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