blob: f967bd941467edfc546fe8bf50b97456d7b4e3b0 [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",
Joshua Haberman06b90f92019-05-14 15:58:58 -070030)
Joshua Haberman06b90f92019-05-14 15:58:58 -070031load(
Joshua Haberman5611ff22019-05-16 11:35:00 -070032 "//bazel:upb_proto_library.bzl",
Josh Habermana7ebe542018-11-03 18:18:47 -070033 "upb_proto_library",
Joshua Habermana274ad72020-10-28 13:06:30 -070034 "upb_proto_library_copts",
Joshua Habermane8f9eac2020-10-28 22:50:03 -070035 "upb_proto_reflection_library",
Josh Haberman2655ed92018-11-03 13:04:10 -070036)
Joshua Haberman143132f2023-01-03 16:20:37 -080037load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
Joshua Habermane41a2d72023-01-11 21:25:34 -080038load(
39 "//upbc:bootstrap_compiler.bzl",
40 "bootstrap_cc_library",
41 "bootstrap_upb_proto_library",
42)
Joshua Haberman0dc23942020-06-05 09:17:33 -070043
Protobuf Team Botbe98a912022-10-11 12:14:01 -070044# begin:google_only
45# load(
46# "//third_party/bazel_rules/rules_kotlin/kotlin/native:native_interop_hint.bzl",
47# "kt_native_interop_hint",
48# )
49# end:google_only
50
Protobuf Teamb8edc712022-03-16 08:24:52 -070051# begin:github_only
52load(
Laramie Leavitt7d762512022-11-16 14:09:07 -080053 "//bazel:amalgamation.bzl",
Protobuf Teamb8edc712022-03-16 08:24:52 -070054 "upb_amalgamation",
55)
Copybara-Serviceaaf9e432023-01-13 13:41:03 -080056load("@rules_pkg//:mappings.bzl", "pkg_files")
Protobuf Teamb8edc712022-03-16 08:24:52 -070057# end:github_only
58
Joshua Haberman83c0edb2021-02-28 16:56:49 -080059licenses(["notice"])
Joshua Haberman7f9f7222019-01-23 17:10:22 -080060
Joshua Habermana5243ff2022-03-30 14:20:07 -070061exports_files(["LICENSE"])
62
63exports_files(
64 [
65 "BUILD",
66 "WORKSPACE",
67 ],
68 visibility = ["//cmake:__pkg__"],
69)
Joshua Haberman7f9f7222019-01-23 17:10:22 -080070
Joshua Haberman00f96cb2019-03-27 12:13:59 -070071config_setting(
Nicolas "Pixel" Noblece3ba4d2019-07-18 01:12:00 +020072 name = "windows",
Protobuf Teame5f26012022-06-01 14:40:00 -070073 constraint_values = ["@platforms//os:windows"],
Eli Schleifer231daa32021-12-20 16:01:23 -080074 visibility = ["//visibility:public"],
Nicolas "Pixel" Noblece3ba4d2019-07-18 01:12:00 +020075)
76
Joshua Haberman143132f2023-01-03 16:20:37 -080077bool_flag(
Joshua Habermana345af92020-10-18 13:39:13 -070078 name = "fasttable_enabled",
Joshua Habermanb9286962020-10-26 21:23:16 -070079 build_setting_default = False,
Joshua Habermana345af92020-10-18 13:39:13 -070080 visibility = ["//visibility:public"],
81)
82
Joshua Habermane8f9eac2020-10-28 22:50:03 -070083config_setting(
84 name = "fasttable_enabled_setting",
85 flag_values = {"//:fasttable_enabled": "true"},
Protobuf Team Bot0f4fffe2022-11-04 14:25:29 -070086 visibility = ["//visibility:public"],
Joshua Habermane8f9eac2020-10-28 22:50:03 -070087)
88
Joshua Habermana274ad72020-10-28 13:06:30 -070089upb_proto_library_copts(
90 name = "upb_proto_library_copts__for_generated_code_only_do_not_use",
91 copts = UPB_DEFAULT_COPTS,
92 visibility = ["//visibility:public"],
93)
94
Protobuf Team Bota4779ef2022-11-04 18:33:20 -070095# Please update copy.bara.sky target = ":friends" if
96# you make changes to this list.
Joshua Haberman6df55172022-05-24 11:41:56 -070097package_group(
98 name = "friends",
99 packages = [],
100)
101
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700102# Public C/C++ libraries #######################################################
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700103
104cc_library(
Anna Rde1bc112020-01-07 15:45:19 -0800105 name = "port",
Joshua Habermana60e9a32022-05-13 17:32:17 -0700106 hdrs = [
Eric Salof6307872022-11-05 16:16:27 -0700107 "upb/port/vsnprintf_compat.h",
Joshua Habermana60e9a32022-05-13 17:32:17 -0700108 ],
Joshua Haberman558315a2020-10-28 17:13:13 -0700109 copts = UPB_DEFAULT_COPTS,
Anna Rde1bc112020-01-07 15:45:19 -0800110 textual_hdrs = [
Eric Salof6307872022-11-05 16:16:27 -0700111 "upb/port/def.inc",
112 "upb/port/undef.inc",
Anna Rde1bc112020-01-07 15:45:19 -0800113 ],
Matt Kulukundisc49e6df2022-02-21 20:12:58 -0500114 visibility = ["//:__subpackages__"],
Anna Rde1bc112020-01-07 15:45:19 -0800115)
116
117cc_library(
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700118 name = "upb",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700119 hdrs = [
Protobuf Team Bot7b05f252022-06-22 09:18:12 -0700120 "upb/alloc.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700121 "upb/arena.h",
Protobuf Team Bot8c44f042022-06-30 10:35:56 -0700122 "upb/array.h",
Eric Saloff8e1b42022-11-13 20:46:22 -0800123 "upb/base/descriptor_constants.h",
124 "upb/base/status.h",
125 "upb/base/string_view.h",
Eric Salofd143162022-11-03 17:17:17 -0700126 "upb/collections/array.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700127 "upb/decode.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700128 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700129 "upb/extension_registry.h",
Eric Salo63247132022-11-13 16:15:01 -0800130 "upb/map.h",
Eric Salof409c992022-11-03 15:48:59 +0000131 "upb/mem/alloc.h",
132 "upb/mem/arena.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800133 "upb/message/extension_internal.h",
134 "upb/message/message.h",
Eric Salo4f098fd2022-11-23 17:59:55 -0800135 "upb/mini_table/extension_registry.h",
Joshua Haberman1674f282021-04-04 18:43:24 -0700136 "upb/msg.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700137 "upb/status.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700138 "upb/string_view.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700139 "upb/upb.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700140 "upb/upb.hpp",
Eric Saloe1371752022-11-03 16:46:34 +0000141 "upb/wire/decode.h",
142 "upb/wire/encode.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700143 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700144 copts = UPB_DEFAULT_COPTS,
Joshua Habermanba29af32019-06-01 19:27:49 -0700145 visibility = ["//visibility:public"],
Joshua Habermanefd576b2020-10-26 21:37:17 -0700146 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800147 ":base",
Eric Salofd143162022-11-03 17:17:17 -0700148 ":collections_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700149 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800150 ":hash",
Eric Salo4d3998b2022-11-16 09:04:06 -0800151 ":lex",
Eric Salof409c992022-11-03 15:48:59 +0000152 ":mem",
Eric Salofb7a6742022-11-17 11:45:26 -0800153 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800154 ":mini_table_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700155 ":port",
Eric Salofb7a6742022-11-17 11:45:26 -0800156 ":wire",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700157 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700158)
159
160cc_library(
Eric Saloff8e1b42022-11-13 20:46:22 -0800161 name = "base",
162 srcs = [
163 "upb/base/status.c",
164 ],
165 hdrs = [
166 "upb/base/descriptor_constants.h",
167 "upb/base/log2.h",
168 "upb/base/status.h",
169 "upb/base/string_view.h",
170 ],
171 copts = UPB_DEFAULT_COPTS,
172 visibility = ["//:__subpackages__"],
173 deps = [":port"],
174)
175
176cc_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800177 name = "mini_table",
178 hdrs = [
179 "upb/mini_table.h",
180 "upb/mini_table/decode.h",
Eric Salo4f098fd2022-11-23 17:59:55 -0800181 "upb/mini_table/extension_registry.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800182 "upb/mini_table/types.h",
183 ],
184 copts = UPB_DEFAULT_COPTS,
185 visibility = ["//visibility:public"],
186 deps = [
187 ":base",
188 ":mem",
189 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700190 ":port",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700191 ],
192)
193
194cc_library(
Joshua Haberman970c6452022-03-08 17:44:06 -0800195 name = "mini_table_internal",
Eric Saloc033eff2022-10-27 14:36:38 -0700196 srcs = [
Eric Saloc033eff2022-10-27 14:36:38 -0700197 "upb/mini_table/common.c",
Eric Saloc033eff2022-10-27 14:36:38 -0700198 "upb/mini_table/decode.c",
199 "upb/mini_table/encode.c",
Eric Salo4f098fd2022-11-23 17:59:55 -0800200 "upb/mini_table/extension_registry.c",
Protobuf Teame5468b42022-04-19 14:09:14 -0700201 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800202 hdrs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800203 "upb/mini_table/common.h",
204 "upb/mini_table/common_internal.h",
Eric Saloc033eff2022-10-27 14:36:38 -0700205 "upb/mini_table/decode.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800206 "upb/mini_table/encode_internal.h",
207 "upb/mini_table/encode_internal.hpp",
208 "upb/mini_table/enum_internal.h",
209 "upb/mini_table/extension_internal.h",
Eric Salo4f098fd2022-11-23 17:59:55 -0800210 "upb/mini_table/extension_registry.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800211 "upb/mini_table/field_internal.h",
212 "upb/mini_table/file_internal.h",
213 "upb/mini_table/message_internal.h",
214 "upb/mini_table/sub_internal.h",
215 "upb/mini_table/types.h",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800216 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800217 visibility = ["//visibility:public"],
Joshua Haberman970c6452022-03-08 17:44:06 -0800218 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800219 ":base",
Joshua Haberman9c6223c2022-11-23 16:54:36 -0800220 ":hash",
Eric Salo27d70ed2022-11-16 22:13:41 -0800221 ":mem",
Joshua Haberman970c6452022-03-08 17:44:06 -0800222 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800223 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800224)
225
Protobuf Teame5468b42022-04-19 14:09:14 -0700226cc_library(
Eric Salofb7a6742022-11-17 11:45:26 -0800227 name = "message",
228 hdrs = [
229 "upb/message/message.h",
230 ],
231 copts = UPB_DEFAULT_COPTS,
232 visibility = ["//visibility:public"],
233 deps = [
234 ":mem",
235 ":message_internal",
236 ":mini_table",
237 ":port",
238 ],
239)
240
241cc_library(
242 name = "message_internal",
243 srcs = [
244 "upb/message/message.c",
245 ],
246 hdrs = [
247 "upb/message/extension_internal.h",
248 "upb/message/internal.h",
249 "upb/message/message.h",
250 ],
251 copts = UPB_DEFAULT_COPTS,
252 visibility = ["//visibility:public"],
253 deps = [
254 ":base",
Eric Salofb7a6742022-11-17 11:45:26 -0800255 ":hash",
256 ":mem",
257 ":mini_table_internal",
258 ":port",
259 ],
260)
261
262cc_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800263 name = "message_accessors",
Protobuf Teame5468b42022-04-19 14:09:14 -0700264 srcs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800265 "upb/message/accessors.c",
Protobuf Teame5468b42022-04-19 14:09:14 -0700266 ],
267 hdrs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800268 "upb/message/accessors.h",
Protobuf Teame5468b42022-04-19 14:09:14 -0700269 ],
270 copts = UPB_DEFAULT_COPTS,
Joshua Haberman6df55172022-05-24 11:41:56 -0700271 visibility = ["//visibility:public"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700272 deps = [
Eric Salofd143162022-11-03 17:17:17 -0700273 ":collections_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -0800274 ":eps_copy_input_stream",
Eric Salofb7a6742022-11-17 11:45:26 -0800275 ":hash",
276 ":message_internal",
Protobuf Teame5468b42022-04-19 14:09:14 -0700277 ":mini_table_internal",
278 ":port",
279 ":upb",
Eric Saloff6439f2022-11-18 09:59:21 -0800280 ":wire",
Joshua Haberman75488a02022-12-27 23:04:44 -0800281 ":wire_reader",
Protobuf Teame5468b42022-04-19 14:09:14 -0700282 ],
283)
284
Protobuf Team Bot3286f942023-03-07 07:09:44 -0800285cc_library(
286 name = "message_copy",
287 srcs = [
288 "upb/message/copy.c",
289 ],
290 hdrs = [
291 "upb/message/copy.h",
292 ],
293 copts = UPB_DEFAULT_COPTS,
294 visibility = ["//visibility:public"],
295 deps = [
296 ":collections_internal",
297 ":message_accessors",
298 ":message_internal",
299 ":mini_table_internal",
300 ":port",
301 ":upb",
302 ],
303)
304
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800305cc_test(
Eric Saloc033eff2022-10-27 14:36:38 -0700306 name = "mini_table_encode_test",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700307 srcs = [
Eric Saloc033eff2022-10-27 14:36:38 -0700308 "upb/mini_table/encode_test.cc",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700309 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800310 deps = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800311 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800312 ":hash",
Eric Salofb7a6742022-11-17 11:45:26 -0800313 ":message_internal",
Joshua Haberman970c6452022-03-08 17:44:06 -0800314 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700315 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800316 ":upb",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800317 "@com_google_absl//absl/container:flat_hash_set",
Joshua Haberman970c6452022-03-08 17:44:06 -0800318 "@com_google_googletest//:gtest_main",
Joshua Haberman8d148f02022-03-13 18:45:50 -0700319 "@com_google_protobuf//:protobuf",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800320 ],
321)
322
Protobuf Teame5468b42022-04-19 14:09:14 -0700323cc_test(
Eric Salo27d70ed2022-11-16 22:13:41 -0800324 name = "message_accessors_test",
325 srcs = ["upb/message/accessors_test.cc"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700326 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700327 ":collections",
Eric Salo27d70ed2022-11-16 22:13:41 -0800328 ":message_accessors",
Protobuf Teame5468b42022-04-19 14:09:14 -0700329 ":mini_table_internal",
Protobuf Teame5468b42022-04-19 14:09:14 -0700330 ":upb",
Eric Salob98c7c72022-12-02 12:39:06 -0800331 "//upb/test:test_messages_proto2_upb_proto",
332 "//upb/test:test_messages_proto3_upb_proto",
333 "//upb/test:test_upb_proto",
Protobuf Teame5468b42022-04-19 14:09:14 -0700334 "@com_google_absl//absl/container:flat_hash_set",
335 "@com_google_googletest//:gtest_main",
336 "@com_google_protobuf//:protobuf",
337 ],
338)
339
Protobuf Team Bot3286f942023-03-07 07:09:44 -0800340cc_test(
341 name = "message_copy_test",
342 srcs = ["upb/message/copy_test.cc"],
343 deps = [
344 ":collections",
345 ":message_accessors",
346 ":message_copy",
347 ":mini_table_internal",
348 ":upb",
349 "//upb/test:test_messages_proto2_upb_proto",
350 "//upb/test:test_messages_proto3_upb_proto",
351 "//upb/test:test_upb_proto",
352 "@com_google_absl//absl/container:flat_hash_set",
353 "@com_google_googletest//:gtest_main",
354 "@com_google_protobuf//:protobuf",
355 ],
356)
357
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800358cc_library(
Joshua Habermancb234e62020-10-17 17:48:32 -0700359 name = "fastdecode",
Joshua Habermane86541a2020-10-28 17:53:09 -0700360 copts = UPB_DEFAULT_COPTS,
Joshua Habermanefd576b2020-10-26 21:37:17 -0700361 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800362 ":base",
Eric Salofd143162022-11-03 17:17:17 -0700363 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800364 ":hash",
Eric Salof409c992022-11-03 15:48:59 +0000365 ":mem_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800366 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800367 ":mini_table_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700368 ":port",
Eric Salofb7a6742022-11-17 11:45:26 -0800369 ":wire",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700370 ],
Joshua Habermanba29af32019-06-01 19:27:49 -0700371)
372
373# Common support routines used by generated code. This library has no
374# implementation, but depends on :upb and exposes a few more hdrs.
375#
376# This is public only because we have no way of visibility-limiting it to
377# upb_proto_library() only. This interface is not stable and by using it you
378# give up any backward compatibility guarantees.
379cc_library(
380 name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
Joshua Habermanba29af32019-06-01 19:27:49 -0700381 hdrs = [
Eric Salofd143162022-11-03 17:17:17 -0700382 "upb/collections/array.h",
383 "upb/collections/array_internal.h",
Eric Salofd040a82022-11-04 22:08:16 -0700384 "upb/collections/map_gencode_util.h",
Eric Salofd143162022-11-03 17:17:17 -0700385 "upb/collections/message_value.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700386 "upb/extension_registry.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800387 "upb/message/accessors.h",
388 "upb/message/extension_internal.h",
389 "upb/message/internal.h",
390 "upb/message/message.h",
Eric Salo33633fd2022-11-10 12:18:03 -0800391 "upb/mini_table/common.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800392 "upb/mini_table/enum_internal.h",
393 "upb/mini_table/extension_internal.h",
394 "upb/mini_table/field_internal.h",
395 "upb/mini_table/file_internal.h",
396 "upb/mini_table/message_internal.h",
397 "upb/mini_table/sub_internal.h",
398 "upb/mini_table/types.h",
Eric Salof6307872022-11-05 16:16:27 -0700399 "upb/port/def.inc",
400 "upb/port/undef.inc",
Eric Saloe1371752022-11-03 16:46:34 +0000401 "upb/wire/decode.h",
402 "upb/wire/decode_fast.h",
403 "upb/wire/encode.h",
Joshua Habermanba29af32019-06-01 19:27:49 -0700404 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700405 copts = UPB_DEFAULT_COPTS,
Vishal Powar7031f772018-11-28 15:32:16 -0800406 visibility = ["//visibility:public"],
Anna Rde1bc112020-01-07 15:45:19 -0800407 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800408 ":base",
Eric Salofd040a82022-11-04 22:08:16 -0700409 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800410 ":hash",
Anna Rde1bc112020-01-07 15:45:19 -0800411 ":upb",
412 ],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700413)
414
Protobuf Team Botff463792022-07-06 09:06:27 -0700415# Common support code for C++ generated code.
416cc_library(
417 name = "generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
418 hdrs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800419 "upb/message/extension_internal.h",
420 "upb/message/internal.h",
421 "upb/message/message.h",
422 "upb/mini_table/enum_internal.h",
423 "upb/mini_table/extension_internal.h",
424 "upb/mini_table/field_internal.h",
425 "upb/mini_table/file_internal.h",
426 "upb/mini_table/message_internal.h",
427 "upb/mini_table/sub_internal.h",
428 "upb/mini_table/types.h",
Eric Salof6307872022-11-05 16:16:27 -0700429 "upb/port/def.inc",
430 "upb/port/undef.inc",
Protobuf Team Botff463792022-07-06 09:06:27 -0700431 "upb/upb.hpp",
Eric Saloe1371752022-11-03 16:46:34 +0000432 "upb/wire/decode.h",
433 "upb/wire/decode_fast.h",
434 "upb/wire/encode.h",
Protobuf Team Botff463792022-07-06 09:06:27 -0700435 ],
436 copts = UPB_DEFAULT_COPTS,
437 visibility = ["//visibility:public"],
438 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800439 ":base",
Eric Salofd040a82022-11-04 22:08:16 -0700440 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800441 ":hash",
Protobuf Team Botff463792022-07-06 09:06:27 -0700442 ":mini_table",
Protobuf Team Botff463792022-07-06 09:06:27 -0700443 ":upb",
444 ],
445)
446
Joshua Haberman8c530f92022-02-22 14:50:55 -0800447cc_library(
448 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
449 hdrs = [
Eric Salof6307872022-11-05 16:16:27 -0700450 "upb/port/def.inc",
451 "upb/port/undef.inc",
Eric Saloedecfd52022-09-15 10:26:14 -0700452 "upb/reflection/def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700453 "upb/reflection/def_pool_internal.h",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800454 ],
455 copts = UPB_DEFAULT_COPTS,
456 visibility = ["//visibility:public"],
457 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800458 ":base",
Eric Saloedecfd52022-09-15 10:26:14 -0700459 ":descriptor_upb_proto",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800460 ":hash",
Joshua Habermane41a2d72023-01-11 21:25:34 -0800461 ":mini_table_internal",
Eric Salo44916d72022-10-04 17:22:07 -0700462 ":reflection_internal",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800463 ],
464)
465
Joshua Habermane41a2d72023-01-11 21:25:34 -0800466bootstrap_upb_proto_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700467 name = "descriptor_upb_proto",
Joshua Habermane41a2d72023-01-11 21:25:34 -0800468 base_dir = "upb/reflection/",
469 google3_src_files = ["net/proto2/proto/descriptor.proto"],
470 google3_src_rules = ["//net/proto2/proto:descriptor_proto_source"],
471 oss_src_files = ["google/protobuf/descriptor.proto"],
472 oss_src_rules = ["@com_google_protobuf//:descriptor_proto_srcs"],
473 oss_strip_prefix = "third_party/protobuf/github/bootstrap/src",
474 proto_lib_deps = ["@com_google_protobuf//:descriptor_proto"],
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700475 visibility = ["//visibility:public"],
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700476)
477
478upb_proto_reflection_library(
479 name = "descriptor_upb_proto_reflection",
Joshua Habermanc58541e2019-05-15 09:49:29 -0700480 visibility = ["//visibility:public"],
Google-Autofuzz8f196672019-06-25 20:14:14 -0400481 deps = ["@com_google_protobuf//:descriptor_proto"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700482)
483
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700484cc_library(
Protobuf Team823ed182022-04-28 16:07:14 -0700485 name = "collections",
Protobuf Team823ed182022-04-28 16:07:14 -0700486 hdrs = [
Eric Salofd143162022-11-03 17:17:17 -0700487 "upb/collections/array.h",
488 "upb/collections/map.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700489 ],
490 copts = UPB_DEFAULT_COPTS,
491 visibility = ["//visibility:public"],
492 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800493 ":base",
Eric Salo63247132022-11-13 16:15:01 -0800494 ":collections_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800495 ":mem",
Eric Salo63247132022-11-13 16:15:01 -0800496 ":port",
497 ],
498)
499
500cc_library(
501 name = "collections_internal",
502 srcs = [
503 "upb/collections/array.c",
504 "upb/collections/map.c",
505 "upb/collections/map_sorter.c",
Eric Salo63247132022-11-13 16:15:01 -0800506 ],
507 hdrs = [
508 "upb/collections/array.h",
509 "upb/collections/array_internal.h",
510 "upb/collections/map.h",
511 "upb/collections/map_gencode_util.h",
512 "upb/collections/map_internal.h",
513 "upb/collections/map_sorter_internal.h",
514 "upb/collections/message_value.h",
515 ],
516 copts = UPB_DEFAULT_COPTS,
517 visibility = ["//:__subpackages__"],
518 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800519 ":base",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800520 ":hash",
Eric Salo63247132022-11-13 16:15:01 -0800521 ":mem",
Joshua Haberman57a79de2023-02-08 16:42:15 -0800522 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800523 ":mini_table_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700524 ":port",
Protobuf Team823ed182022-04-28 16:07:14 -0700525 ],
526)
527
Eric Salo00765002022-09-14 20:27:24 -0700528# TODO(b/232091617): Once we can delete the deprecated forwarding headers
529# (= everything in upb/) we can move this build target down into reflection/
Joshua Habermane41a2d72023-01-11 21:25:34 -0800530bootstrap_cc_library(
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700531 name = "reflection",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700532 hdrs = [
533 "upb/def.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700534 "upb/def.hpp",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800535 "upb/reflection.h",
Joshua Haberman5e550e82021-01-09 15:45:44 -0800536 "upb/reflection.hpp",
Eric Salo00765002022-09-14 20:27:24 -0700537 "upb/reflection/def.h",
538 "upb/reflection/def.hpp",
539 "upb/reflection/message.h",
540 "upb/reflection/message.hpp",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700541 ],
Joshua Habermane41a2d72023-01-11 21:25:34 -0800542 bootstrap_deps = [":reflection_internal"],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700543 copts = UPB_DEFAULT_COPTS,
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700544 visibility = ["//visibility:public"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700545 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700546 ":collections",
Anna Rfc494112020-01-09 14:16:25 -0800547 ":port",
Joshua Haberman9a663562019-05-13 16:13:39 -0700548 ":upb",
Josh Habermancd9e1e62019-04-17 15:23:00 -0700549 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700550)
551
Joshua Habermane41a2d72023-01-11 21:25:34 -0800552bootstrap_cc_library(
Eric Salo44916d72022-10-04 17:22:07 -0700553 name = "reflection_internal",
554 srcs = [
Eric Salo63247132022-11-13 16:15:01 -0800555 "upb/reflection/def_builder.c",
556 "upb/reflection/def_pool.c",
557 "upb/reflection/def_type.c",
558 "upb/reflection/desc_state.c",
559 "upb/reflection/enum_def.c",
Eric Salo384ffc02022-11-17 12:57:40 -0800560 "upb/reflection/enum_reserved_range.c",
Eric Salo63247132022-11-13 16:15:01 -0800561 "upb/reflection/enum_value_def.c",
562 "upb/reflection/extension_range.c",
563 "upb/reflection/field_def.c",
564 "upb/reflection/file_def.c",
565 "upb/reflection/message.c",
566 "upb/reflection/message_def.c",
Eric Salo384ffc02022-11-17 12:57:40 -0800567 "upb/reflection/message_reserved_range.c",
Eric Salo63247132022-11-13 16:15:01 -0800568 "upb/reflection/method_def.c",
569 "upb/reflection/oneof_def.c",
570 "upb/reflection/service_def.c",
571 ],
572 hdrs = [
Eric Salo44916d72022-10-04 17:22:07 -0700573 "upb/reflection/common.h",
Eric Salo63247132022-11-13 16:15:01 -0800574 "upb/reflection/def.h",
575 "upb/reflection/def.hpp",
Eric Salo44916d72022-10-04 17:22:07 -0700576 "upb/reflection/def_builder_internal.h",
577 "upb/reflection/def_pool.h",
Eric Salo63247132022-11-13 16:15:01 -0800578 "upb/reflection/def_pool_internal.h",
Eric Salo44916d72022-10-04 17:22:07 -0700579 "upb/reflection/def_type.h",
580 "upb/reflection/desc_state_internal.h",
581 "upb/reflection/enum_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700582 "upb/reflection/enum_def_internal.h",
Eric Salo384ffc02022-11-17 12:57:40 -0800583 "upb/reflection/enum_reserved_range.h",
584 "upb/reflection/enum_reserved_range_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800585 "upb/reflection/enum_value_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700586 "upb/reflection/enum_value_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800587 "upb/reflection/extension_range.h",
Eric Salo44916d72022-10-04 17:22:07 -0700588 "upb/reflection/extension_range_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800589 "upb/reflection/field_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700590 "upb/reflection/field_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800591 "upb/reflection/file_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700592 "upb/reflection/file_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800593 "upb/reflection/message.h",
594 "upb/reflection/message.hpp",
595 "upb/reflection/message_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700596 "upb/reflection/message_def_internal.h",
Eric Salo384ffc02022-11-17 12:57:40 -0800597 "upb/reflection/message_reserved_range.h",
598 "upb/reflection/message_reserved_range_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800599 "upb/reflection/method_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700600 "upb/reflection/method_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800601 "upb/reflection/oneof_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700602 "upb/reflection/oneof_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800603 "upb/reflection/service_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700604 "upb/reflection/service_def_internal.h",
605 ],
Joshua Habermane41a2d72023-01-11 21:25:34 -0800606 bootstrap_deps = [":descriptor_upb_proto"],
Eric Salo44916d72022-10-04 17:22:07 -0700607 copts = UPB_DEFAULT_COPTS,
608 visibility = ["//visibility:public"],
609 deps = [
610 ":collections",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800611 ":hash",
Joshua Haberman9c6223c2022-11-23 16:54:36 -0800612 ":message_accessors",
Eric Salo44916d72022-10-04 17:22:07 -0700613 ":mini_table_internal",
614 ":port",
Eric Salo44916d72022-10-04 17:22:07 -0700615 ":upb",
616 ],
617)
618
619cc_library(
Joshua Habermance1a3992020-02-04 06:22:09 -0800620 name = "textformat",
621 srcs = [
Eric Salo0bb46632022-11-03 10:33:57 -0700622 "upb/text/encode.c",
Joshua Habermance1a3992020-02-04 06:22:09 -0800623 ],
624 hdrs = [
Eric Salo0bb46632022-11-03 10:33:57 -0700625 "upb/text/encode.h",
Joshua Haberman02c89a82020-02-10 14:56:27 -0800626 "upb/text_encode.h",
Joshua Habermance1a3992020-02-04 06:22:09 -0800627 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700628 copts = UPB_DEFAULT_COPTS,
Joshua Habermance1a3992020-02-04 06:22:09 -0800629 visibility = ["//visibility:public"],
630 deps = [
Eric Salo63247132022-11-13 16:15:01 -0800631 ":collections_internal",
Joshua Haberman112f0372022-12-28 11:55:56 -0800632 ":eps_copy_input_stream",
Eric Salo4d3998b2022-11-16 09:04:06 -0800633 ":lex",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800634 ":port",
Joshua Habermance1a3992020-02-04 06:22:09 -0800635 ":reflection",
Eric Saloff6439f2022-11-18 09:59:21 -0800636 ":wire",
Joshua Haberman112f0372022-12-28 11:55:56 -0800637 ":wire_reader",
Eric Salo26e9a752022-12-28 06:09:44 -0800638 ":wire_types",
Joshua Habermance1a3992020-02-04 06:22:09 -0800639 ],
640)
641
Eric Salo8cc3e072022-09-25 20:19:42 -0700642# TODO(b/232091617): Once we can delete the deprecated forwarding headers
643# (= everything in upb/) we can move this build target down into json/
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800644cc_library(
645 name = "json",
646 srcs = [
Eric Salo8cc3e072022-09-25 20:19:42 -0700647 "upb/json/decode.c",
648 "upb/json/encode.c",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800649 ],
650 hdrs = [
Eric Salo8cc3e072022-09-25 20:19:42 -0700651 "upb/json/decode.h",
652 "upb/json/encode.h",
Joshua Habermand49c1db2020-02-23 19:49:39 -0800653 "upb/json_decode.h",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800654 "upb/json_encode.h",
655 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700656 copts = UPB_DEFAULT_COPTS,
Lidi Zhengf72c26c2020-12-10 16:23:08 -0800657 visibility = ["//visibility:public"],
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800658 deps = [
Eric Salo85534bb2022-09-06 21:04:59 -0700659 ":collections",
Eric Salo4d3998b2022-11-16 09:04:06 -0800660 ":lex",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800661 ":port",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800662 ":reflection",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800663 ":upb",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800664 ],
665)
666
Joshua Haberman11b6df02022-02-15 19:55:44 -0800667# Tests ########################################################################
668
669cc_test(
Eric Salo00765002022-09-14 20:27:24 -0700670 name = "def_builder_test",
671 srcs = [
672 "upb/reflection/common.h",
Eric Salo44916d72022-10-04 17:22:07 -0700673 "upb/reflection/def_builder_internal.h",
Eric Salo00765002022-09-14 20:27:24 -0700674 "upb/reflection/def_builder_test.cc",
Eric Salo00765002022-09-14 20:27:24 -0700675 "upb/reflection/def_type.h",
676 ],
Joshua Haberman023c4da2022-11-14 22:37:17 -0800677 # TODO(b/259158612): fix this test on Windows.
678 target_compatible_with = select({
679 "@platforms//os:windows": ["//third_party/bazel_platforms:incompatible"],
680 "//conditions:default": [],
681 }),
Eric Salo00765002022-09-14 20:27:24 -0700682 deps = [
683 ":descriptor_upb_proto",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800684 ":hash",
Eric Salo00765002022-09-14 20:27:24 -0700685 ":port",
686 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -0700687 ":reflection_internal",
Eric Salo00765002022-09-14 20:27:24 -0700688 ":upb",
689 "@com_google_googletest//:gtest_main",
690 ],
691)
692
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700693proto_library(
694 name = "json_test_proto",
695 testonly = 1,
Eric Salo8cc3e072022-09-25 20:19:42 -0700696 srcs = ["upb/json/test.proto"],
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700697 deps = ["@com_google_protobuf//:struct_proto"],
698)
699
700upb_proto_library(
701 name = "json_test_upb_proto",
702 testonly = 1,
703 deps = [":json_test_proto"],
704)
705
706upb_proto_reflection_library(
707 name = "json_test_upb_proto_reflection",
708 testonly = 1,
709 deps = [":json_test_proto"],
710)
711
712cc_test(
Eric Salo4215bc82022-09-07 14:21:18 -0700713 name = "json_decode_test",
Eric Salo8cc3e072022-09-25 20:19:42 -0700714 srcs = ["upb/json/decode_test.cc"],
Eric Salo4215bc82022-09-07 14:21:18 -0700715 deps = [
716 ":json",
717 ":json_test_upb_proto",
718 ":json_test_upb_proto_reflection",
719 ":reflection",
720 ":struct_upb_proto",
721 ":upb",
722 "@com_google_googletest//:gtest_main",
723 ],
724)
725
726cc_test(
727 name = "json_encode_test",
Eric Salo8cc3e072022-09-25 20:19:42 -0700728 srcs = ["upb/json/encode_test.cc"],
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700729 deps = [
730 ":json",
731 ":json_test_upb_proto",
732 ":json_test_upb_proto_reflection",
733 ":reflection",
734 ":struct_upb_proto",
735 ":upb",
736 "@com_google_googletest//:gtest_main",
737 ],
738)
739
Joshua Habermance012b72021-10-01 16:34:42 -0700740cc_test(
Eric Salo02cf7aa2022-12-18 13:58:04 -0800741 name = "collections_test",
742 srcs = ["upb/collections/test.cc"],
743 deps = [
744 ":collections",
745 ":upb",
746 "@com_google_googletest//:gtest_main",
747 ],
748)
749
750cc_test(
Eric Salo27d70ed2022-11-16 22:13:41 -0800751 name = "message_test",
752 srcs = ["upb/message/test.cc"],
Joshua Habermance012b72021-10-01 16:34:42 -0700753 deps = [
Joshua Habermance012b72021-10-01 16:34:42 -0700754 ":json",
Eric Salo27d70ed2022-11-16 22:13:41 -0800755 ":message_test_upb_proto",
756 ":message_test_upb_proto_reflection",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500757 ":reflection",
758 ":upb",
Eric Salob98c7c72022-12-02 12:39:06 -0800759 "//upb/test:fuzz_util",
760 "//upb/test:test_messages_proto3_upb_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500761 "@com_google_googletest//:gtest_main",
Joshua Habermance012b72021-10-01 16:34:42 -0700762 ],
763)
764
765proto_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800766 name = "message_test_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500767 testonly = 1,
Eric Salo27d70ed2022-11-16 22:13:41 -0800768 srcs = ["upb/message/test.proto"],
Protobuf Team Bot04363f72022-10-07 11:49:51 -0700769 deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"],
Joshua Habermance012b72021-10-01 16:34:42 -0700770)
771
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500772upb_proto_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800773 name = "message_test_upb_proto",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500774 testonly = 1,
Eric Salo27d70ed2022-11-16 22:13:41 -0800775 deps = [":message_test_proto"],
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500776)
777
Joshua Habermance012b72021-10-01 16:34:42 -0700778upb_proto_reflection_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800779 name = "message_test_upb_proto_reflection",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500780 testonly = 1,
Eric Salo27d70ed2022-11-16 22:13:41 -0800781 deps = [":message_test_proto"],
Joshua Habermance012b72021-10-01 16:34:42 -0700782)
783
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500784upb_proto_library(
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700785 name = "struct_upb_proto",
786 deps = ["@com_google_protobuf//:struct_proto"],
787)
788
Joshua Haberman11b6df02022-02-15 19:55:44 -0800789cc_test(
Eric Saloc67021f2022-08-23 11:21:55 -0700790 name = "atoi_test",
Eric Salo4d3998b2022-11-16 09:04:06 -0800791 srcs = ["upb/lex/atoi_test.cc"],
Eric Saloc67021f2022-08-23 11:21:55 -0700792 copts = UPB_DEFAULT_CPPOPTS,
793 deps = [
Eric Salo4d3998b2022-11-16 09:04:06 -0800794 ":lex",
Eric Saloc67021f2022-08-23 11:21:55 -0700795 "@com_google_absl//absl/strings",
796 "@com_google_googletest//:gtest_main",
797 ],
798)
799
800cc_test(
Eric Salob3cb3fb2022-11-14 09:33:03 -0800801 name = "hash_test",
802 srcs = ["upb/hash/test.cc"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800803 copts = UPB_DEFAULT_CPPOPTS,
804 deps = [
Eric Salob3cb3fb2022-11-14 09:33:03 -0800805 ":hash",
Eric Salo00765002022-09-14 20:27:24 -0700806 ":port",
Eric Salo00765002022-09-14 20:27:24 -0700807 ":upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800808 "@com_google_googletest//:gtest_main",
809 ],
810)
811
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700812# Internal C/C++ libraries #####################################################
813
814cc_library(
Eric Salof409c992022-11-03 15:48:59 +0000815 name = "mem",
Eric Salof409c992022-11-03 15:48:59 +0000816 hdrs = [
817 "upb/mem/alloc.h",
818 "upb/mem/arena.h",
819 ],
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700820 copts = UPB_DEFAULT_COPTS,
821 visibility = ["//:__subpackages__"],
Eric Salo63247132022-11-13 16:15:01 -0800822 deps = [
823 ":mem_internal",
824 ":port",
825 ],
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700826)
827
828cc_library(
Eric Salof409c992022-11-03 15:48:59 +0000829 name = "mem_internal",
Eric Salo63247132022-11-13 16:15:01 -0800830 srcs = [
831 "upb/mem/alloc.c",
832 "upb/mem/arena.c",
833 ],
834 hdrs = [
835 "upb/mem/alloc.h",
836 "upb/mem/arena.h",
837 "upb/mem/arena_internal.h",
838 ],
Eric Salof409c992022-11-03 15:48:59 +0000839 copts = UPB_DEFAULT_COPTS,
840 visibility = ["//:__subpackages__"],
Eric Salo63247132022-11-13 16:15:01 -0800841 deps = [":port"],
Eric Salof409c992022-11-03 15:48:59 +0000842)
843
844cc_library(
Eric Salofb7a6742022-11-17 11:45:26 -0800845 name = "wire",
846 hdrs = [
847 "upb/wire/decode.h",
848 "upb/wire/encode.h",
849 ],
850 copts = UPB_DEFAULT_COPTS,
851 visibility = ["//visibility:public"],
852 deps = [
Eric Salofb7a6742022-11-17 11:45:26 -0800853 ":mem",
854 ":message_internal",
Eric Saloa4a7c302022-11-27 14:04:35 -0800855 ":mini_table_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800856 ":port",
857 ":wire_internal",
858 ],
859)
860
861cc_library(
Eric Saloe1371752022-11-03 16:46:34 +0000862 name = "wire_internal",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700863 srcs = [
Eric Salofb7a6742022-11-17 11:45:26 -0800864 "upb/wire/decode.c",
865 "upb/wire/decode_fast.c",
866 "upb/wire/encode.c",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700867 ],
Eric Saloe1371752022-11-03 16:46:34 +0000868 hdrs = [
Eric Salo46699b72022-11-05 09:51:07 -0700869 "upb/wire/common_internal.h",
Eric Salofb7a6742022-11-17 11:45:26 -0800870 "upb/wire/decode.h",
871 "upb/wire/decode_fast.h",
Eric Saloe1371752022-11-03 16:46:34 +0000872 "upb/wire/decode_internal.h",
Eric Salofb7a6742022-11-17 11:45:26 -0800873 "upb/wire/encode.h",
Eric Saloff8e1b42022-11-13 20:46:22 -0800874 "upb/wire/swap_internal.h",
Eric Saloe1371752022-11-03 16:46:34 +0000875 ],
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700876 copts = UPB_DEFAULT_COPTS,
877 visibility = ["//:__subpackages__"],
878 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800879 ":base",
Eric Salofd040a82022-11-04 22:08:16 -0700880 ":collections_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -0800881 ":eps_copy_input_stream",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800882 ":hash",
Eric Salof409c992022-11-03 15:48:59 +0000883 ":mem_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800884 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800885 ":mini_table_internal",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700886 ":port",
Joshua Haberman7cd8f6c2022-12-29 20:54:31 -0800887 ":wire_reader",
Joshua Haberman75488a02022-12-27 23:04:44 -0800888 ":wire_types",
Copybara-Service65a329a2022-12-02 13:53:04 -0800889 "@utf8_range",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700890 ],
891)
892
Joshua Haberman75488a02022-12-27 23:04:44 -0800893cc_library(
894 name = "wire_types",
895 hdrs = ["upb/wire/types.h"],
896 visibility = ["//visibility:public"],
897)
898
899cc_library(
900 name = "eps_copy_input_stream",
901 srcs = ["upb/wire/eps_copy_input_stream.c"],
902 hdrs = ["upb/wire/eps_copy_input_stream.h"],
903 visibility = ["//visibility:public"],
904 deps = [
905 ":mem",
906 ":port",
907 ],
908)
909
910cc_library(
911 name = "wire_reader",
Joshua Haberman112f0372022-12-28 11:55:56 -0800912 srcs = [
913 "upb/wire/reader.c",
914 "upb/wire/swap_internal.h",
915 ],
Joshua Haberman75488a02022-12-27 23:04:44 -0800916 hdrs = ["upb/wire/reader.h"],
917 visibility = ["//visibility:public"],
918 deps = [
919 ":eps_copy_input_stream",
920 ":port",
921 ":wire_types",
922 ],
923)
924
Joshua Haberman68d1d912022-12-10 08:50:36 -0800925cc_test(
926 name = "eps_copy_input_stream_test",
927 srcs = ["upb/wire/eps_copy_input_stream_test.cc"],
928 deps = [
Joshua Haberman75488a02022-12-27 23:04:44 -0800929 ":eps_copy_input_stream",
Joshua Habermana48af3f2022-12-27 20:43:42 -0800930 ":upb",
Joshua Haberman68d1d912022-12-10 08:50:36 -0800931 "@com_google_googletest//:gtest_main",
932 ],
933)
934
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700935cc_library(
Eric Salob3cb3fb2022-11-14 09:33:03 -0800936 name = "hash",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700937 srcs = [
Eric Salob3cb3fb2022-11-14 09:33:03 -0800938 "upb/hash/common.c",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700939 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700940 hdrs = [
Eric Salob3cb3fb2022-11-14 09:33:03 -0800941 "upb/hash/common.h",
942 "upb/hash/int_table.h",
943 "upb/hash/str_table.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700944 ],
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700945 copts = UPB_DEFAULT_COPTS,
946 visibility = ["//:__subpackages__"],
Eric Saloff8e1b42022-11-13 20:46:22 -0800947 deps = [
948 ":base",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800949 ":mem",
Eric Saloff8e1b42022-11-13 20:46:22 -0800950 ":port",
951 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700952)
953
Eric Salo410143b2022-07-08 16:27:56 -0700954cc_library(
Eric Salo4d3998b2022-11-16 09:04:06 -0800955 name = "lex",
Eric Salo410143b2022-07-08 16:27:56 -0700956 srcs = [
Eric Salo4d3998b2022-11-16 09:04:06 -0800957 "upb/lex/atoi.c",
958 "upb/lex/round_trip.c",
959 "upb/lex/strtod.c",
960 "upb/lex/unicode.c",
Eric Salo410143b2022-07-08 16:27:56 -0700961 ],
962 hdrs = [
Eric Salo4d3998b2022-11-16 09:04:06 -0800963 "upb/lex/atoi.h",
964 "upb/lex/round_trip.h",
965 "upb/lex/strtod.h",
966 "upb/lex/unicode.h",
Eric Salo410143b2022-07-08 16:27:56 -0700967 ],
968 copts = UPB_DEFAULT_COPTS,
969 visibility = ["//:__subpackages__"],
970 deps = [":port"],
971)
972
Joshua Haberman77371f02019-01-23 16:26:13 -0800973# Amalgamation #################################################################
974
Protobuf Teamb8edc712022-03-16 08:24:52 -0700975# begin:github_only
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800976
Joshua Haberman77371f02019-01-23 16:26:13 -0800977upb_amalgamation(
978 name = "gen_amalgamation",
979 outs = [
980 "upb.c",
981 "upb.h",
982 ],
Joshua Haberman77371f02019-01-23 16:26:13 -0800983 libs = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800984 ":base",
Eric Salofd143162022-11-03 17:17:17 -0700985 ":collections_internal",
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700986 ":descriptor_upb_proto",
Joshua Haberman75488a02022-12-27 23:04:44 -0800987 ":eps_copy_input_stream",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700988 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800989 ":hash",
Eric Salo4d3998b2022-11-16 09:04:06 -0800990 ":lex",
Eric Salof409c992022-11-03 15:48:59 +0000991 ":mem_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800992 ":mini_table_internal",
993 ":message_accessors",
Eric Salofb7a6742022-11-17 11:45:26 -0800994 ":message_internal",
Anna Rde1bc112020-01-07 15:45:19 -0800995 ":port",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700996 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -0700997 ":reflection_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -0700998 ":upb",
Eric Saloe1371752022-11-03 16:46:34 +0000999 ":wire_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -08001000 ":wire_reader",
1001 ":wire_types",
Joshua Haberman77371f02019-01-23 16:26:13 -08001002 ],
Mike Kruskal17b64512022-07-13 15:00:01 -07001003 strip_import_prefix = ["src"],
Joshua Haberman77371f02019-01-23 16:26:13 -08001004)
1005
1006cc_library(
1007 name = "amalgamation",
1008 srcs = ["upb.c"],
1009 hdrs = ["upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -07001010 copts = UPB_DEFAULT_COPTS,
Copybara-Service65a329a2022-12-02 13:53:04 -08001011 deps = ["@utf8_range"],
Joshua Haberman77371f02019-01-23 16:26:13 -08001012)
1013
Joshua Haberman16facab2020-05-08 16:40:24 -07001014upb_amalgamation(
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001015 name = "gen_php_amalgamation",
Joshua Haberman16facab2020-05-08 16:40:24 -07001016 outs = [
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001017 "php-upb.c",
1018 "php-upb.h",
Joshua Haberman16facab2020-05-08 16:40:24 -07001019 ],
Joshua Haberman16facab2020-05-08 16:40:24 -07001020 libs = [
Eric Saloff8e1b42022-11-13 20:46:22 -08001021 ":base",
Eric Salofd143162022-11-03 17:17:17 -07001022 ":collections_internal",
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001023 ":descriptor_upb_proto",
1024 ":descriptor_upb_proto_reflection",
Joshua Haberman75488a02022-12-27 23:04:44 -08001025 ":eps_copy_input_stream",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001026 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -08001027 ":hash",
Joshua Haberman16facab2020-05-08 16:40:24 -07001028 ":json",
Eric Salo4d3998b2022-11-16 09:04:06 -08001029 ":lex",
Eric Salof409c992022-11-03 15:48:59 +00001030 ":mem_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -08001031 ":message_accessors",
Eric Salofb7a6742022-11-17 11:45:26 -08001032 ":message_internal",
1033 ":mini_table_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001034 ":port",
1035 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -07001036 ":reflection_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001037 ":upb",
Eric Saloe1371752022-11-03 16:46:34 +00001038 ":wire_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -08001039 ":wire_reader",
1040 ":wire_types",
Joshua Haberman16facab2020-05-08 16:40:24 -07001041 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -07001042 prefix = "php-",
Mike Kruskal17b64512022-07-13 15:00:01 -07001043 strip_import_prefix = ["src"],
Mike Kruskal1fee6d82022-12-05 12:03:38 -08001044 visibility = ["@com_google_protobuf//php:__subpackages__"],
Joshua Haberman16facab2020-05-08 16:40:24 -07001045)
1046
1047cc_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001048 name = "php_amalgamation",
1049 srcs = ["php-upb.c"],
1050 hdrs = ["php-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -07001051 copts = UPB_DEFAULT_COPTS,
Copybara-Service65a329a2022-12-02 13:53:04 -08001052 deps = ["@utf8_range"],
Joshua Haberman16facab2020-05-08 16:40:24 -07001053)
1054
Joshua Habermanefefbff2020-08-03 10:12:31 -07001055upb_amalgamation(
1056 name = "gen_ruby_amalgamation",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001057 outs = [
1058 "ruby-upb.c",
1059 "ruby-upb.h",
1060 ],
Joshua Habermanefefbff2020-08-03 10:12:31 -07001061 libs = [
Eric Saloff8e1b42022-11-13 20:46:22 -08001062 ":base",
Eric Salofd143162022-11-03 17:17:17 -07001063 ":collections_internal",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001064 ":descriptor_upb_proto",
Joshua Haberman75488a02022-12-27 23:04:44 -08001065 ":eps_copy_input_stream",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001066 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -08001067 ":hash",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001068 ":json",
Eric Salo4d3998b2022-11-16 09:04:06 -08001069 ":lex",
Eric Salof409c992022-11-03 15:48:59 +00001070 ":mem_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -08001071 ":message_accessors",
Eric Salofb7a6742022-11-17 11:45:26 -08001072 ":message_internal",
1073 ":mini_table_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001074 ":port",
1075 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -07001076 ":reflection_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001077 ":upb",
Eric Saloe1371752022-11-03 16:46:34 +00001078 ":wire_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -08001079 ":wire_reader",
1080 ":wire_types",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001081 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -07001082 prefix = "ruby-",
Mike Kruskal17b64512022-07-13 15:00:01 -07001083 strip_import_prefix = ["src"],
Mike Kruskal1fee6d82022-12-05 12:03:38 -08001084 visibility = ["@com_google_protobuf//ruby:__subpackages__"],
Joshua Habermanefefbff2020-08-03 10:12:31 -07001085)
1086
1087cc_library(
1088 name = "ruby_amalgamation",
1089 srcs = ["ruby-upb.c"],
1090 hdrs = ["ruby-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -07001091 copts = UPB_DEFAULT_COPTS,
Copybara-Service65a329a2022-12-02 13:53:04 -08001092 deps = ["@utf8_range"],
Joshua Habermanefefbff2020-08-03 10:12:31 -07001093)
1094
Joshua Habermane3f41de2020-10-17 13:15:58 -07001095exports_files(
1096 [
Joshua Habermanbfc86d32019-12-04 16:56:40 -08001097 "third_party/lunit/console.lua",
1098 "third_party/lunit/lunit.lua",
1099 ],
Eric Saloa77b9662022-11-07 15:54:10 -08001100 visibility = ["//lua:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -07001101)
1102
Joshua Haberman985145c2019-04-24 17:36:17 +00001103filegroup(
1104 name = "cmake_files",
1105 srcs = glob([
Joshua Haberman985145c2019-04-24 17:36:17 +00001106 "upb/**/*",
Joshua Haberman4f901b62020-10-14 16:32:43 -07001107 "third_party/**/*",
Joshua Haberman9a663562019-05-13 16:13:39 -07001108 ]),
Joshua Habermane3f41de2020-10-17 13:15:58 -07001109 visibility = ["//cmake:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -07001110)
Joshua Haberman83c0edb2021-02-28 16:56:49 -08001111
Copybara-Serviceaaf9e432023-01-13 13:41:03 -08001112
Deanna Garciaf887fe32022-12-31 02:37:52 +00001113pkg_files(
Copybara-Serviceaaf9e432023-01-13 13:41:03 -08001114 name = "upb_source_files",
1115 srcs = glob(
1116 [
1117 "upb/**/*.c",
1118 "upb/**/*.h",
1119 "upb/**/*.hpp",
1120 "upb/**/*.inc",
1121 ],
Eric Salo4843fd02023-01-17 18:50:18 -08001122 exclude = ["upb/**/conformance_upb.c"],
Copybara-Serviceaaf9e432023-01-13 13:41:03 -08001123 ),
1124 strip_prefix = "",
1125 visibility = ["//python/dist:__pkg__"],
Deanna Garciaf887fe32022-12-31 02:37:52 +00001126)
1127
Protobuf Teamb8edc712022-03-16 08:24:52 -07001128# end:github_only
Joshua Haberman4ffeaa62022-06-01 12:25:11 -07001129
1130# begin:google_only
1131#
1132# py_binary(
1133# name = "update_check_runs",
1134# srcs = ["update_check_runs.py"],
1135# main = "update_check_runs.py",
1136# deps = [
1137# "//third_party/py/absl:app",
Mike Kruskale1b11b62022-09-30 13:28:24 -07001138# "//third_party/py/absl/flags",
Joshua Haberman4ffeaa62022-06-01 12:25:11 -07001139# ],
1140# )
1141#
Protobuf Team Botbe98a912022-10-11 12:14:01 -07001142# kt_native_interop_hint(
1143# name = "upb_kotlin_native_hint",
1144# compatible_with = ["//buildenv/target:non_prod"],
1145# headers_to_exclude = glob([
1146# "**/*.hpp",
Eric Salo4f098fd2022-11-23 17:59:55 -08001147# ]),
Protobuf Team Botbe98a912022-10-11 12:14:01 -07001148# no_string_conversion = ["upb_MiniTable_Build"],
1149# strict_enums = ["upb_FieldType"],
1150# )
1151#
1152# kt_native_interop_hint(
1153# name = "suppress_kotlin_interop",
1154# compatible_with = ["//buildenv/target:non_prod"],
1155# suppressed = True,
1156# )
1157#
Joshua Haberman4ffeaa62022-06-01 12:25:11 -07001158# end:google_only