• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
16load("@rules_testing//lib:util.bzl", "PREVENT_IMPLICIT_BUILDING_TAGS")
17load("//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
18load(":fake_cc_toolchain_config.bzl", "fake_cc_toolchain_config")
19
20package(default_visibility = ["//:__subpackages__"])
21
22exports_files(["fake_header.h"])
23
24toolchain(
25    name = "fake_py_cc_toolchain",
26    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
27    toolchain = ":fake_py_cc_toolchain_impl",
28    toolchain_type = "@rules_python//python/cc:toolchain_type",
29)
30
31py_cc_toolchain(
32    name = "fake_py_cc_toolchain_impl",
33    headers = ":fake_headers",
34    python_version = "3.999",
35    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
36)
37
38# buildifier: disable=native-cc
39cc_library(
40    name = "fake_headers",
41    hdrs = ["fake_header.h"],
42    data = ["data.txt"],
43    includes = ["fake_include"],
44    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
45)
46
47cc_toolchain_suite(
48    name = "cc_toolchain_suite",
49    tags = ["manual"],
50    toolchains = {
51        "darwin_x86_64": ":mac_toolchain",
52        "k8": ":linux_toolchain",
53    },
54)
55
56filegroup(name = "empty")
57
58cc_toolchain(
59    name = "mac_toolchain",
60    all_files = ":empty",
61    compiler_files = ":empty",
62    dwp_files = ":empty",
63    linker_files = ":empty",
64    objcopy_files = ":empty",
65    strip_files = ":empty",
66    supports_param_files = 0,
67    toolchain_config = ":mac_toolchain_config",
68    toolchain_identifier = "mac-toolchain",
69)
70
71toolchain(
72    name = "mac_toolchain_definition",
73    target_compatible_with = ["@platforms//os:macos"],
74    toolchain = ":mac_toolchain",
75    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
76)
77
78fake_cc_toolchain_config(
79    name = "mac_toolchain_config",
80    target_cpu = "darwin_x86_64",
81    toolchain_identifier = "mac-toolchain",
82)
83
84cc_toolchain(
85    name = "linux_toolchain",
86    all_files = ":empty",
87    compiler_files = ":empty",
88    dwp_files = ":empty",
89    linker_files = ":empty",
90    objcopy_files = ":empty",
91    strip_files = ":empty",
92    supports_param_files = 0,
93    toolchain_config = ":linux_toolchain_config",
94    toolchain_identifier = "linux-toolchain",
95)
96
97toolchain(
98    name = "linux_toolchain_definition",
99    target_compatible_with = ["@platforms//os:linux"],
100    toolchain = ":linux_toolchain",
101    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
102)
103
104fake_cc_toolchain_config(
105    name = "linux_toolchain_config",
106    target_cpu = "k8",
107    toolchain_identifier = "linux-toolchain",
108)
109