blob: 1dd45e632f2d9ecf4f8a041ff9f064af328b5439 [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 Bot7b05f252022-06-22 09:18:12 -0700105 "upb/alloc.c",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700106 "upb/arena.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700107 "upb/decode.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700108 "upb/encode.c",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700109 "upb/internal/table.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700110 "upb/msg.c",
Joshua Haberman38813932021-04-05 16:00:25 -0700111 "upb/msg_internal.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700112 "upb/status.c",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700113 "upb/upb.c",
114 ],
115 hdrs = [
Protobuf Team Bot7b05f252022-06-22 09:18:12 -0700116 "upb/alloc.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700117 "upb/arena.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700118 "upb/decode.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700119 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700120 "upb/extension_registry.h",
Joshua Haberman1674f282021-04-04 18:43:24 -0700121 "upb/msg.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700122 "upb/status.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700123 "upb/string_view.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 Bot8d0d13f2022-06-23 13:43:40 -0700130 ":arena_internal",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700131 ":decode_internal",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700132 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700133 ":extension_registry",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700134 ":fastdecode",
135 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700136 ":table_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700137 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700138)
139
140cc_library(
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700141 name = "extension_registry",
142 srcs = [
143 "upb/extension_registry.c",
144 "upb/msg.h",
145 "upb/msg_internal.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700146 "upb/string_view.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700147 "upb/upb.h",
148 ],
149 hdrs = [
150 "upb/extension_registry.h",
151 ],
152 copts = UPB_DEFAULT_COPTS,
153 visibility = ["//visibility:public"],
154 deps = [
155 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700156 ":table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700157 ],
158)
159
160cc_library(
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700161 name = "mini_descriptor",
162 srcs = [
163 "upb/mini_descriptor.c",
164 ],
165 hdrs = [
166 "upb/mini_descriptor.h",
167 ],
168 copts = UPB_DEFAULT_COPTS,
169 visibility = ["//visibility:public"],
170 deps = [
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700171 ":mini_table",
172 ":port",
173 ":reflection",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700174 ":table_internal",
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700175 ":upb",
176 ],
177)
178
179cc_library(
Joshua Haberman970c6452022-03-08 17:44:06 -0800180 name = "mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700181 hdrs = [
182 "upb/msg_internal.h",
183 ],
Joshua Haberman970c6452022-03-08 17:44:06 -0800184 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700185 ":extension_registry",
Joshua Haberman970c6452022-03-08 17:44:06 -0800186 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700187 ":table_internal",
Joshua Haberman970c6452022-03-08 17:44:06 -0800188 ":upb",
189 ],
190)
191
192cc_library(
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800193 name = "mini_table",
Protobuf Teame5468b42022-04-19 14:09:14 -0700194 srcs = [
195 "upb/mini_table.c",
196 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800197 hdrs = [
198 "upb/mini_table.h",
199 "upb/mini_table.hpp",
200 ],
201 copts = UPB_DEFAULT_COPTS,
202 visibility = ["//visibility:public"],
Joshua Haberman970c6452022-03-08 17:44:06 -0800203 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700204 ":extension_registry",
Joshua Haberman970c6452022-03-08 17:44:06 -0800205 ":mini_table_internal",
206 ":port",
207 ":upb",
208 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800209)
210
Protobuf Teame5468b42022-04-19 14:09:14 -0700211cc_library(
212 name = "mini_table_accessors",
213 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700214 "upb/internal/mini_table_accessors.h",
Protobuf Teame5468b42022-04-19 14:09:14 -0700215 "upb/mini_table_accessors.c",
Protobuf Teame5468b42022-04-19 14:09:14 -0700216 ],
217 hdrs = [
218 "upb/mini_table_accessors.h",
219 ],
220 copts = UPB_DEFAULT_COPTS,
Joshua Haberman6df55172022-05-24 11:41:56 -0700221 visibility = ["//visibility:public"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700222 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700223 ":collections",
Protobuf Teame5468b42022-04-19 14:09:14 -0700224 ":mini_table",
225 ":mini_table_internal",
226 ":port",
227 ":upb",
228 ],
229)
230
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800231cc_test(
232 name = "mini_table_test",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700233 srcs = [
234 "upb/internal/table.h",
235 "upb/mini_table_test.cc",
236 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800237 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700238 ":extension_registry",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800239 ":mini_table",
Joshua Haberman970c6452022-03-08 17:44:06 -0800240 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700241 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800242 ":upb",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800243 "@com_google_absl//absl/container:flat_hash_set",
Joshua Haberman970c6452022-03-08 17:44:06 -0800244 "@com_google_googletest//:gtest_main",
Joshua Haberman8d148f02022-03-13 18:45:50 -0700245 "@com_google_protobuf//:protobuf",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800246 ],
247)
248
Protobuf Teame5468b42022-04-19 14:09:14 -0700249cc_test(
250 name = "mini_table_accessors_test",
251 srcs = ["upb/mini_table_accessors_test.cc"],
252 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700253 ":collections",
Protobuf Teame5468b42022-04-19 14:09:14 -0700254 ":mini_table",
255 ":mini_table_accessors",
256 ":mini_table_internal",
257 ":test_messages_proto2_proto_upb",
258 ":test_messages_proto3_proto_upb",
Protobuf Team459059e2022-05-09 14:13:02 -0700259 ":test_upb_proto",
Protobuf Teame5468b42022-04-19 14:09:14 -0700260 ":upb",
261 "@com_google_absl//absl/container:flat_hash_set",
262 "@com_google_googletest//:gtest_main",
263 "@com_google_protobuf//:protobuf",
264 ],
265)
266
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800267cc_library(
Joshua Habermancb234e62020-10-17 17:48:32 -0700268 name = "fastdecode",
269 srcs = [
Joshua Haberman3d437bb2021-10-13 09:53:36 -0700270 "upb/decode.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700271 "upb/decode_fast.c",
272 "upb/decode_fast.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700273 "upb/msg.h",
Joshua Haberman38813932021-04-05 16:00:25 -0700274 "upb/msg_internal.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700275 ],
Joshua Habermane86541a2020-10-28 17:53:09 -0700276 copts = UPB_DEFAULT_COPTS,
Joshua Habermanefd576b2020-10-26 21:37:17 -0700277 deps = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700278 ":arena_internal",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700279 ":decode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700280 ":extension_registry",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700281 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700282 ":table_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700283 ],
Joshua Habermanba29af32019-06-01 19:27:49 -0700284)
285
286# Common support routines used by generated code. This library has no
287# implementation, but depends on :upb and exposes a few more hdrs.
288#
289# This is public only because we have no way of visibility-limiting it to
290# upb_proto_library() only. This interface is not stable and by using it you
291# give up any backward compatibility guarantees.
292cc_library(
293 name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
Joshua Habermanba29af32019-06-01 19:27:49 -0700294 hdrs = [
Joshua Haberman8c530f92022-02-22 14:50:55 -0800295 "upb/decode.h",
Joshua Habermanaec762e2020-10-11 23:14:50 -0700296 "upb/decode_fast.h",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800297 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700298 "upb/extension_registry.h",
Joshua Habermanba29af32019-06-01 19:27:49 -0700299 "upb/msg.h",
Joshua Haberman42bdfcb2021-04-06 09:25:28 -0700300 "upb/msg_internal.h",
Anna Ra27429f2020-01-09 14:50:03 -0800301 "upb/port_def.inc",
302 "upb/port_undef.inc",
Joshua Habermanba29af32019-06-01 19:27:49 -0700303 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700304 copts = UPB_DEFAULT_COPTS,
Vishal Powar7031f772018-11-28 15:32:16 -0800305 visibility = ["//visibility:public"],
Anna Rde1bc112020-01-07 15:45:19 -0800306 deps = [
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700307 ":table_internal",
Anna Rde1bc112020-01-07 15:45:19 -0800308 ":upb",
309 ],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700310)
311
Joshua Haberman8c530f92022-02-22 14:50:55 -0800312cc_library(
313 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
314 hdrs = [
315 "upb/def.h",
316 "upb/port_def.inc",
317 "upb/port_undef.inc",
318 ],
319 copts = UPB_DEFAULT_COPTS,
320 visibility = ["//visibility:public"],
321 deps = [
322 ":descriptor_upb_proto",
323 ":reflection",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700324 ":table_internal",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800325 ],
326)
327
Josh Habermancd9e1e62019-04-17 15:23:00 -0700328upb_proto_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700329 name = "descriptor_upb_proto",
330 visibility = ["//visibility:public"],
331 deps = ["@com_google_protobuf//:descriptor_proto"],
332)
333
334upb_proto_reflection_library(
335 name = "descriptor_upb_proto_reflection",
Joshua Habermanc58541e2019-05-15 09:49:29 -0700336 visibility = ["//visibility:public"],
Google-Autofuzz8f196672019-06-25 20:14:14 -0400337 deps = ["@com_google_protobuf//:descriptor_proto"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700338)
339
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700340cc_library(
Protobuf Team823ed182022-04-28 16:07:14 -0700341 name = "collections",
342 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700343 "upb/array.c",
344 "upb/map.c",
Protobuf Team Bot79759452022-06-23 16:51:15 -0700345 "upb/msg_internal.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700346 ],
347 hdrs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700348 "upb/array.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700349 "upb/collections.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700350 "upb/map.h",
351 "upb/message_value.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700352 ],
353 copts = UPB_DEFAULT_COPTS,
354 visibility = ["//visibility:public"],
355 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700356 ":mini_table",
357 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700358 ":table_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700359 ":upb",
360 ],
361)
362
363cc_library(
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700364 name = "reflection",
365 srcs = [
366 "upb/def.c",
Joshua Haberman58010a32020-02-18 16:53:21 -0800367 "upb/msg.h",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800368 "upb/reflection.c",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700369 ],
370 hdrs = [
371 "upb/def.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700372 "upb/def.hpp",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800373 "upb/reflection.h",
Joshua Haberman5e550e82021-01-09 15:45:44 -0800374 "upb/reflection.hpp",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700375 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700376 copts = UPB_DEFAULT_COPTS,
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700377 visibility = ["//visibility:public"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700378 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700379 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700380 ":descriptor_upb_proto",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700381 ":mini_table",
Anna Rfc494112020-01-09 14:16:25 -0800382 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700383 ":table_internal",
Joshua Haberman9a663562019-05-13 16:13:39 -0700384 ":upb",
Josh Habermancd9e1e62019-04-17 15:23:00 -0700385 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700386)
387
Joshua Habermance1a3992020-02-04 06:22:09 -0800388cc_library(
389 name = "textformat",
390 srcs = [
Joshua Haberman02c89a82020-02-10 14:56:27 -0800391 "upb/text_encode.c",
Joshua Habermance1a3992020-02-04 06:22:09 -0800392 ],
393 hdrs = [
Joshua Haberman02c89a82020-02-10 14:56:27 -0800394 "upb/text_encode.h",
Joshua Habermance1a3992020-02-04 06:22:09 -0800395 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700396 copts = UPB_DEFAULT_COPTS,
Joshua Habermance1a3992020-02-04 06:22:09 -0800397 visibility = ["//visibility:public"],
398 deps = [
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700399 ":encode_internal",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800400 ":port",
Joshua Habermance1a3992020-02-04 06:22:09 -0800401 ":reflection",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700402 ":table_internal",
Joshua Habermance1a3992020-02-04 06:22:09 -0800403 ],
404)
405
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800406cc_library(
407 name = "json",
408 srcs = [
Joshua Habermand49c1db2020-02-23 19:49:39 -0800409 "upb/json_decode.c",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800410 "upb/json_encode.c",
411 ],
412 hdrs = [
Joshua Habermand49c1db2020-02-23 19:49:39 -0800413 "upb/json_decode.h",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800414 "upb/json_encode.h",
415 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700416 copts = UPB_DEFAULT_COPTS,
Lidi Zhengf72c26c2020-12-10 16:23:08 -0800417 visibility = ["//visibility:public"],
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800418 deps = [
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700419 ":encode_internal",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800420 ":port",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800421 ":reflection",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800422 ":upb",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800423 ],
424)
425
Joshua Haberman11b6df02022-02-15 19:55:44 -0800426# Tests ########################################################################
427
428cc_test(
429 name = "test_generated_code",
430 srcs = ["upb/test_generated_code.cc"],
431 deps = [
432 ":empty_upbdefs_proto",
Joshua Haberman1cf82142022-05-12 13:57:50 -0700433 ":port",
Protobuf Teambef53682022-04-04 11:18:39 -0700434 ":test_messages_proto2_proto_upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800435 ":test_messages_proto3_proto_upb",
436 ":test_upb_proto",
Matt Kulukundisedd1dd32022-02-20 17:44:27 -0500437 ":upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800438 "@com_google_googletest//:gtest_main",
439 ],
440)
441
442proto_library(
443 name = "test_proto",
444 testonly = 1,
445 srcs = ["upb/test.proto"],
446)
447
448upb_proto_library(
449 name = "test_upb_proto",
450 testonly = 1,
451 deps = [":test_proto"],
452)
453
454proto_library(
455 name = "empty_proto",
456 srcs = ["upb/empty.proto"],
457)
458
459upb_proto_reflection_library(
460 name = "empty_upbdefs_proto",
461 testonly = 1,
462 deps = [":empty_proto"],
463)
464
465upb_proto_library(
Protobuf Teambef53682022-04-04 11:18:39 -0700466 name = "test_messages_proto2_proto_upb",
467 testonly = 1,
468 deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
469)
470
471upb_proto_library(
Joshua Haberman11b6df02022-02-15 19:55:44 -0800472 name = "test_messages_proto3_proto_upb",
473 testonly = 1,
474 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
475)
Matt Kulukundis61b09052022-02-19 19:35:58 -0500476
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700477proto_library(
478 name = "json_test_proto",
479 testonly = 1,
480 srcs = ["upb/json_test.proto"],
481 deps = ["@com_google_protobuf//:struct_proto"],
482)
483
484upb_proto_library(
485 name = "json_test_upb_proto",
486 testonly = 1,
487 deps = [":json_test_proto"],
488)
489
490upb_proto_reflection_library(
491 name = "json_test_upb_proto_reflection",
492 testonly = 1,
493 deps = [":json_test_proto"],
494)
495
496cc_test(
497 name = "json_test",
498 srcs = ["upb/json_test.cc"],
499 deps = [
500 ":json",
501 ":json_test_upb_proto",
502 ":json_test_upb_proto_reflection",
503 ":reflection",
504 ":struct_upb_proto",
505 ":upb",
506 "@com_google_googletest//:gtest_main",
507 ],
508)
509
Joshua Habermance012b72021-10-01 16:34:42 -0700510cc_test(
511 name = "msg_test",
512 srcs = ["upb/msg_test.cc"],
513 deps = [
Joshua Habermance012b72021-10-01 16:34:42 -0700514 ":json",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500515 ":msg_test_upb_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500516 ":msg_test_upb_proto_reflection",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500517 ":reflection",
Matt Kulukundis42c121e2022-02-21 23:58:17 -0500518 ":test_messages_proto3_proto_upb",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500519 ":upb",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500520 "@com_google_googletest//:gtest_main",
Joshua Habermance012b72021-10-01 16:34:42 -0700521 ],
522)
523
524proto_library(
525 name = "msg_test_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500526 testonly = 1,
Joshua Habermance012b72021-10-01 16:34:42 -0700527 srcs = ["upb/msg_test.proto"],
528 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
529)
530
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500531upb_proto_library(
532 name = "msg_test_upb_proto",
533 testonly = 1,
534 deps = [":msg_test_proto"],
535)
536
Joshua Habermance012b72021-10-01 16:34:42 -0700537upb_proto_reflection_library(
538 name = "msg_test_upb_proto_reflection",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500539 testonly = 1,
Joshua Habermance012b72021-10-01 16:34:42 -0700540 deps = [":msg_test_proto"],
541)
542
Joshua Haberman11b6df02022-02-15 19:55:44 -0800543proto_library(
544 name = "test_cpp_proto",
545 srcs = ["upb/test_cpp.proto"],
Matt Kulukundis61b09052022-02-19 19:35:58 -0500546 deps = ["@com_google_protobuf//:timestamp_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800547)
548
549upb_proto_library(
550 name = "test_cpp_upb_proto",
551 deps = ["test_cpp_proto"],
552)
553
554upb_proto_reflection_library(
555 name = "test_cpp_upb_proto_reflection",
556 deps = ["test_cpp_proto"],
557)
558
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500559upb_proto_library(
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700560 name = "struct_upb_proto",
561 deps = ["@com_google_protobuf//:struct_proto"],
562)
563
564upb_proto_library(
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500565 name = "timestamp_upb_proto",
566 deps = ["@com_google_protobuf//:timestamp_proto"],
567)
568
569upb_proto_reflection_library(
570 name = "timestamp_upb_proto_reflection",
571 deps = ["@com_google_protobuf//:timestamp_proto"],
572)
573
Joshua Haberman11b6df02022-02-15 19:55:44 -0800574cc_test(
575 name = "test_cpp",
576 srcs = ["upb/test_cpp.cc"],
577 copts = UPB_DEFAULT_CPPOPTS,
578 deps = [
579 ":test_cpp_upb_proto",
580 ":test_cpp_upb_proto_reflection",
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500581 ":timestamp_upb_proto",
582 ":timestamp_upb_proto_reflection",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800583 "//:json",
584 "//:port",
585 "//:reflection",
586 "//:upb",
587 "@com_google_googletest//:gtest_main",
588 ],
589)
590
591cc_test(
592 name = "test_table",
593 srcs = ["upb/test_table.cc"],
594 copts = UPB_DEFAULT_CPPOPTS,
595 deps = [
596 "//:port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700597 "//:table_internal",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800598 "//:upb",
599 "@com_google_googletest//:gtest_main",
600 ],
601)
602
Joshua Haberman11b6df02022-02-15 19:55:44 -0800603upb_proto_library(
604 name = "conformance_proto_upb",
605 testonly = 1,
Joshua Haberman32f45b52022-05-09 22:00:33 -0700606 deps = ["@com_google_protobuf//conformance:conformance_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800607)
608
609upb_proto_reflection_library(
610 name = "conformance_proto_upbdefs",
611 testonly = 1,
Joshua Haberman32f45b52022-05-09 22:00:33 -0700612 deps = ["@com_google_protobuf//conformance:conformance_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800613)
614
615upb_proto_reflection_library(
616 name = "test_messages_proto2_upbdefs",
617 testonly = 1,
618 deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
619)
620
621upb_proto_reflection_library(
622 name = "test_messages_proto3_upbdefs",
623 testonly = 1,
624 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
625)
626
627cc_binary(
628 name = "conformance_upb",
629 testonly = 1,
630 srcs = ["upb/conformance_upb.c"],
631 copts = UPB_DEFAULT_COPTS,
632 data = ["upb/conformance_upb_failures.txt"],
633 deps = [
634 ":conformance_proto_upb",
635 ":conformance_proto_upbdefs",
636 ":test_messages_proto2_upbdefs",
637 ":test_messages_proto3_upbdefs",
638 "//:json",
639 "//:port",
640 "//:reflection",
641 "//:textformat",
642 "//:upb",
643 ],
644)
645
646make_shell_script(
647 name = "gen_test_conformance_upb",
648 out = "test_conformance_upb.sh",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700649 contents = "external/com_google_protobuf/conformance/conformance_test_runner " +
Joshua Haberman11b6df02022-02-15 19:55:44 -0800650 " --enforce_recommended " +
651 " --failure_list ./upb/conformance_upb_failures.txt" +
652 " ./conformance_upb",
653)
654
655sh_test(
656 name = "test_conformance_upb",
657 srcs = ["test_conformance_upb.sh"],
658 data = [
659 "upb/conformance_upb_failures.txt",
660 ":conformance_upb",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700661 "@com_google_protobuf//conformance:conformance_test_runner",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800662 ],
663 deps = ["@bazel_tools//tools/bash/runfiles"],
664)
665
Joshua Haberman50c12982022-03-08 15:52:37 -0800666cc_binary(
667 name = "conformance_upb_dynamic_minitable",
668 testonly = 1,
669 srcs = ["upb/conformance_upb.c"],
670 copts = UPB_DEFAULT_COPTS + [
Joshua Haberman970c6452022-03-08 17:44:06 -0800671 "-DREBUILD_MINITABLES",
Joshua Haberman50c12982022-03-08 15:52:37 -0800672 ],
673 data = ["upb/conformance_upb_failures.txt"],
674 deps = [
675 ":conformance_proto_upb",
676 ":conformance_proto_upbdefs",
677 ":test_messages_proto2_upbdefs",
678 ":test_messages_proto3_upbdefs",
679 "//:json",
680 "//:port",
681 "//:reflection",
682 "//:textformat",
683 "//:upb",
684 ],
685)
686
687make_shell_script(
688 name = "gen_test_conformance_upb_dynamic_minitable",
689 out = "test_conformance_upb_dynamic_minitable.sh",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700690 contents = "external/com_google_protobuf/conformance/conformance_test_runner " +
Joshua Haberman50c12982022-03-08 15:52:37 -0800691 " --enforce_recommended " +
692 " --failure_list ./upb/conformance_upb_failures.txt" +
693 " ./conformance_upb_dynamic_minitable",
694)
695
696sh_test(
697 name = "test_conformance_upb_dynamic_minitable",
698 srcs = ["test_conformance_upb_dynamic_minitable.sh"],
699 data = [
700 "upb/conformance_upb_failures.txt",
701 ":conformance_upb_dynamic_minitable",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700702 "@com_google_protobuf//conformance:conformance_test_runner",
Joshua Haberman50c12982022-03-08 15:52:37 -0800703 ],
704 deps = ["@bazel_tools//tools/bash/runfiles"],
705)
706
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700707# Internal C/C++ libraries #####################################################
708
709cc_library(
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700710 name = "arena_internal",
711 srcs = [
712 "upb/alloc.h",
713 "upb/arena.h",
714 ],
715 hdrs = ["upb/internal/arena.h"],
716 copts = UPB_DEFAULT_COPTS,
717 visibility = ["//:__subpackages__"],
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700718 deps = [":port"],
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700719)
720
721cc_library(
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700722 name = "decode_internal",
723 srcs = [
724 "upb/decode.h",
725 "upb/extension_registry.h",
726 "upb/msg.h",
727 "upb/msg_internal.h",
728 ],
729 hdrs = ["upb/internal/decode.h"],
730 copts = UPB_DEFAULT_COPTS,
731 visibility = ["//:__subpackages__"],
732 deps = [
733 ":arena_internal",
734 ":port",
735 ":table_internal",
736 "//third_party/utf8_range",
737 ],
738)
739
740cc_library(
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700741 name = "encode_internal",
742 hdrs = ["upb/internal/encode.h"],
743 copts = UPB_DEFAULT_COPTS,
744 visibility = ["//:__subpackages__"],
745 deps = [":port"],
746)
747
748cc_library(
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700749 name = "table_internal",
750 srcs = [
751 "upb/internal/table.c",
752 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700753 hdrs = [
Protobuf Team Bot7b05f252022-06-22 09:18:12 -0700754 "upb/alloc.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700755 "upb/arena.h",
756 "upb/internal/table.h",
757 "upb/status.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700758 "upb/string_view.h",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700759 "upb/upb.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700760 ],
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700761 copts = UPB_DEFAULT_COPTS,
762 visibility = ["//:__subpackages__"],
763 deps = [":port"],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700764)
765
Joshua Haberman77371f02019-01-23 16:26:13 -0800766# Amalgamation #################################################################
767
Protobuf Teamb8edc712022-03-16 08:24:52 -0700768# begin:github_only
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800769
Joshua Haberman77371f02019-01-23 16:26:13 -0800770upb_amalgamation(
771 name = "gen_amalgamation",
772 outs = [
773 "upb.c",
774 "upb.h",
775 ],
Joshua Haberman77371f02019-01-23 16:26:13 -0800776 libs = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700777 ":arena_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700778 ":collections",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700779 ":decode_internal",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700780 ":descriptor_upb_proto",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700781 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700782 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700783 ":fastdecode",
784 ":mini_table",
Anna Rde1bc112020-01-07 15:45:19 -0800785 ":port",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700786 ":reflection",
787 ":upb",
Joshua Haberman77371f02019-01-23 16:26:13 -0800788 ],
789)
790
791cc_library(
792 name = "amalgamation",
793 srcs = ["upb.c"],
794 hdrs = ["upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700795 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700796 deps = ["//third_party/utf8_range"],
Joshua Haberman77371f02019-01-23 16:26:13 -0800797)
798
Joshua Haberman16facab2020-05-08 16:40:24 -0700799upb_amalgamation(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700800 name = "gen_php_amalgamation",
Joshua Haberman16facab2020-05-08 16:40:24 -0700801 outs = [
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700802 "php-upb.c",
803 "php-upb.h",
Joshua Haberman16facab2020-05-08 16:40:24 -0700804 ],
Joshua Haberman16facab2020-05-08 16:40:24 -0700805 libs = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700806 ":arena_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700807 ":collections",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700808 ":decode_internal",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700809 ":descriptor_upb_proto",
810 ":descriptor_upb_proto_reflection",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700811 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700812 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700813 ":fastdecode",
Joshua Haberman16facab2020-05-08 16:40:24 -0700814 ":json",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700815 ":mini_table",
816 ":port",
817 ":reflection",
818 ":upb",
Joshua Haberman16facab2020-05-08 16:40:24 -0700819 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700820 prefix = "php-",
Joshua Haberman16facab2020-05-08 16:40:24 -0700821)
822
823cc_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700824 name = "php_amalgamation",
825 srcs = ["php-upb.c"],
826 hdrs = ["php-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700827 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700828 deps = ["//third_party/utf8_range"],
Joshua Haberman16facab2020-05-08 16:40:24 -0700829)
830
Joshua Habermanefefbff2020-08-03 10:12:31 -0700831upb_amalgamation(
832 name = "gen_ruby_amalgamation",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700833 outs = [
834 "ruby-upb.c",
835 "ruby-upb.h",
836 ],
Joshua Habermanefefbff2020-08-03 10:12:31 -0700837 libs = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700838 ":arena_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700839 ":collections",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700840 ":decode_internal",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700841 ":descriptor_upb_proto",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700842 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700843 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700844 ":fastdecode",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700845 ":json",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700846 ":mini_table",
847 ":port",
848 ":reflection",
849 ":upb",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700850 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700851 prefix = "ruby-",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700852)
853
854cc_library(
855 name = "ruby_amalgamation",
856 srcs = ["ruby-upb.c"],
857 hdrs = ["ruby-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700858 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700859 deps = ["//third_party/utf8_range"],
Joshua Habermanefefbff2020-08-03 10:12:31 -0700860)
861
Joshua Habermane3f41de2020-10-17 13:15:58 -0700862exports_files(
863 [
Joshua Habermanbfc86d32019-12-04 16:56:40 -0800864 "third_party/lunit/console.lua",
865 "third_party/lunit/lunit.lua",
866 ],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800867 visibility = ["//upb/bindings/lua:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700868)
869
Joshua Haberman985145c2019-04-24 17:36:17 +0000870filegroup(
871 name = "cmake_files",
872 srcs = glob([
Joshua Haberman985145c2019-04-24 17:36:17 +0000873 "upbc/**/*",
874 "upb/**/*",
Joshua Haberman4f901b62020-10-14 16:32:43 -0700875 "third_party/**/*",
Joshua Haberman9a663562019-05-13 16:13:39 -0700876 ]),
Joshua Habermane3f41de2020-10-17 13:15:58 -0700877 visibility = ["//cmake:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700878)
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800879
Protobuf Teamb8edc712022-03-16 08:24:52 -0700880# end:github_only
Joshua Haberman4ffeaa62022-06-01 12:25:11 -0700881
882# begin:google_only
883#
884# py_binary(
885# name = "update_check_runs",
886# srcs = ["update_check_runs.py"],
887# main = "update_check_runs.py",
888# deps = [
889# "//third_party/py/absl:app",
890# ],
891# )
892#
893# end:google_only