blob: a0e0438d6ef9c7adc36885dd8c410f54b5114327 [file] [log] [blame]
David L. Jones52655b12022-05-06 12:11:46 -07001# Internal Starlark definitions for Protobuf.
2
Mike Kruskal58888822023-03-01 13:45:10 -08003load("@bazel_skylib//lib:selects.bzl", "selects")
aiuto3ab12762024-02-13 09:06:30 -08004load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
Protobuf Team Bot21d75f82024-04-05 07:45:26 -07005load("//bazel:cc_proto_library.bzl", starlark_cc_proto_library = "cc_proto_library")
David L. Jones52655b12022-05-06 12:11:46 -07006load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
7load(":compiler_config_setting.bzl", "create_compiler_config_setting")
8
9package(
10 default_visibility = [
11 # Public, but Protobuf only visibility.
12 "//:__subpackages__",
13 ],
14)
15
16create_compiler_config_setting(
17 name = "config_msvc",
18 value = "msvc-cl",
19)
20
Mike Kruskaled5c57a2022-08-10 22:51:29 -070021config_setting(
22 name = "aarch64",
23 values = {"cpu": "linux-aarch_64"},
24)
25
26config_setting(
27 name = "x86_64",
28 values = {"cpu": "linux-x86_64"},
29)
30
David L. Jones52655b12022-05-06 12:11:46 -070031# Android NDK builds can specify different crosstool_top flags to choose which
32# STL they use for C++. We need these multiple variants to catch all of those
33# versions of crosstool_top and reliably detect Android.
34#
35# For more info on the various crosstool_tops used by NDK Bazel builds, see:
36# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl
37
Ming-Chuane5417472024-03-13 09:42:33 -070038# When using https://bazel.build/concepts/platforms
David L. Jones52655b12022-05-06 12:11:46 -070039config_setting(
40 name = "config_android",
Ming-Chuaneef55642024-03-22 09:17:10 -070041 constraint_values = ["@platforms//os:android"],
David L. Jones52655b12022-05-06 12:11:46 -070042)
43
Ming-Chuane5417472024-03-13 09:42:33 -070044# When using legacy flags like --android_crosstool_top, --android_cpu, and --fat_apk_cpu
45config_setting(
46 name = "config_android-legacy-default-crosstool",
47 values = {
48 # Default of `--android_crosstool_top`
49 "crosstool_top": "//external:android/crosstool",
50 },
51)
52
David L. Jones52655b12022-05-06 12:11:46 -070053config_setting(
54 name = "config_android-stlport",
55 values = {
56 "crosstool_top": "@androidndk//:toolchain-stlport",
57 },
58)
59
60config_setting(
61 name = "config_android-libcpp",
62 values = {
63 "crosstool_top": "@androidndk//:toolchain-libcpp",
64 },
65)
66
67config_setting(
68 name = "config_android-gnu-libstdcpp",
69 values = {
70 "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
71 },
72)
73
74config_setting(
75 name = "config_android-default",
76 values = {
77 "crosstool_top": "@androidndk//:default_crosstool",
78 },
79)
80
Joshua Haberman2dc76792022-05-23 20:59:31 +000081config_setting(
82 name = "config_win32",
83 values = {
84 "cpu": "win32",
85 },
86)
87
88config_setting(
89 name = "config_win64",
90 values = {
91 "cpu": "win64",
92 },
93)
94
deannagarcia15bd2c22023-03-08 15:36:57 -080095selects.config_setting_group(
96 name = "config_win",
97 match_any = [
98 ":config_win32",
99 ":config_win64",
Adam Cozzette501ecec2023-09-26 14:36:20 -0700100 ],
deannagarcia15bd2c22023-03-08 15:36:57 -0800101)
102
Mike Kruskal58888822023-03-01 13:45:10 -0800103config_setting(
104 name = "config_osx_aarch64",
105 values = {"cpu": "osx-aarch_64"},
106)
107
108config_setting(
109 name = "config_osx_x86_64",
deannagarcia15bd2c22023-03-08 15:36:57 -0800110 values = {"cpu": "osx-x86_64"},
Mike Kruskal58888822023-03-01 13:45:10 -0800111)
112
113selects.config_setting_group(
114 name = "config_osx",
115 match_any = [
Mike Kruskal58888822023-03-01 13:45:10 -0800116 ":config_osx_aarch64",
117 ":config_osx_x86_64",
Adam Cozzette501ecec2023-09-26 14:36:20 -0700118 ],
Mike Kruskal58888822023-03-01 13:45:10 -0800119)
120
David L. Jones52655b12022-05-06 12:11:46 -0700121# Internal testing:
122
123starlark_cc_proto_library(
124 name = "any_cc_proto",
125 visibility = ["//visibility:private"],
126 deps = ["//:any_proto"],
127)
128
129starlark_cc_proto_library(
130 name = "api_cc_proto",
131 visibility = ["//visibility:private"],
132 deps = ["//:api_proto"],
133)
134
135starlark_cc_proto_library(
136 name = "compiler_plugin_cc_proto",
137 visibility = ["//visibility:private"],
138 deps = ["//:compiler_plugin_proto"],
139)
140
141starlark_cc_proto_library(
142 name = "descriptor_cc_proto",
143 visibility = ["//visibility:private"],
144 deps = ["//:descriptor_proto"],
145)
146
147starlark_cc_proto_library(
148 name = "duration_cc_proto",
149 visibility = ["//visibility:private"],
150 deps = ["//:duration_proto"],
151)
152
153starlark_cc_proto_library(
154 name = "empty_cc_proto",
155 visibility = ["//visibility:private"],
156 deps = ["//:empty_proto"],
157)
158
159starlark_cc_proto_library(
160 name = "field_mask_cc_proto",
161 visibility = ["//visibility:private"],
162 deps = ["//:field_mask_proto"],
163)
164
165starlark_cc_proto_library(
166 name = "source_context_cc_proto",
167 visibility = ["//visibility:private"],
168 deps = ["//:source_context_proto"],
169)
170
171starlark_cc_proto_library(
172 name = "struct_cc_proto",
173 visibility = ["//visibility:private"],
174 deps = ["//:struct_proto"],
175)
176
177starlark_cc_proto_library(
178 name = "timestamp_cc_proto",
179 visibility = ["//visibility:private"],
180 deps = ["//:timestamp_proto"],
181)
182
183starlark_cc_proto_library(
184 name = "type_cc_proto",
185 visibility = ["//visibility:private"],
186 deps = ["//:type_proto"],
187)
188
189starlark_cc_proto_library(
190 name = "wrappers_cc_proto",
191 visibility = ["//visibility:private"],
192 deps = ["//:wrappers_proto"],
193)
194
195cc_proto_blacklist_test(
196 name = "cc_proto_blacklist_test",
197 deps = [
198 ":any_cc_proto",
199 ":api_cc_proto",
200 ":compiler_plugin_cc_proto",
201 ":descriptor_cc_proto",
202 ":duration_cc_proto",
203 ":empty_cc_proto",
204 ":field_mask_cc_proto",
205 ":source_context_cc_proto",
206 ":struct_cc_proto",
207 ":timestamp_cc_proto",
208 ":type_cc_proto",
209 ":wrappers_cc_proto",
210 ],
211)
212
213pkg_files(
214 name = "dist_files",
215 srcs = glob(["*"]),
216 strip_prefix = strip_prefix.from_root(""),
217 visibility = ["//pkg:__pkg__"],
218)