blob: f396377bfa3fef3c7eb40845c88e455a7a377f40 [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/decode.h",
110 "upb/internal/table.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/upb.c",
115 ],
116 hdrs = [
Protobuf Team Bot7b05f252022-06-22 09:18:12 -0700117 "upb/alloc.h",
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",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700124 "upb/string_view.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700125 "upb/upb.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700126 "upb/upb.hpp",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700127 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700128 copts = UPB_DEFAULT_COPTS,
Joshua Habermanba29af32019-06-01 19:27:49 -0700129 visibility = ["//visibility:public"],
Joshua Habermanefd576b2020-10-26 21:37:17 -0700130 deps = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700131 ":arena_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 Haberman4307f5d2021-10-11 23:02:32 -0700137 "//third_party/utf8_range",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700138 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700139)
140
141cc_library(
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700142 name = "extension_registry",
143 srcs = [
144 "upb/extension_registry.c",
145 "upb/msg.h",
146 "upb/msg_internal.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700147 "upb/string_view.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700148 "upb/upb.h",
149 ],
150 hdrs = [
151 "upb/extension_registry.h",
152 ],
153 copts = UPB_DEFAULT_COPTS,
154 visibility = ["//visibility:public"],
155 deps = [
156 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700157 ":table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700158 ],
159)
160
161cc_library(
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700162 name = "mini_descriptor",
163 srcs = [
164 "upb/mini_descriptor.c",
165 ],
166 hdrs = [
167 "upb/mini_descriptor.h",
168 ],
169 copts = UPB_DEFAULT_COPTS,
170 visibility = ["//visibility:public"],
171 deps = [
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700172 ":mini_table",
173 ":port",
174 ":reflection",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700175 ":table_internal",
Protobuf Team Botbb38fc92022-06-10 14:32:58 -0700176 ":upb",
177 ],
178)
179
180cc_library(
Joshua Haberman970c6452022-03-08 17:44:06 -0800181 name = "mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700182 hdrs = [
183 "upb/msg_internal.h",
184 ],
Joshua Haberman970c6452022-03-08 17:44:06 -0800185 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700186 ":extension_registry",
Joshua Haberman970c6452022-03-08 17:44:06 -0800187 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700188 ":table_internal",
Joshua Haberman970c6452022-03-08 17:44:06 -0800189 ":upb",
190 ],
191)
192
193cc_library(
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800194 name = "mini_table",
Protobuf Teame5468b42022-04-19 14:09:14 -0700195 srcs = [
196 "upb/mini_table.c",
197 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800198 hdrs = [
199 "upb/mini_table.h",
200 "upb/mini_table.hpp",
201 ],
202 copts = UPB_DEFAULT_COPTS,
203 visibility = ["//visibility:public"],
Joshua Haberman970c6452022-03-08 17:44:06 -0800204 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700205 ":extension_registry",
Joshua Haberman970c6452022-03-08 17:44:06 -0800206 ":mini_table_internal",
207 ":port",
208 ":upb",
209 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800210)
211
Protobuf Teame5468b42022-04-19 14:09:14 -0700212cc_library(
213 name = "mini_table_accessors",
214 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700215 "upb/internal/mini_table_accessors.h",
Protobuf Teame5468b42022-04-19 14:09:14 -0700216 "upb/mini_table_accessors.c",
Protobuf Teame5468b42022-04-19 14:09:14 -0700217 ],
218 hdrs = [
219 "upb/mini_table_accessors.h",
220 ],
221 copts = UPB_DEFAULT_COPTS,
Joshua Haberman6df55172022-05-24 11:41:56 -0700222 visibility = ["//visibility:public"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700223 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700224 ":collections",
Protobuf Teame5468b42022-04-19 14:09:14 -0700225 ":mini_table",
226 ":mini_table_internal",
227 ":port",
228 ":upb",
229 ],
230)
231
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800232cc_test(
233 name = "mini_table_test",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700234 srcs = [
235 "upb/internal/table.h",
236 "upb/mini_table_test.cc",
237 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800238 deps = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700239 ":extension_registry",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800240 ":mini_table",
Joshua Haberman970c6452022-03-08 17:44:06 -0800241 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700242 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800243 ":upb",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800244 "@com_google_absl//absl/container:flat_hash_set",
Joshua Haberman970c6452022-03-08 17:44:06 -0800245 "@com_google_googletest//:gtest_main",
Joshua Haberman8d148f02022-03-13 18:45:50 -0700246 "@com_google_protobuf//:protobuf",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800247 ],
248)
249
Protobuf Teame5468b42022-04-19 14:09:14 -0700250cc_test(
251 name = "mini_table_accessors_test",
252 srcs = ["upb/mini_table_accessors_test.cc"],
253 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700254 ":collections",
Protobuf Teame5468b42022-04-19 14:09:14 -0700255 ":mini_table",
256 ":mini_table_accessors",
257 ":mini_table_internal",
258 ":test_messages_proto2_proto_upb",
259 ":test_messages_proto3_proto_upb",
Protobuf Team459059e2022-05-09 14:13:02 -0700260 ":test_upb_proto",
Protobuf Teame5468b42022-04-19 14:09:14 -0700261 ":upb",
262 "@com_google_absl//absl/container:flat_hash_set",
263 "@com_google_googletest//:gtest_main",
264 "@com_google_protobuf//:protobuf",
265 ],
266)
267
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800268cc_library(
Joshua Habermancb234e62020-10-17 17:48:32 -0700269 name = "fastdecode",
270 srcs = [
Joshua Haberman3d437bb2021-10-13 09:53:36 -0700271 "upb/decode.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700272 "upb/decode_fast.c",
273 "upb/decode_fast.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700274 "upb/internal/decode.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700275 "upb/msg.h",
Joshua Haberman38813932021-04-05 16:00:25 -0700276 "upb/msg_internal.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700277 ],
Joshua Habermane86541a2020-10-28 17:53:09 -0700278 copts = UPB_DEFAULT_COPTS,
Joshua Habermanefd576b2020-10-26 21:37:17 -0700279 deps = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700280 ":arena_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700281 ":extension_registry",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700282 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700283 ":table_internal",
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700284 "//third_party/utf8_range",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700285 ],
Joshua Habermanba29af32019-06-01 19:27:49 -0700286)
287
288# Common support routines used by generated code. This library has no
289# implementation, but depends on :upb and exposes a few more hdrs.
290#
291# This is public only because we have no way of visibility-limiting it to
292# upb_proto_library() only. This interface is not stable and by using it you
293# give up any backward compatibility guarantees.
294cc_library(
295 name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
Joshua Habermanba29af32019-06-01 19:27:49 -0700296 hdrs = [
Joshua Haberman8c530f92022-02-22 14:50:55 -0800297 "upb/decode.h",
Joshua Habermanaec762e2020-10-11 23:14:50 -0700298 "upb/decode_fast.h",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800299 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700300 "upb/extension_registry.h",
Joshua Habermanba29af32019-06-01 19:27:49 -0700301 "upb/msg.h",
Joshua Haberman42bdfcb2021-04-06 09:25:28 -0700302 "upb/msg_internal.h",
Anna Ra27429f2020-01-09 14:50:03 -0800303 "upb/port_def.inc",
304 "upb/port_undef.inc",
Joshua Habermanba29af32019-06-01 19:27:49 -0700305 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700306 copts = UPB_DEFAULT_COPTS,
Vishal Powar7031f772018-11-28 15:32:16 -0800307 visibility = ["//visibility:public"],
Anna Rde1bc112020-01-07 15:45:19 -0800308 deps = [
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700309 ":table_internal",
Anna Rde1bc112020-01-07 15:45:19 -0800310 ":upb",
311 ],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700312)
313
Joshua Haberman8c530f92022-02-22 14:50:55 -0800314cc_library(
315 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
316 hdrs = [
317 "upb/def.h",
318 "upb/port_def.inc",
319 "upb/port_undef.inc",
320 ],
321 copts = UPB_DEFAULT_COPTS,
322 visibility = ["//visibility:public"],
323 deps = [
324 ":descriptor_upb_proto",
325 ":reflection",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700326 ":table_internal",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800327 ],
328)
329
Josh Habermancd9e1e62019-04-17 15:23:00 -0700330upb_proto_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700331 name = "descriptor_upb_proto",
332 visibility = ["//visibility:public"],
333 deps = ["@com_google_protobuf//:descriptor_proto"],
334)
335
336upb_proto_reflection_library(
337 name = "descriptor_upb_proto_reflection",
Joshua Habermanc58541e2019-05-15 09:49:29 -0700338 visibility = ["//visibility:public"],
Google-Autofuzz8f196672019-06-25 20:14:14 -0400339 deps = ["@com_google_protobuf//:descriptor_proto"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700340)
341
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700342cc_library(
Protobuf Team823ed182022-04-28 16:07:14 -0700343 name = "collections",
344 srcs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700345 "upb/array.c",
346 "upb/map.c",
Protobuf Team Bot79759452022-06-23 16:51:15 -0700347 "upb/msg_internal.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700348 ],
349 hdrs = [
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700350 "upb/array.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700351 "upb/collections.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700352 "upb/map.h",
353 "upb/message_value.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700354 ],
355 copts = UPB_DEFAULT_COPTS,
356 visibility = ["//visibility:public"],
357 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700358 ":mini_table",
359 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700360 ":table_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700361 ":upb",
362 ],
363)
364
365cc_library(
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700366 name = "reflection",
367 srcs = [
368 "upb/def.c",
Joshua Haberman58010a32020-02-18 16:53:21 -0800369 "upb/msg.h",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800370 "upb/reflection.c",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700371 ],
372 hdrs = [
373 "upb/def.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700374 "upb/def.hpp",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800375 "upb/reflection.h",
Joshua Haberman5e550e82021-01-09 15:45:44 -0800376 "upb/reflection.hpp",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700377 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700378 copts = UPB_DEFAULT_COPTS,
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700379 visibility = ["//visibility:public"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700380 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700381 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700382 ":descriptor_upb_proto",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700383 ":mini_table",
Anna Rfc494112020-01-09 14:16:25 -0800384 ":port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700385 ":table_internal",
Joshua Haberman9a663562019-05-13 16:13:39 -0700386 ":upb",
Josh Habermancd9e1e62019-04-17 15:23:00 -0700387 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700388)
389
Joshua Habermance1a3992020-02-04 06:22:09 -0800390cc_library(
391 name = "textformat",
392 srcs = [
Joshua Haberman02c89a82020-02-10 14:56:27 -0800393 "upb/text_encode.c",
Joshua Habermance1a3992020-02-04 06:22:09 -0800394 ],
395 hdrs = [
Joshua Haberman02c89a82020-02-10 14:56:27 -0800396 "upb/text_encode.h",
Joshua Habermance1a3992020-02-04 06:22:09 -0800397 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700398 copts = UPB_DEFAULT_COPTS,
Joshua Habermance1a3992020-02-04 06:22:09 -0800399 visibility = ["//visibility:public"],
400 deps = [
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700401 ":encode_internal",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800402 ":port",
Joshua Habermance1a3992020-02-04 06:22:09 -0800403 ":reflection",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700404 ":table_internal",
Joshua Habermance1a3992020-02-04 06:22:09 -0800405 ],
406)
407
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800408cc_library(
409 name = "json",
410 srcs = [
Joshua Habermand49c1db2020-02-23 19:49:39 -0800411 "upb/json_decode.c",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800412 "upb/json_encode.c",
413 ],
414 hdrs = [
Joshua Habermand49c1db2020-02-23 19:49:39 -0800415 "upb/json_decode.h",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800416 "upb/json_encode.h",
417 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700418 copts = UPB_DEFAULT_COPTS,
Lidi Zhengf72c26c2020-12-10 16:23:08 -0800419 visibility = ["//visibility:public"],
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800420 deps = [
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700421 ":encode_internal",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800422 ":port",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800423 ":reflection",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800424 ":upb",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800425 ],
426)
427
Joshua Haberman11b6df02022-02-15 19:55:44 -0800428# Tests ########################################################################
429
430cc_test(
431 name = "test_generated_code",
432 srcs = ["upb/test_generated_code.cc"],
433 deps = [
434 ":empty_upbdefs_proto",
Joshua Haberman1cf82142022-05-12 13:57:50 -0700435 ":port",
Protobuf Teambef53682022-04-04 11:18:39 -0700436 ":test_messages_proto2_proto_upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800437 ":test_messages_proto3_proto_upb",
438 ":test_upb_proto",
Matt Kulukundisedd1dd32022-02-20 17:44:27 -0500439 ":upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800440 "@com_google_googletest//:gtest_main",
441 ],
442)
443
444proto_library(
445 name = "test_proto",
446 testonly = 1,
447 srcs = ["upb/test.proto"],
448)
449
450upb_proto_library(
451 name = "test_upb_proto",
452 testonly = 1,
453 deps = [":test_proto"],
454)
455
456proto_library(
457 name = "empty_proto",
458 srcs = ["upb/empty.proto"],
459)
460
461upb_proto_reflection_library(
462 name = "empty_upbdefs_proto",
463 testonly = 1,
464 deps = [":empty_proto"],
465)
466
467upb_proto_library(
Protobuf Teambef53682022-04-04 11:18:39 -0700468 name = "test_messages_proto2_proto_upb",
469 testonly = 1,
470 deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
471)
472
473upb_proto_library(
Joshua Haberman11b6df02022-02-15 19:55:44 -0800474 name = "test_messages_proto3_proto_upb",
475 testonly = 1,
476 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
477)
Matt Kulukundis61b09052022-02-19 19:35:58 -0500478
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700479proto_library(
480 name = "json_test_proto",
481 testonly = 1,
482 srcs = ["upb/json_test.proto"],
483 deps = ["@com_google_protobuf//:struct_proto"],
484)
485
486upb_proto_library(
487 name = "json_test_upb_proto",
488 testonly = 1,
489 deps = [":json_test_proto"],
490)
491
492upb_proto_reflection_library(
493 name = "json_test_upb_proto_reflection",
494 testonly = 1,
495 deps = [":json_test_proto"],
496)
497
498cc_test(
499 name = "json_test",
500 srcs = ["upb/json_test.cc"],
501 deps = [
502 ":json",
503 ":json_test_upb_proto",
504 ":json_test_upb_proto_reflection",
505 ":reflection",
506 ":struct_upb_proto",
507 ":upb",
508 "@com_google_googletest//:gtest_main",
509 ],
510)
511
Joshua Habermance012b72021-10-01 16:34:42 -0700512cc_test(
513 name = "msg_test",
514 srcs = ["upb/msg_test.cc"],
515 deps = [
Joshua Habermance012b72021-10-01 16:34:42 -0700516 ":json",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500517 ":msg_test_upb_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500518 ":msg_test_upb_proto_reflection",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500519 ":reflection",
Matt Kulukundis42c121e2022-02-21 23:58:17 -0500520 ":test_messages_proto3_proto_upb",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500521 ":upb",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500522 "@com_google_googletest//:gtest_main",
Joshua Habermance012b72021-10-01 16:34:42 -0700523 ],
524)
525
526proto_library(
527 name = "msg_test_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500528 testonly = 1,
Joshua Habermance012b72021-10-01 16:34:42 -0700529 srcs = ["upb/msg_test.proto"],
530 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
531)
532
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500533upb_proto_library(
534 name = "msg_test_upb_proto",
535 testonly = 1,
536 deps = [":msg_test_proto"],
537)
538
Joshua Habermance012b72021-10-01 16:34:42 -0700539upb_proto_reflection_library(
540 name = "msg_test_upb_proto_reflection",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500541 testonly = 1,
Joshua Habermance012b72021-10-01 16:34:42 -0700542 deps = [":msg_test_proto"],
543)
544
Joshua Haberman11b6df02022-02-15 19:55:44 -0800545proto_library(
546 name = "test_cpp_proto",
547 srcs = ["upb/test_cpp.proto"],
Matt Kulukundis61b09052022-02-19 19:35:58 -0500548 deps = ["@com_google_protobuf//:timestamp_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800549)
550
551upb_proto_library(
552 name = "test_cpp_upb_proto",
553 deps = ["test_cpp_proto"],
554)
555
556upb_proto_reflection_library(
557 name = "test_cpp_upb_proto_reflection",
558 deps = ["test_cpp_proto"],
559)
560
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500561upb_proto_library(
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700562 name = "struct_upb_proto",
563 deps = ["@com_google_protobuf//:struct_proto"],
564)
565
566upb_proto_library(
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500567 name = "timestamp_upb_proto",
568 deps = ["@com_google_protobuf//:timestamp_proto"],
569)
570
571upb_proto_reflection_library(
572 name = "timestamp_upb_proto_reflection",
573 deps = ["@com_google_protobuf//:timestamp_proto"],
574)
575
Joshua Haberman11b6df02022-02-15 19:55:44 -0800576cc_test(
577 name = "test_cpp",
578 srcs = ["upb/test_cpp.cc"],
579 copts = UPB_DEFAULT_CPPOPTS,
580 deps = [
581 ":test_cpp_upb_proto",
582 ":test_cpp_upb_proto_reflection",
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500583 ":timestamp_upb_proto",
584 ":timestamp_upb_proto_reflection",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800585 "//:json",
586 "//:port",
587 "//:reflection",
588 "//:upb",
589 "@com_google_googletest//:gtest_main",
590 ],
591)
592
593cc_test(
594 name = "test_table",
595 srcs = ["upb/test_table.cc"],
596 copts = UPB_DEFAULT_CPPOPTS,
597 deps = [
598 "//:port",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700599 "//:table_internal",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800600 "//:upb",
601 "@com_google_googletest//:gtest_main",
602 ],
603)
604
Joshua Haberman11b6df02022-02-15 19:55:44 -0800605upb_proto_library(
606 name = "conformance_proto_upb",
607 testonly = 1,
Joshua Haberman32f45b52022-05-09 22:00:33 -0700608 deps = ["@com_google_protobuf//conformance:conformance_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800609)
610
611upb_proto_reflection_library(
612 name = "conformance_proto_upbdefs",
613 testonly = 1,
Joshua Haberman32f45b52022-05-09 22:00:33 -0700614 deps = ["@com_google_protobuf//conformance:conformance_proto"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800615)
616
617upb_proto_reflection_library(
618 name = "test_messages_proto2_upbdefs",
619 testonly = 1,
620 deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
621)
622
623upb_proto_reflection_library(
624 name = "test_messages_proto3_upbdefs",
625 testonly = 1,
626 deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
627)
628
629cc_binary(
630 name = "conformance_upb",
631 testonly = 1,
632 srcs = ["upb/conformance_upb.c"],
633 copts = UPB_DEFAULT_COPTS,
634 data = ["upb/conformance_upb_failures.txt"],
635 deps = [
636 ":conformance_proto_upb",
637 ":conformance_proto_upbdefs",
638 ":test_messages_proto2_upbdefs",
639 ":test_messages_proto3_upbdefs",
640 "//:json",
641 "//:port",
642 "//:reflection",
643 "//:textformat",
644 "//:upb",
645 ],
646)
647
648make_shell_script(
649 name = "gen_test_conformance_upb",
650 out = "test_conformance_upb.sh",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700651 contents = "external/com_google_protobuf/conformance/conformance_test_runner " +
Joshua Haberman11b6df02022-02-15 19:55:44 -0800652 " --enforce_recommended " +
653 " --failure_list ./upb/conformance_upb_failures.txt" +
654 " ./conformance_upb",
655)
656
657sh_test(
658 name = "test_conformance_upb",
659 srcs = ["test_conformance_upb.sh"],
660 data = [
661 "upb/conformance_upb_failures.txt",
662 ":conformance_upb",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700663 "@com_google_protobuf//conformance:conformance_test_runner",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800664 ],
665 deps = ["@bazel_tools//tools/bash/runfiles"],
666)
667
Joshua Haberman50c12982022-03-08 15:52:37 -0800668cc_binary(
669 name = "conformance_upb_dynamic_minitable",
670 testonly = 1,
671 srcs = ["upb/conformance_upb.c"],
672 copts = UPB_DEFAULT_COPTS + [
Joshua Haberman970c6452022-03-08 17:44:06 -0800673 "-DREBUILD_MINITABLES",
Joshua Haberman50c12982022-03-08 15:52:37 -0800674 ],
675 data = ["upb/conformance_upb_failures.txt"],
676 deps = [
677 ":conformance_proto_upb",
678 ":conformance_proto_upbdefs",
679 ":test_messages_proto2_upbdefs",
680 ":test_messages_proto3_upbdefs",
681 "//:json",
682 "//:port",
683 "//:reflection",
684 "//:textformat",
685 "//:upb",
686 ],
687)
688
689make_shell_script(
690 name = "gen_test_conformance_upb_dynamic_minitable",
691 out = "test_conformance_upb_dynamic_minitable.sh",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700692 contents = "external/com_google_protobuf/conformance/conformance_test_runner " +
Joshua Haberman50c12982022-03-08 15:52:37 -0800693 " --enforce_recommended " +
694 " --failure_list ./upb/conformance_upb_failures.txt" +
695 " ./conformance_upb_dynamic_minitable",
696)
697
698sh_test(
699 name = "test_conformance_upb_dynamic_minitable",
700 srcs = ["test_conformance_upb_dynamic_minitable.sh"],
701 data = [
702 "upb/conformance_upb_failures.txt",
703 ":conformance_upb_dynamic_minitable",
Joshua Haberman32f45b52022-05-09 22:00:33 -0700704 "@com_google_protobuf//conformance:conformance_test_runner",
Joshua Haberman50c12982022-03-08 15:52:37 -0800705 ],
706 deps = ["@bazel_tools//tools/bash/runfiles"],
707)
708
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700709# Internal C/C++ libraries #####################################################
710
711cc_library(
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700712 name = "arena_internal",
713 srcs = [
714 "upb/alloc.h",
715 "upb/arena.h",
716 ],
717 hdrs = ["upb/internal/arena.h"],
718 copts = UPB_DEFAULT_COPTS,
719 visibility = ["//:__subpackages__"],
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700720 deps = [":port"],
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700721)
722
723cc_library(
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700724 name = "encode_internal",
725 hdrs = ["upb/internal/encode.h"],
726 copts = UPB_DEFAULT_COPTS,
727 visibility = ["//:__subpackages__"],
728 deps = [":port"],
729)
730
731cc_library(
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700732 name = "table_internal",
733 srcs = [
734 "upb/internal/table.c",
735 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700736 hdrs = [
Protobuf Team Bot7b05f252022-06-22 09:18:12 -0700737 "upb/alloc.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700738 "upb/arena.h",
739 "upb/internal/table.h",
740 "upb/status.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700741 "upb/string_view.h",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700742 "upb/upb.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700743 ],
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700744 copts = UPB_DEFAULT_COPTS,
745 visibility = ["//:__subpackages__"],
746 deps = [":port"],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700747)
748
Joshua Haberman77371f02019-01-23 16:26:13 -0800749# Amalgamation #################################################################
750
Protobuf Teamb8edc712022-03-16 08:24:52 -0700751# begin:github_only
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800752
Joshua Haberman77371f02019-01-23 16:26:13 -0800753upb_amalgamation(
754 name = "gen_amalgamation",
755 outs = [
756 "upb.c",
757 "upb.h",
758 ],
Joshua Haberman77371f02019-01-23 16:26:13 -0800759 libs = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700760 ":arena_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700761 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700762 ":descriptor_upb_proto",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700763 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700764 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700765 ":fastdecode",
766 ":mini_table",
Anna Rde1bc112020-01-07 15:45:19 -0800767 ":port",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700768 ":reflection",
769 ":upb",
Joshua Haberman77371f02019-01-23 16:26:13 -0800770 ],
771)
772
773cc_library(
774 name = "amalgamation",
775 srcs = ["upb.c"],
776 hdrs = ["upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700777 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700778 deps = ["//third_party/utf8_range"],
Joshua Haberman77371f02019-01-23 16:26:13 -0800779)
780
Joshua Haberman16facab2020-05-08 16:40:24 -0700781upb_amalgamation(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700782 name = "gen_php_amalgamation",
Joshua Haberman16facab2020-05-08 16:40:24 -0700783 outs = [
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700784 "php-upb.c",
785 "php-upb.h",
Joshua Haberman16facab2020-05-08 16:40:24 -0700786 ],
Joshua Haberman16facab2020-05-08 16:40:24 -0700787 libs = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700788 ":arena_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700789 ":collections",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700790 ":descriptor_upb_proto",
791 ":descriptor_upb_proto_reflection",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700792 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700793 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700794 ":fastdecode",
Joshua Haberman16facab2020-05-08 16:40:24 -0700795 ":json",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700796 ":mini_table",
797 ":port",
798 ":reflection",
799 ":upb",
Joshua Haberman16facab2020-05-08 16:40:24 -0700800 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700801 prefix = "php-",
Joshua Haberman16facab2020-05-08 16:40:24 -0700802)
803
804cc_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700805 name = "php_amalgamation",
806 srcs = ["php-upb.c"],
807 hdrs = ["php-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 Haberman16facab2020-05-08 16:40:24 -0700810)
811
Joshua Habermanefefbff2020-08-03 10:12:31 -0700812upb_amalgamation(
813 name = "gen_ruby_amalgamation",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700814 outs = [
815 "ruby-upb.c",
816 "ruby-upb.h",
817 ],
Joshua Habermanefefbff2020-08-03 10:12:31 -0700818 libs = [
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700819 ":arena_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700820 ":collections",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700821 ":descriptor_upb_proto",
Protobuf Team Bot033859f2022-06-24 13:52:58 -0700822 ":encode_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700823 ":extension_registry",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700824 ":fastdecode",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700825 ":json",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700826 ":mini_table",
827 ":port",
828 ":reflection",
829 ":upb",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700830 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700831 prefix = "ruby-",
Joshua Habermanefefbff2020-08-03 10:12:31 -0700832)
833
834cc_library(
835 name = "ruby_amalgamation",
836 srcs = ["ruby-upb.c"],
837 hdrs = ["ruby-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -0700838 copts = UPB_DEFAULT_COPTS,
Joshua Haberman4307f5d2021-10-11 23:02:32 -0700839 deps = ["//third_party/utf8_range"],
Joshua Habermanefefbff2020-08-03 10:12:31 -0700840)
841
Joshua Habermane3f41de2020-10-17 13:15:58 -0700842exports_files(
843 [
Joshua Habermanbfc86d32019-12-04 16:56:40 -0800844 "third_party/lunit/console.lua",
845 "third_party/lunit/lunit.lua",
846 ],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800847 visibility = ["//upb/bindings/lua:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700848)
849
Joshua Haberman985145c2019-04-24 17:36:17 +0000850filegroup(
851 name = "cmake_files",
852 srcs = glob([
Joshua Haberman985145c2019-04-24 17:36:17 +0000853 "upbc/**/*",
854 "upb/**/*",
Joshua Haberman4f901b62020-10-14 16:32:43 -0700855 "third_party/**/*",
Joshua Haberman9a663562019-05-13 16:13:39 -0700856 ]),
Joshua Habermane3f41de2020-10-17 13:15:58 -0700857 visibility = ["//cmake:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700858)
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800859
Protobuf Teamb8edc712022-03-16 08:24:52 -0700860# end:github_only
Joshua Haberman4ffeaa62022-06-01 12:25:11 -0700861
862# begin:google_only
863#
864# py_binary(
865# name = "update_check_runs",
866# srcs = ["update_check_runs.py"],
867# main = "update_check_runs.py",
868# deps = [
869# "//third_party/py/absl:app",
870# ],
871# )
872#
873# end:google_only