• 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/toolchains:cc_toolchain.bzl", "cc_toolchain")
16load("@rules_cc//cc/toolchains:cc_toolchain_suite.bzl", "cc_toolchain_suite")
17load("@rules_testing//lib:util.bzl", "PREVENT_IMPLICIT_BUILDING_TAGS")
18load("//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
19load(":fake_cc_toolchain_config.bzl", "fake_cc_toolchain_config")
20
21package(default_visibility = ["//:__subpackages__"])
22
23exports_files(["fake_header.h"])
24
25filegroup(
26    name = "libpython",
27    srcs = ["libpython-fake.so"],
28    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
29)
30
31toolchain(
32    name = "fake_py_cc_toolchain",
33    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
34    toolchain = ":fake_py_cc_toolchain_impl",
35    toolchain_type = "@rules_python//python/cc:toolchain_type",
36)
37
38py_cc_toolchain(
39    name = "fake_py_cc_toolchain_impl",
40    headers = ":fake_headers",
41    libs = ":fake_libs",
42    python_version = "3.999",
43    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
44)
45
46# buildifier: disable=native-cc
47cc_library(
48    name = "fake_headers",
49    hdrs = ["fake_header.h"],
50    data = ["data.txt"],
51    includes = ["fake_include"],
52    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
53)
54
55# buildifier: disable=native-cc
56cc_library(
57    name = "fake_libs",
58    srcs = ["libpython3.so"],
59    data = ["libdata.txt"],
60    tags = PREVENT_IMPLICIT_BUILDING_TAGS,
61)
62
63cc_toolchain_suite(
64    name = "cc_toolchain_suite",
65    tags = ["manual"],
66    toolchains = {
67        "darwin_x86_64": ":mac_toolchain",
68        "k8": ":linux_toolchain",
69        "windows_x86_64": ":windows_toolchain",
70    },
71)
72
73filegroup(name = "empty")
74
75cc_toolchain(
76    name = "mac_toolchain",
77    all_files = ":empty",
78    compiler_files = ":empty",
79    dwp_files = ":empty",
80    linker_files = ":empty",
81    objcopy_files = ":empty",
82    strip_files = ":empty",
83    supports_param_files = 0,
84    toolchain_config = ":mac_toolchain_config",
85    toolchain_identifier = "mac-toolchain",
86)
87
88toolchain(
89    name = "mac_toolchain_definition",
90    target_compatible_with = ["@platforms//os:macos"],
91    toolchain = ":mac_toolchain",
92    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
93)
94
95fake_cc_toolchain_config(
96    name = "mac_toolchain_config",
97    target_cpu = "darwin_x86_64",
98    toolchain_identifier = "mac-toolchain",
99)
100
101cc_toolchain(
102    name = "linux_toolchain",
103    all_files = ":empty",
104    compiler_files = ":empty",
105    dwp_files = ":empty",
106    linker_files = ":empty",
107    objcopy_files = ":empty",
108    strip_files = ":empty",
109    supports_param_files = 0,
110    toolchain_config = ":linux_toolchain_config",
111    toolchain_identifier = "linux-toolchain",
112)
113
114toolchain(
115    name = "linux_toolchain_definition",
116    target_compatible_with = ["@platforms//os:linux"],
117    toolchain = ":linux_toolchain",
118    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
119)
120
121fake_cc_toolchain_config(
122    name = "linux_toolchain_config",
123    target_cpu = "k8",
124    toolchain_identifier = "linux-toolchain",
125)
126
127cc_toolchain(
128    name = "windows_toolchain",
129    all_files = ":empty",
130    compiler_files = ":empty",
131    dwp_files = ":empty",
132    linker_files = ":empty",
133    objcopy_files = ":empty",
134    strip_files = ":empty",
135    supports_param_files = 0,
136    toolchain_config = ":windows_toolchain_config",
137    toolchain_identifier = "windows-toolchain",
138)
139
140toolchain(
141    name = "windows_toolchain_definition",
142    target_compatible_with = ["@platforms//os:windows"],
143    toolchain = ":windows_toolchain",
144    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
145)
146
147fake_cc_toolchain_config(
148    name = "windows_toolchain_config",
149    target_cpu = "windows_x86_64",
150    toolchain_identifier = "windows-toolchain",
151)
152