blob: 95701d1d2f9c0fbfe4c94f1353e5a86ce3e5ee1c [file] [log] [blame]
Joshua Haberman823eb092021-04-05 12:26:41 -07001# Copyright (c) 2009-2021, Google LLC
Joshua Habermane59d2c82021-04-05 10:47:53 -07002# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6# * Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# * Redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution.
11# * Neither the name of Google LLC nor the
12# names of its contributors may be used to endorse or promote products
13# derived from this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
19# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
Josh Haberman2655ed92018-11-03 13:04:10 -070026load(
Joshua Haberman5611ff22019-05-16 11:35:00 -070027 "//bazel:build_defs.bzl",
Joshua Habermane3f41de2020-10-17 13:15:58 -070028 "UPB_DEFAULT_COPTS",
Joshua Haberman11b6df02022-02-15 19:55:44 -080029 "UPB_DEFAULT_CPPOPTS",
30 "make_shell_script",
Joshua Haberman06b90f92019-05-14 15:58:58 -070031)
Joshua Haberman06b90f92019-05-14 15:58:58 -070032load(
Joshua Haberman5611ff22019-05-16 11:35:00 -070033 "//bazel:upb_proto_library.bzl",
Joshua Habermana345af92020-10-18 13:39:13 -070034 "upb_fasttable_enabled",
Josh Habermana7ebe542018-11-03 18:18:47 -070035 "upb_proto_library",
Joshua Habermana274ad72020-10-28 13:06:30 -070036 "upb_proto_library_copts",
Joshua Habermane8f9eac2020-10-28 22:50:03 -070037 "upb_proto_reflection_library",
Josh Haberman2655ed92018-11-03 13:04:10 -070038)
Joshua Haberman0dc23942020-06-05 09:17:33 -070039
Protobuf Teamb8edc712022-03-16 08:24:52 -070040# begin:github_only
41load(
42 "//bazel:build_defs.bzl",
43 "upb_amalgamation",
44)
45# end:github_only
46
Joshua Haberman83c0edb2021-02-28 16:56:49 -080047licenses(["notice"])
Joshua Haberman7f9f7222019-01-23 17:10:22 -080048
Joshua Habermana5243ff2022-03-30 14:20:07 -070049exports_files(["LICENSE"])
50
51exports_files(
52 [
53 "BUILD",
54 "WORKSPACE",
55 ],
56 visibility = ["//cmake:__pkg__"],
57)
Joshua Haberman7f9f7222019-01-23 17:10:22 -080058
Joshua Haberman00f96cb2019-03-27 12:13:59 -070059config_setting(
Nicolas "Pixel" Noblece3ba4d2019-07-18 01:12:00 +020060 name = "windows",
Protobuf Teame5f26012022-06-01 14:40:00 -070061 constraint_values = ["@platforms//os:windows"],
Eli Schleifer231daa32021-12-20 16:01:23 -080062 visibility = ["//visibility:public"],
Nicolas "Pixel" Noblece3ba4d2019-07-18 01:12:00 +020063)
64
Joshua Habermana345af92020-10-18 13:39:13 -070065upb_fasttable_enabled(
66 name = "fasttable_enabled",
Joshua Habermanb9286962020-10-26 21:23:16 -070067 build_setting_default = False,
Joshua Habermana345af92020-10-18 13:39:13 -070068 visibility = ["//visibility:public"],
69)
70
Joshua Habermane8f9eac2020-10-28 22:50:03 -070071config_setting(
72 name = "fasttable_enabled_setting",
73 flag_values = {"//:fasttable_enabled": "true"},
74)
75
Joshua Habermana274ad72020-10-28 13:06:30 -070076upb_proto_library_copts(
77 name = "upb_proto_library_copts__for_generated_code_only_do_not_use",
78 copts = UPB_DEFAULT_COPTS,
79 visibility = ["//visibility:public"],
80)
81
Joshua Haberman6df55172022-05-24 11:41:56 -070082package_group(
83 name = "friends",
84 packages = [],
85)
86
Joshua Haberman928ef7f2019-03-27 12:52:33 -070087# Public C/C++ libraries #######################################################
Josh Haberman01ed4ce2018-11-02 12:49:15 -070088
89cc_library(
Anna Rde1bc112020-01-07 15:45:19 -080090 name = "port",
Joshua Habermana60e9a32022-05-13 17:32:17 -070091 hdrs = [
92 "upb/internal/vsnprintf_compat.h",
93 ],
Joshua Haberman558315a2020-10-28 17:13:13 -070094 copts = UPB_DEFAULT_COPTS,
Anna Rde1bc112020-01-07 15:45:19 -080095 textual_hdrs = [
96 "upb/port_def.inc",
97 "upb/port_undef.inc",
98 ],
Matt Kulukundisc49e6df2022-02-21 20:12:58 -050099 visibility = ["//:__subpackages__"],
Anna Rde1bc112020-01-07 15:45:19 -0800100)
101
102cc_library(
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700103 name = "upb",
104 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700105 "upb/arena.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700106 "upb/decode.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700107 "upb/encode.c",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700108 "upb/internal/decode.h",
109 "upb/internal/table.h",
110 "upb/internal/upb.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700111 "upb/msg.c",
Joshua Haberman38813932021-04-05 16:00:25 -0700112 "upb/msg_internal.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700113 "upb/status.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700114 "upb/table.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700115 "upb/upb.c",
116 ],
117 hdrs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700118 "upb/arena.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700119 "upb/decode.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700120 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700121 "upb/extension_registry.h",
Joshua Haberman1674f282021-04-04 18:43:24 -0700122 "upb/msg.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700123 "upb/status.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700124 "upb/upb.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700125 "upb/upb.hpp",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700126 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700127 copts = UPB_DEFAULT_COPTS,
Joshua Habermanba29af32019-06-01 19:27:49 -0700128 visibility = ["//visibility:public"],
Joshua Habermanefd576b2020-10-26 21:37:17 -0700129 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700130 ":extension_registry",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700131 ":fastdecode",
132 ":port",
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700133 "//third_party/utf8_range",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700134 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700135)
136
137cc_library(
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700138 name = "extension_registry",
139 srcs = [
140 "upb/extension_registry.c",
141 "upb/msg.h",
142 "upb/msg_internal.h",
143 "upb/upb.h",
144 ],
145 hdrs = [
146 "upb/extension_registry.h",
147 ],
148 copts = UPB_DEFAULT_COPTS,
149 visibility = ["//visibility:public"],
150 deps = [
151 ":port",
152 ":table",
153 ],
154)
155
156cc_library(
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700157 name = "mini_descriptor",
158 srcs = [
159 "upb/mini_descriptor.c",
160 ],
161 hdrs = [
162 "upb/mini_descriptor.h",
163 ],
164 copts = UPB_DEFAULT_COPTS,
165 visibility = ["//visibility:public"],
166 deps = [
167 ":descriptor_upb_proto",
168 ":mini_table",
169 ":port",
170 ":reflection",
171 ":table",
172 ":upb",
173 ],
174)
175
176cc_library(
Joshua Haberman970c6452022-03-08 17:44:06 -0800177 name = "mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700178 hdrs = [
179 "upb/msg_internal.h",
180 ],
Joshua Haberman970c6452022-03-08 17:44:06 -0800181 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700182 ":extension_registry",
Joshua Haberman970c6452022-03-08 17:44:06 -0800183 ":port",
184 ":table",
185 ":upb",
186 ],
187)
188
189cc_library(
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800190 name = "mini_table",
Protobuf Teame5468b42022-04-19 14:09:14 -0700191 srcs = [
192 "upb/mini_table.c",
193 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800194 hdrs = [
195 "upb/mini_table.h",
196 "upb/mini_table.hpp",
197 ],
198 copts = UPB_DEFAULT_COPTS,
199 visibility = ["//visibility:public"],
Joshua Haberman970c6452022-03-08 17:44:06 -0800200 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700201 ":extension_registry",
Joshua Haberman970c6452022-03-08 17:44:06 -0800202 ":mini_table_internal",
203 ":port",
204 ":upb",
205 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800206)
207
Protobuf Teame5468b42022-04-19 14:09:14 -0700208cc_library(
209 name = "mini_table_accessors",
210 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700211 "upb/internal/mini_table_accessors.h",
Protobuf Teame5468b42022-04-19 14:09:14 -0700212 "upb/mini_table_accessors.c",
Protobuf Teame5468b42022-04-19 14:09:14 -0700213 ],
214 hdrs = [
215 "upb/mini_table_accessors.h",
216 ],
217 copts = UPB_DEFAULT_COPTS,
Joshua Haberman6df55172022-05-24 11:41:56 -0700218 visibility = ["//visibility:public"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700219 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700220 ":collections",
Protobuf Teame5468b42022-04-19 14:09:14 -0700221 ":mini_table",
222 ":mini_table_internal",
223 ":port",
224 ":upb",
225 ],
226)
227
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800228cc_test(
229 name = "mini_table_test",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700230 srcs = [
231 "upb/internal/table.h",
232 "upb/mini_table_test.cc",
233 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800234 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700235 ":extension_registry",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800236 ":mini_table",
Joshua Haberman970c6452022-03-08 17:44:06 -0800237 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700238 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800239 ":upb",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800240 "@com_google_absl//absl/container:flat_hash_set",
Joshua Haberman970c6452022-03-08 17:44:06 -0800241 "@com_google_googletest//:gtest_main",
Joshua Haberman8d148f02022-03-13 18:45:50 -0700242 "@com_google_protobuf//:protobuf",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800243 ],
244)
245
Protobuf Teame5468b42022-04-19 14:09:14 -0700246cc_test(
247 name = "mini_table_accessors_test",
248 srcs = ["upb/mini_table_accessors_test.cc"],
249 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700250 ":collections",
Protobuf Teame5468b42022-04-19 14:09:14 -0700251 ":mini_table",
252 ":mini_table_accessors",
253 ":mini_table_internal",
254 ":test_messages_proto2_proto_upb",
255 ":test_messages_proto3_proto_upb",
Protobuf Team459059e2022-05-09 14:13:02 -0700256 ":test_upb_proto",
Protobuf Teame5468b42022-04-19 14:09:14 -0700257 ":upb",
258 "@com_google_absl//absl/container:flat_hash_set",
259 "@com_google_googletest//:gtest_main",
260 "@com_google_protobuf//:protobuf",
261 ],
262)
263
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800264cc_library(
Joshua Habermancb234e62020-10-17 17:48:32 -0700265 name = "fastdecode",
266 srcs = [
Joshua Haberman3d437bb2021-10-13 09:53:36 -0700267 "upb/decode.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700268 "upb/decode_fast.c",
269 "upb/decode_fast.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700270 "upb/internal/decode.h",
271 "upb/internal/upb.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700272 "upb/msg.h",
Joshua Haberman38813932021-04-05 16:00:25 -0700273 "upb/msg_internal.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700274 ],
Joshua Habermane86541a2020-10-28 17:53:09 -0700275 copts = UPB_DEFAULT_COPTS,
Joshua Habermanefd576b2020-10-26 21:37:17 -0700276 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700277 ":extension_registry",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700278 ":port",
279 ":table",
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700280 "//third_party/utf8_range",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700281 ],
Joshua Habermanba29af32019-06-01 19:27:49 -0700282)
283
284# Common support routines used by generated code. This library has no
285# implementation, but depends on :upb and exposes a few more hdrs.
286#
287# This is public only because we have no way of visibility-limiting it to
288# upb_proto_library() only. This interface is not stable and by using it you
289# give up any backward compatibility guarantees.
290cc_library(
291 name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
Joshua Habermanba29af32019-06-01 19:27:49 -0700292 hdrs = [
Joshua Haberman8c530f92022-02-22 14:50:55 -0800293 "upb/decode.h",
Joshua Habermanaec762e2020-10-11 23:14:50 -0700294 "upb/decode_fast.h",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800295 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700296 "upb/extension_registry.h",
Joshua Habermanba29af32019-06-01 19:27:49 -0700297 "upb/msg.h",
Joshua Haberman42bdfcb2021-04-06 09:25:28 -0700298 "upb/msg_internal.h",
Anna Ra27429f2020-01-09 14:50:03 -0800299 "upb/port_def.inc",
300 "upb/port_undef.inc",
Joshua Habermanba29af32019-06-01 19:27:49 -0700301 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700302 copts = UPB_DEFAULT_COPTS,
Vishal Powar7031f772018-11-28 15:32:16 -0800303 visibility = ["//visibility:public"],
Anna Rde1bc112020-01-07 15:45:19 -0800304 deps = [
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800305 ":table",
Anna Rde1bc112020-01-07 15:45:19 -0800306 ":upb",
307 ],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700308)
309
Joshua Haberman8c530f92022-02-22 14:50:55 -0800310cc_library(
311 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
312 hdrs = [
313 "upb/def.h",
314 "upb/port_def.inc",
315 "upb/port_undef.inc",
316 ],
317 copts = UPB_DEFAULT_COPTS,
318 visibility = ["//visibility:public"],
319 deps = [
320 ":descriptor_upb_proto",
321 ":reflection",
322 ":table",
323 ],
324)
325
Josh Habermancd9e1e62019-04-17 15:23:00 -0700326upb_proto_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700327 name = "descriptor_upb_proto",
328 visibility = ["//visibility:public"],
329 deps = ["@com_google_protobuf//:descriptor_proto"],
330)
331
332upb_proto_reflection_library(
333 name = "descriptor_upb_proto_reflection",
Joshua Habermanc58541e2019-05-15 09:49:29 -0700334 visibility = ["//visibility:public"],
Google-Autofuzz8f196672019-06-25 20:14:14 -0400335 deps = ["@com_google_protobuf//:descriptor_proto"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700336)
337
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700338cc_library(
Protobuf Team823ed182022-04-28 16:07:14 -0700339 name = "collections",
340 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700341 "upb/array.c",
342 "upb/map.c",
Protobuf Team823ed182022-04-28 16:07:14 -0700343 ],
344 hdrs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700345 "upb/array.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700346 "upb/collections.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700347 "upb/map.h",
348 "upb/message_value.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700349 ],
350 copts = UPB_DEFAULT_COPTS,
351 visibility = ["//visibility:public"],
352 deps = [
353 ":descriptor_upb_proto",
354 ":mini_table",
355 ":port",
356 ":table",
357 ":upb",
358 ],
359)
360
361cc_library(
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700362 name = "reflection",
363 srcs = [
364 "upb/def.c",
Joshua Haberman58010a32020-02-18 16:53:21 -0800365 "upb/msg.h",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800366 "upb/reflection.c",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700367 ],
368 hdrs = [
369 "upb/def.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700370 "upb/def.hpp",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800371 "upb/reflection.h",
Joshua Haberman5e550e82021-01-09 15:45:44 -0800372 "upb/reflection.hpp",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700373 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700374 copts = UPB_DEFAULT_COPTS,
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700375 visibility = ["//visibility:public"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700376 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700377 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700378 ":descriptor_upb_proto",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700379 ":mini_table",
Anna Rfc494112020-01-09 14:16:25 -0800380 ":port",
Joshua Haberman9b073112019-05-14 11:12:13 -0700381 ":table",
Joshua Haberman9a663562019-05-13 16:13:39 -0700382 ":upb",
Josh Habermancd9e1e62019-04-17 15:23:00 -0700383 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700384)
385
Joshua Habermance1a3992020-02-04 06:22:09 -0800386cc_library(
387 name = "textformat",
388 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700389 "upb/internal/upb.h",
Joshua Haberman02c89a82020-02-10 14:56:27 -0800390 "upb/text_encode.c",
Joshua Habermance1a3992020-02-04 06:22:09 -0800391 ],
392 hdrs = [
Joshua Haberman02c89a82020-02-10 14:56:27 -0800393 "upb/text_encode.h",
Joshua Habermance1a3992020-02-04 06:22:09 -0800394 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700395 copts = UPB_DEFAULT_COPTS,
Joshua Habermance1a3992020-02-04 06:22:09 -0800396 visibility = ["//visibility:public"],
397 deps = [
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800398 ":port",
Joshua Habermance1a3992020-02-04 06:22:09 -0800399 ":reflection",
Matt Kulukundisedd1dd32022-02-20 17:44:27 -0500400 ":table",
Joshua Habermance1a3992020-02-04 06:22:09 -0800401 ],
402)
403
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800404cc_library(
405 name = "json",
406 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700407 "upb/internal/upb.h",
Joshua Habermand49c1db2020-02-23 19:49:39 -0800408 "upb/json_decode.c",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800409 "upb/json_encode.c",
410 ],
411 hdrs = [
Joshua Habermand49c1db2020-02-23 19:49:39 -0800412 "upb/json_decode.h",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800413 "upb/json_encode.h",
414 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700415 copts = UPB_DEFAULT_COPTS,
Lidi Zhengf72c26c2020-12-10 16:23:08 -0800416 visibility = ["//visibility:public"],
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800417 deps = [
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800418 ":port",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800419 ":reflection",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800420 ":upb",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800421 ],
422)
423
Joshua Haberman11b6df02022-02-15 19:55:44 -0800424# Tests ########################################################################
425
426cc_test(
427 name = "test_generated_code",
428 srcs = ["upb/test_generated_code.cc"],
429 deps = [
430 ":empty_upbdefs_proto",
Joshua Haberman1cf82142022-05-12 13:57:50 -0700431 ":port",
Protobuf Teambef53682022-04-04 11:18:39 -0700432 ":test_messages_proto2_proto_upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800433 ":test_messages_proto3_proto_upb",
434 ":test_upb_proto",
Matt Kulukundisedd1dd32022-02-20 17:44:27 -0500435 ":upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800436 "@com_google_googletest//:gtest_main",
437 ],
438)
439
440proto_library(
441 name = "test_proto",
442 testonly = 1,
443 srcs = ["upb/test.proto"],
444)
445
446upb_proto_library(
447 name = "test_upb_proto",
448 testonly = 1,
449 deps = [":test_proto"],
450)
451
452proto_library(
453 name = "empty_proto",
454 srcs = ["upb/empty.proto"],
455)
456
457upb_proto_reflection_library(
458 name = "empty_upbdefs_proto",
459 testonly = 1,
460 deps = [":empty_proto"],
461)
462
463upb_proto_library(
Protobuf Teambef53682022-04-04 11:18:39 -0700464 name = "test_messages_proto2_proto_upb",
465 testonly = 1,
466 deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
467)
468
469upb_proto_library(
Joshua Haberman11b6df02022-02-15 19:55:44 -0800470 name = "test_messages_proto3_proto_upb",
471 testonly = 1,
472 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
473)
Matt Kulukundis61b09052022-02-19 19:35:58 -0500474
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700475proto_library(
476 name = "json_test_proto",
477 testonly = 1,
478 srcs = ["upb/json_test.proto"],
479 deps = ["@com_google_protobuf//:struct_proto"],
480)
481
482upb_proto_library(
483 name = "json_test_upb_proto",
484 testonly = 1,
485 deps = [":json_test_proto"],
486)
487
488upb_proto_reflection_library(
489 name = "json_test_upb_proto_reflection",
490 testonly = 1,
491 deps = [":json_test_proto"],
492)
493
494cc_test(
495 name = "json_test",
496 srcs = ["upb/json_test.cc"],
497 deps = [
498 ":json",
499 ":json_test_upb_proto",
500 ":json_test_upb_proto_reflection",
501 ":reflection",
502 ":struct_upb_proto",
503 ":upb",
504 "@com_google_googletest//:gtest_main",
505 ],
506)
507
Joshua Habermance012b72021-10-01 16:34:42 -0700508cc_test(
509 name = "msg_test",
510 srcs = ["upb/msg_test.cc"],
511 deps = [
Joshua Habermance012b72021-10-01 16:34:42 -0700512 ":json",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500513 ":msg_test_upb_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500514 ":msg_test_upb_proto_reflection",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500515 ":reflection",
Matt Kulukundis42c121e2022-02-21 23:58:17 -0500516 ":test_messages_proto3_proto_upb",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500517 ":upb",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500518 "@com_google_googletest//:gtest_main",
Joshua Habermance012b72021-10-01 16:34:42 -0700519 ],
520)
521
522proto_library(
523 name = "msg_test_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500524 testonly = 1,
Joshua Habermance012b72021-10-01 16:34:42 -0700525 srcs = ["upb/msg_test.proto"],
526 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
527)
528
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500529upb_proto_library(
530 name = "msg_test_upb_proto",
531 testonly = 1,
532 deps = [":msg_test_proto"],
533)
534
Joshua Habermance012b72021-10-01 16:34:42 -0700535upb_proto_reflection_library(
536 name = "msg_test_upb_proto_reflection",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500537 testonly = 1,
Joshua Habermance012b72021-10-01 16:34:42 -0700538 deps = [":msg_test_proto"],
539)
540
Joshua Haberman11b6df02022-02-15 19:55:44 -0800541proto_library(
542 name = "test_cpp_proto",
543 srcs = ["upb/test_cpp.proto"],
Matt Kulukundis61b09052022-02-19 19:35:58 -0500544 deps = ["@com_google_protobuf//:timestamp_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800545)
546
547upb_proto_library(
548 name = "test_cpp_upb_proto",
549 deps = ["test_cpp_proto"],
550)
551
552upb_proto_reflection_library(
553 name = "test_cpp_upb_proto_reflection",
554 deps = ["test_cpp_proto"],
555)
556
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500557upb_proto_library(
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700558 name = "struct_upb_proto",
559 deps = ["@com_google_protobuf//:struct_proto"],
560)
561
562upb_proto_library(
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500563 name = "timestamp_upb_proto",
564 deps = ["@com_google_protobuf//:timestamp_proto"],
565)
566
567upb_proto_reflection_library(
568 name = "timestamp_upb_proto_reflection",
569 deps = ["@com_google_protobuf//:timestamp_proto"],
570)
571
Joshua Haberman11b6df02022-02-15 19:55:44 -0800572cc_test(
573 name = "test_cpp",
574 srcs = ["upb/test_cpp.cc"],
575 copts = UPB_DEFAULT_CPPOPTS,
576 deps = [
577 ":test_cpp_upb_proto",
578 ":test_cpp_upb_proto_reflection",
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500579 ":timestamp_upb_proto",
580 ":timestamp_upb_proto_reflection",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800581 "//:json",
582 "//:port",
583 "//:reflection",
584 "//:upb",
585 "@com_google_googletest//:gtest_main",
586 ],
587)
588
589cc_test(
590 name = "test_table",
591 srcs = ["upb/test_table.cc"],
592 copts = UPB_DEFAULT_CPPOPTS,
593 deps = [
594 "//:port",
595 "//:table",
596 "//:upb",
597 "@com_google_googletest//:gtest_main",
598 ],
599)
600
Joshua Haberman11b6df02022-02-15 19:55:44 -0800601upb_proto_library(
602 name = "conformance_proto_upb",
603 testonly = 1,
Joshua Haberman32f45b52022-05-09 22:00:33 -0700604 deps = ["@com_google_protobuf//conformance:conformance_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800605)
606
607upb_proto_reflection_library(
608 name = "conformance_proto_upbdefs",
609 testonly = 1,
Joshua Haberman32f45b52022-05-09 22:00:33 -0700610 deps = ["@com_google_protobuf//conformance:conformance_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800611)
612
613upb_proto_reflection_library(
614 name = "test_messages_proto2_upbdefs",
615 testonly = 1,
616 deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
617)
618
619upb_proto_reflection_library(
620 name = "test_messages_proto3_upbdefs",
621 testonly = 1,
622 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
623)
624
625cc_binary(
626 name = "conformance_upb",
627 testonly = 1,
628 srcs = ["upb/conformance_upb.c"],
629 copts = UPB_DEFAULT_COPTS,
630 data = ["upb/conformance_upb_failures.txt"],
631 deps = [
632 ":conformance_proto_upb",
633 ":conformance_proto_upbdefs",
634 ":test_messages_proto2_upbdefs",
635 ":test_messages_proto3_upbdefs",
636 "//:json",
637 "//:port",
638 "//:reflection",
639 "//:textformat",
640 "//:upb",
641 ],
642)
643
644make_shell_script(
645 name = "gen_test_conformance_upb",
646 out = "test_conformance_upb.sh",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700647 contents = "external/com_google_protobuf/conformance/conformance_test_runner " +
Joshua Haberman11b6df02022-02-15 19:55:44 -0800648 " --enforce_recommended " +
649 " --failure_list ./upb/conformance_upb_failures.txt" +
650 " ./conformance_upb",
651)
652
653sh_test(
654 name = "test_conformance_upb",
655 srcs = ["test_conformance_upb.sh"],
656 data = [
657 "upb/conformance_upb_failures.txt",
658 ":conformance_upb",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700659 "@com_google_protobuf//conformance:conformance_test_runner",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800660 ],
661 deps = ["@bazel_tools//tools/bash/runfiles"],
662)
663
Joshua Haberman50c12982022-03-08 15:52:37 -0800664cc_binary(
665 name = "conformance_upb_dynamic_minitable",
666 testonly = 1,
667 srcs = ["upb/conformance_upb.c"],
668 copts = UPB_DEFAULT_COPTS + [
Joshua Haberman970c6452022-03-08 17:44:06 -0800669 "-DREBUILD_MINITABLES",
Joshua Haberman50c12982022-03-08 15:52:37 -0800670 ],
671 data = ["upb/conformance_upb_failures.txt"],
672 deps = [
673 ":conformance_proto_upb",
674 ":conformance_proto_upbdefs",
675 ":test_messages_proto2_upbdefs",
676 ":test_messages_proto3_upbdefs",
677 "//:json",
678 "//:port",
679 "//:reflection",
680 "//:textformat",
681 "//:upb",
682 ],
683)
684
685make_shell_script(
686 name = "gen_test_conformance_upb_dynamic_minitable",
687 out = "test_conformance_upb_dynamic_minitable.sh",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700688 contents = "external/com_google_protobuf/conformance/conformance_test_runner " +
Joshua Haberman50c12982022-03-08 15:52:37 -0800689 " --enforce_recommended " +
690 " --failure_list ./upb/conformance_upb_failures.txt" +
691 " ./conformance_upb_dynamic_minitable",
692)
693
694sh_test(
695 name = "test_conformance_upb_dynamic_minitable",
696 srcs = ["test_conformance_upb_dynamic_minitable.sh"],
697 data = [
698 "upb/conformance_upb_failures.txt",
699 ":conformance_upb_dynamic_minitable",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700700 "@com_google_protobuf//conformance:conformance_test_runner",
Joshua Haberman50c12982022-03-08 15:52:37 -0800701 ],
702 deps = ["@bazel_tools//tools/bash/runfiles"],
703)
704
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700705# Internal C/C++ libraries #####################################################
706
707cc_library(
708 name = "table",
Joshua Habermancb234e62020-10-17 17:48:32 -0700709 hdrs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700710 "upb/arena.h",
711 "upb/internal/table.h",
712 "upb/status.h",
Joshua Haberman38813932021-04-05 16:00:25 -0700713 "upb/table_internal.h",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700714 "upb/upb.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700715 ],
Joshua Habermandfc07a82022-02-26 21:51:59 -0800716 visibility = [
717 "//python:__pkg__",
718 "//tests:__pkg__",
719 ],
Anna Rde1bc112020-01-07 15:45:19 -0800720 deps = [
721 ":port",
Anna Rde1bc112020-01-07 15:45:19 -0800722 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700723)
724
Joshua Haberman77371f02019-01-23 16:26:13 -0800725# Amalgamation #################################################################
726
Protobuf Teamb8edc712022-03-16 08:24:52 -0700727# begin:github_only
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800728
Joshua Haberman77371f02019-01-23 16:26:13 -0800729upb_amalgamation(
730 name = "gen_amalgamation",
731 outs = [
732 "upb.c",
733 "upb.h",
734 ],
Joshua Haberman77371f02019-01-23 16:26:13 -0800735 libs = [
Protobuf Team823ed182022-04-28 16:07:14 -0700736 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700737 ":descriptor_upb_proto",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700738 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700739 ":fastdecode",
740 ":mini_table",
Anna Rde1bc112020-01-07 15:45:19 -0800741 ":port",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700742 ":reflection",
743 ":upb",
Joshua Haberman77371f02019-01-23 16:26:13 -0800744 ],
745)
746
747cc_library(
748 name = "amalgamation",
749 srcs = ["upb.c"],
750 hdrs = ["upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700751 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700752 deps = ["//third_party/utf8_range"],
Joshua Haberman77371f02019-01-23 16:26:13 -0800753)
754
Joshua Haberman16facab2020-05-08 16:40:24 -0700755upb_amalgamation(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700756 name = "gen_php_amalgamation",
Joshua Haberman16facab2020-05-08 16:40:24 -0700757 outs = [
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700758 "php-upb.c",
759 "php-upb.h",
Joshua Haberman16facab2020-05-08 16:40:24 -0700760 ],
Joshua Haberman16facab2020-05-08 16:40:24 -0700761 libs = [
Protobuf Team823ed182022-04-28 16:07:14 -0700762 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700763 ":descriptor_upb_proto",
764 ":descriptor_upb_proto_reflection",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700765 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700766 ":fastdecode",
Joshua Haberman16facab2020-05-08 16:40:24 -0700767 ":json",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700768 ":mini_table",
769 ":port",
770 ":reflection",
771 ":upb",
Joshua Haberman16facab2020-05-08 16:40:24 -0700772 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700773 prefix = "php-",
Joshua Haberman16facab2020-05-08 16:40:24 -0700774)
775
776cc_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700777 name = "php_amalgamation",
778 srcs = ["php-upb.c"],
779 hdrs = ["php-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700780 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700781 deps = ["//third_party/utf8_range"],
Joshua Haberman16facab2020-05-08 16:40:24 -0700782)
783
Joshua Habermanefefbff2020-08-03 10:12:31 -0700784upb_amalgamation(
785 name = "gen_ruby_amalgamation",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700786 outs = [
787 "ruby-upb.c",
788 "ruby-upb.h",
789 ],
Joshua Habermanefefbff2020-08-03 10:12:31 -0700790 libs = [
Protobuf Team823ed182022-04-28 16:07:14 -0700791 ":collections",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700792 ":descriptor_upb_proto",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700793 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700794 ":fastdecode",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700795 ":json",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700796 ":mini_table",
797 ":port",
798 ":reflection",
799 ":upb",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700800 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700801 prefix = "ruby-",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700802)
803
804cc_library(
805 name = "ruby_amalgamation",
806 srcs = ["ruby-upb.c"],
807 hdrs = ["ruby-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700808 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700809 deps = ["//third_party/utf8_range"],
Joshua Habermanefefbff2020-08-03 10:12:31 -0700810)
811
Joshua Habermane3f41de2020-10-17 13:15:58 -0700812exports_files(
813 [
Joshua Habermanbfc86d32019-12-04 16:56:40 -0800814 "third_party/lunit/console.lua",
815 "third_party/lunit/lunit.lua",
816 ],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800817 visibility = ["//upb/bindings/lua:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700818)
819
Joshua Haberman985145c2019-04-24 17:36:17 +0000820filegroup(
821 name = "cmake_files",
822 srcs = glob([
Joshua Haberman985145c2019-04-24 17:36:17 +0000823 "upbc/**/*",
824 "upb/**/*",
Joshua Haberman4f901b62020-10-14 16:32:43 -0700825 "third_party/**/*",
Joshua Haberman9a663562019-05-13 16:13:39 -0700826 ]),
Joshua Habermane3f41de2020-10-17 13:15:58 -0700827 visibility = ["//cmake:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700828)
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800829
Protobuf Teamb8edc712022-03-16 08:24:52 -0700830# end:github_only
Joshua Haberman4ffeaa62022-06-01 12:25:11 -0700831
832# begin:google_only
833#
834# py_binary(
835# name = "update_check_runs",
836# srcs = ["update_check_runs.py"],
837# main = "update_check_runs.py",
838# deps = [
839# "//third_party/py/absl:app",
840# ],
841# )
842#
843# end:google_only