Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 1 | # Copyright 2020 The Monogon Project Authors. |
| 2 | # |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame^] | 17 | load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "tool", "tool_path") |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 18 | |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame^] | 19 | # This defines a minimal, barely parametrized toolchain configuration rule that |
| 20 | # uses the host GCC with some possible overrides. |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 21 | |
| 22 | def _host_cc_toolchain_impl(ctx): |
| 23 | tool_paths = [ |
| 24 | tool_path( |
| 25 | name = "gcc", |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame^] | 26 | path = ctx.attr.gcc, |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 27 | ), |
| 28 | tool_path( |
| 29 | name = "ld", |
| 30 | path = "/usr/bin/ld", |
| 31 | ), |
| 32 | tool_path( |
| 33 | name = "ar", |
| 34 | path = "/usr/bin/ar", |
| 35 | ), |
| 36 | tool_path( |
| 37 | name = "cpp", |
| 38 | path = "/bin/false", |
| 39 | ), |
| 40 | tool_path( |
| 41 | name = "gcov", |
| 42 | path = "/bin/false", |
| 43 | ), |
| 44 | tool_path( |
| 45 | name = "nm", |
| 46 | path = "/bin/false", |
| 47 | ), |
| 48 | tool_path( |
| 49 | name = "objdump", |
| 50 | path = "/bin/false", |
| 51 | ), |
| 52 | tool_path( |
| 53 | name = "strip", |
| 54 | path = "/bin/false", |
| 55 | ), |
| 56 | ] |
| 57 | return cc_common.create_cc_toolchain_config_info( |
| 58 | ctx = ctx, |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame^] | 59 | cxx_builtin_include_directories = ctx.attr.host_includes, |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 60 | toolchain_identifier = "k8-toolchain", |
| 61 | host_system_name = "local", |
| 62 | target_system_name = "local", |
| 63 | target_cpu = "k8", |
| 64 | target_libc = "unknown", |
| 65 | compiler = "gcc", |
| 66 | abi_version = "unknown", |
| 67 | abi_libc_version = "unknown", |
| 68 | tool_paths = tool_paths, |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame^] | 69 | builtin_sysroot = ctx.attr.sysroot, |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 70 | ) |
| 71 | |
| 72 | host_cc_toolchain_config = rule( |
| 73 | implementation = _host_cc_toolchain_impl, |
Serge Bazanski | 9e861a8 | 2020-09-16 13:46:41 +0200 | [diff] [blame^] | 74 | attrs = { |
| 75 | "gcc": attr.string( |
| 76 | default = "/usr/bin/gcc", |
| 77 | ), |
| 78 | "host_includes": attr.string_list( |
| 79 | default = [ |
| 80 | "/usr/lib/gcc/x86_64-redhat-linux/10/include/", |
| 81 | "/usr/include", |
| 82 | ], |
| 83 | ), |
| 84 | "sysroot": attr.string( |
| 85 | default = "", |
| 86 | ), |
| 87 | }, |
Serge Bazanski | 385c12f | 2020-06-17 12:12:42 +0200 | [diff] [blame] | 88 | provides = [CcToolchainConfigInfo], |
| 89 | ) |