blob: 11c773639e09c0a6ba40b15eadd5e015e256730e [file] [log] [blame]
Serge Bazanski385c12f2020-06-17 12:12:42 +02001# 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 Bazanski9e861a82020-09-16 13:46:41 +020017load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "tool", "tool_path")
Serge Bazanski385c12f2020-06-17 12:12:42 +020018
Serge Bazanski9e861a82020-09-16 13:46:41 +020019# This defines a minimal, barely parametrized toolchain configuration rule that
20# uses the host GCC with some possible overrides.
Serge Bazanski385c12f2020-06-17 12:12:42 +020021
22def _host_cc_toolchain_impl(ctx):
23 tool_paths = [
24 tool_path(
25 name = "gcc",
Serge Bazanski9e861a82020-09-16 13:46:41 +020026 path = ctx.attr.gcc,
Serge Bazanski385c12f2020-06-17 12:12:42 +020027 ),
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 Bazanski9e861a82020-09-16 13:46:41 +020059 cxx_builtin_include_directories = ctx.attr.host_includes,
Serge Bazanski385c12f2020-06-17 12:12:42 +020060 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 Bazanski9e861a82020-09-16 13:46:41 +020069 builtin_sysroot = ctx.attr.sysroot,
Serge Bazanski385c12f2020-06-17 12:12:42 +020070 )
71
72host_cc_toolchain_config = rule(
73 implementation = _host_cc_toolchain_impl,
Serge Bazanski9e861a82020-09-16 13:46:41 +020074 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 Bazanski385c12f2020-06-17 12:12:42 +020088 provides = [CcToolchainConfigInfo],
89)