blob: ea8fa18e94c676ed23fdf55cb119f88cfe8b4053 [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")
David L. Jones52655b12022-05-06 12:11:46 -07004load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
5load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
6load(":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
38config_setting(
39 name = "config_android",
40 values = {
41 "crosstool_top": "//external:android/crosstool",
42 },
43)
44
45config_setting(
46 name = "config_android-stlport",
47 values = {
48 "crosstool_top": "@androidndk//:toolchain-stlport",
49 },
50)
51
52config_setting(
53 name = "config_android-libcpp",
54 values = {
55 "crosstool_top": "@androidndk//:toolchain-libcpp",
56 },
57)
58
59config_setting(
60 name = "config_android-gnu-libstdcpp",
61 values = {
62 "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
63 },
64)
65
66config_setting(
67 name = "config_android-default",
68 values = {
69 "crosstool_top": "@androidndk//:default_crosstool",
70 },
71)
72
Joshua Haberman2dc76792022-05-23 20:59:31 +000073config_setting(
74 name = "config_win32",
75 values = {
76 "cpu": "win32",
77 },
78)
79
80config_setting(
81 name = "config_win64",
82 values = {
83 "cpu": "win64",
84 },
85)
86
deannagarcia15bd2c22023-03-08 15:36:57 -080087selects.config_setting_group(
88 name = "config_win",
89 match_any = [
90 ":config_win32",
91 ":config_win64",
Adam Cozzette501ecec2023-09-26 14:36:20 -070092 ],
deannagarcia15bd2c22023-03-08 15:36:57 -080093)
94
Mike Kruskal58888822023-03-01 13:45:10 -080095config_setting(
96 name = "config_osx_aarch64",
97 values = {"cpu": "osx-aarch_64"},
98)
99
100config_setting(
101 name = "config_osx_x86_64",
deannagarcia15bd2c22023-03-08 15:36:57 -0800102 values = {"cpu": "osx-x86_64"},
Mike Kruskal58888822023-03-01 13:45:10 -0800103)
104
105selects.config_setting_group(
106 name = "config_osx",
107 match_any = [
Mike Kruskal58888822023-03-01 13:45:10 -0800108 ":config_osx_aarch64",
109 ":config_osx_x86_64",
Adam Cozzette501ecec2023-09-26 14:36:20 -0700110 ],
Mike Kruskal58888822023-03-01 13:45:10 -0800111)
112
David L. Jones52655b12022-05-06 12:11:46 -0700113# Internal testing:
114
115starlark_cc_proto_library(
116 name = "any_cc_proto",
117 visibility = ["//visibility:private"],
118 deps = ["//:any_proto"],
119)
120
121starlark_cc_proto_library(
122 name = "api_cc_proto",
123 visibility = ["//visibility:private"],
124 deps = ["//:api_proto"],
125)
126
127starlark_cc_proto_library(
128 name = "compiler_plugin_cc_proto",
129 visibility = ["//visibility:private"],
130 deps = ["//:compiler_plugin_proto"],
131)
132
133starlark_cc_proto_library(
134 name = "descriptor_cc_proto",
135 visibility = ["//visibility:private"],
136 deps = ["//:descriptor_proto"],
137)
138
139starlark_cc_proto_library(
140 name = "duration_cc_proto",
141 visibility = ["//visibility:private"],
142 deps = ["//:duration_proto"],
143)
144
145starlark_cc_proto_library(
146 name = "empty_cc_proto",
147 visibility = ["//visibility:private"],
148 deps = ["//:empty_proto"],
149)
150
151starlark_cc_proto_library(
152 name = "field_mask_cc_proto",
153 visibility = ["//visibility:private"],
154 deps = ["//:field_mask_proto"],
155)
156
157starlark_cc_proto_library(
158 name = "source_context_cc_proto",
159 visibility = ["//visibility:private"],
160 deps = ["//:source_context_proto"],
161)
162
163starlark_cc_proto_library(
164 name = "struct_cc_proto",
165 visibility = ["//visibility:private"],
166 deps = ["//:struct_proto"],
167)
168
169starlark_cc_proto_library(
170 name = "timestamp_cc_proto",
171 visibility = ["//visibility:private"],
172 deps = ["//:timestamp_proto"],
173)
174
175starlark_cc_proto_library(
176 name = "type_cc_proto",
177 visibility = ["//visibility:private"],
178 deps = ["//:type_proto"],
179)
180
181starlark_cc_proto_library(
182 name = "wrappers_cc_proto",
183 visibility = ["//visibility:private"],
184 deps = ["//:wrappers_proto"],
185)
186
187cc_proto_blacklist_test(
188 name = "cc_proto_blacklist_test",
189 deps = [
190 ":any_cc_proto",
191 ":api_cc_proto",
192 ":compiler_plugin_cc_proto",
193 ":descriptor_cc_proto",
194 ":duration_cc_proto",
195 ":empty_cc_proto",
196 ":field_mask_cc_proto",
197 ":source_context_cc_proto",
198 ":struct_cc_proto",
199 ":timestamp_cc_proto",
200 ":type_cc_proto",
201 ":wrappers_cc_proto",
202 ],
203)
204
205pkg_files(
206 name = "dist_files",
207 srcs = glob(["*"]),
208 strip_prefix = strip_prefix.from_root(""),
209 visibility = ["//pkg:__pkg__"],
210)