blob: bb283130825472882d085b759d9930009b0b257d [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 = [
Joshua Habermand4509902023-03-22 08:21:49 -0700107 "upb/port/atomic.h",
Eric Salof6307872022-11-05 16:16:27 -0700108 "upb/port/vsnprintf_compat.h",
Joshua Habermana60e9a32022-05-13 17:32:17 -0700109 ],
Joshua Haberman558315a2020-10-28 17:13:13 -0700110 copts = UPB_DEFAULT_COPTS,
Anna Rde1bc112020-01-07 15:45:19 -0800111 textual_hdrs = [
Eric Salof6307872022-11-05 16:16:27 -0700112 "upb/port/def.inc",
113 "upb/port/undef.inc",
Anna Rde1bc112020-01-07 15:45:19 -0800114 ],
Matt Kulukundisc49e6df2022-02-21 20:12:58 -0500115 visibility = ["//:__subpackages__"],
Anna Rde1bc112020-01-07 15:45:19 -0800116)
117
118cc_library(
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700119 name = "upb",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700120 hdrs = [
Protobuf Team Bot7b05f252022-06-22 09:18:12 -0700121 "upb/alloc.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700122 "upb/arena.h",
Protobuf Team Bot8c44f042022-06-30 10:35:56 -0700123 "upb/array.h",
Eric Saloff8e1b42022-11-13 20:46:22 -0800124 "upb/base/descriptor_constants.h",
125 "upb/base/status.h",
126 "upb/base/string_view.h",
Eric Salofd143162022-11-03 17:17:17 -0700127 "upb/collections/array.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700128 "upb/decode.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700129 "upb/encode.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700130 "upb/extension_registry.h",
Eric Salo63247132022-11-13 16:15:01 -0800131 "upb/map.h",
Eric Salof409c992022-11-03 15:48:59 +0000132 "upb/mem/alloc.h",
133 "upb/mem/arena.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800134 "upb/message/extension_internal.h",
135 "upb/message/message.h",
Eric Salo4f098fd2022-11-23 17:59:55 -0800136 "upb/mini_table/extension_registry.h",
Joshua Haberman1674f282021-04-04 18:43:24 -0700137 "upb/msg.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700138 "upb/status.h",
Protobuf Team Bote153b522022-06-23 14:12:45 -0700139 "upb/string_view.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700140 "upb/upb.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700141 "upb/upb.hpp",
Protobuf Team Bot9d2b5d12023-04-09 10:01:22 -0700142 "upb/wire/common.h",
Eric Saloe1371752022-11-03 16:46:34 +0000143 "upb/wire/decode.h",
144 "upb/wire/encode.h",
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700145 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700146 copts = UPB_DEFAULT_COPTS,
Joshua Habermanba29af32019-06-01 19:27:49 -0700147 visibility = ["//visibility:public"],
Joshua Habermanefd576b2020-10-26 21:37:17 -0700148 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800149 ":base",
Eric Salofd143162022-11-03 17:17:17 -0700150 ":collections_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700151 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800152 ":hash",
Eric Salo4d3998b2022-11-16 09:04:06 -0800153 ":lex",
Eric Salof409c992022-11-03 15:48:59 +0000154 ":mem",
Eric Salofb7a6742022-11-17 11:45:26 -0800155 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800156 ":mini_table_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700157 ":port",
Eric Salofb7a6742022-11-17 11:45:26 -0800158 ":wire",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700159 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700160)
161
162cc_library(
Eric Saloff8e1b42022-11-13 20:46:22 -0800163 name = "base",
164 srcs = [
165 "upb/base/status.c",
166 ],
167 hdrs = [
168 "upb/base/descriptor_constants.h",
169 "upb/base/log2.h",
170 "upb/base/status.h",
171 "upb/base/string_view.h",
172 ],
173 copts = UPB_DEFAULT_COPTS,
174 visibility = ["//:__subpackages__"],
175 deps = [":port"],
176)
177
178cc_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800179 name = "mini_table",
180 hdrs = [
181 "upb/mini_table.h",
182 "upb/mini_table/decode.h",
Eric Salo4f098fd2022-11-23 17:59:55 -0800183 "upb/mini_table/extension_registry.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800184 "upb/mini_table/types.h",
185 ],
186 copts = UPB_DEFAULT_COPTS,
187 visibility = ["//visibility:public"],
188 deps = [
189 ":base",
190 ":mem",
191 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700192 ":port",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700193 ],
194)
195
196cc_library(
Joshua Haberman970c6452022-03-08 17:44:06 -0800197 name = "mini_table_internal",
Eric Saloc033eff2022-10-27 14:36:38 -0700198 srcs = [
Eric Saloc033eff2022-10-27 14:36:38 -0700199 "upb/mini_table/common.c",
Eric Saloc033eff2022-10-27 14:36:38 -0700200 "upb/mini_table/decode.c",
201 "upb/mini_table/encode.c",
Eric Salo4f098fd2022-11-23 17:59:55 -0800202 "upb/mini_table/extension_registry.c",
Protobuf Teame5468b42022-04-19 14:09:14 -0700203 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800204 hdrs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800205 "upb/mini_table/common.h",
206 "upb/mini_table/common_internal.h",
Eric Saloc033eff2022-10-27 14:36:38 -0700207 "upb/mini_table/decode.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800208 "upb/mini_table/encode_internal.h",
209 "upb/mini_table/encode_internal.hpp",
210 "upb/mini_table/enum_internal.h",
211 "upb/mini_table/extension_internal.h",
Eric Salo4f098fd2022-11-23 17:59:55 -0800212 "upb/mini_table/extension_registry.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800213 "upb/mini_table/field_internal.h",
214 "upb/mini_table/file_internal.h",
215 "upb/mini_table/message_internal.h",
216 "upb/mini_table/sub_internal.h",
217 "upb/mini_table/types.h",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800218 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800219 visibility = ["//visibility:public"],
Joshua Haberman970c6452022-03-08 17:44:06 -0800220 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800221 ":base",
Joshua Haberman9c6223c2022-11-23 16:54:36 -0800222 ":hash",
Eric Salo27d70ed2022-11-16 22:13:41 -0800223 ":mem",
Joshua Haberman970c6452022-03-08 17:44:06 -0800224 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800225 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800226)
227
Protobuf Teame5468b42022-04-19 14:09:14 -0700228cc_library(
Eric Salofb7a6742022-11-17 11:45:26 -0800229 name = "message",
230 hdrs = [
231 "upb/message/message.h",
232 ],
233 copts = UPB_DEFAULT_COPTS,
234 visibility = ["//visibility:public"],
235 deps = [
236 ":mem",
237 ":message_internal",
238 ":mini_table",
239 ":port",
240 ],
241)
242
243cc_library(
244 name = "message_internal",
245 srcs = [
246 "upb/message/message.c",
247 ],
248 hdrs = [
249 "upb/message/extension_internal.h",
250 "upb/message/internal.h",
251 "upb/message/message.h",
252 ],
253 copts = UPB_DEFAULT_COPTS,
254 visibility = ["//visibility:public"],
255 deps = [
256 ":base",
Eric Salofb7a6742022-11-17 11:45:26 -0800257 ":hash",
258 ":mem",
259 ":mini_table_internal",
260 ":port",
261 ],
262)
263
264cc_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800265 name = "message_accessors",
Protobuf Teame5468b42022-04-19 14:09:14 -0700266 srcs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800267 "upb/message/accessors.c",
Joshua Habermana49ff552023-04-17 08:41:25 -0700268 "upb/message/accessors_internal.h",
Protobuf Teame5468b42022-04-19 14:09:14 -0700269 ],
270 hdrs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800271 "upb/message/accessors.h",
Protobuf Teame5468b42022-04-19 14:09:14 -0700272 ],
273 copts = UPB_DEFAULT_COPTS,
Joshua Haberman6df55172022-05-24 11:41:56 -0700274 visibility = ["//visibility:public"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700275 deps = [
Eric Salofd143162022-11-03 17:17:17 -0700276 ":collections_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -0800277 ":eps_copy_input_stream",
Eric Salofb7a6742022-11-17 11:45:26 -0800278 ":hash",
279 ":message_internal",
Protobuf Teame5468b42022-04-19 14:09:14 -0700280 ":mini_table_internal",
281 ":port",
282 ":upb",
Eric Saloff6439f2022-11-18 09:59:21 -0800283 ":wire",
Joshua Haberman75488a02022-12-27 23:04:44 -0800284 ":wire_reader",
Protobuf Teame5468b42022-04-19 14:09:14 -0700285 ],
286)
287
Protobuf Team Bot3286f942023-03-07 07:09:44 -0800288cc_library(
289 name = "message_copy",
290 srcs = [
291 "upb/message/copy.c",
292 ],
293 hdrs = [
294 "upb/message/copy.h",
295 ],
296 copts = UPB_DEFAULT_COPTS,
297 visibility = ["//visibility:public"],
298 deps = [
299 ":collections_internal",
300 ":message_accessors",
301 ":message_internal",
302 ":mini_table_internal",
303 ":port",
304 ":upb",
305 ],
306)
307
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800308cc_test(
Eric Saloc033eff2022-10-27 14:36:38 -0700309 name = "mini_table_encode_test",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700310 srcs = [
Eric Saloc033eff2022-10-27 14:36:38 -0700311 "upb/mini_table/encode_test.cc",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700312 ],
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800313 deps = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800314 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800315 ":hash",
Eric Salofb7a6742022-11-17 11:45:26 -0800316 ":message_internal",
Joshua Haberman970c6452022-03-08 17:44:06 -0800317 ":mini_table_internal",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700318 ":port",
Joshua Haberman970c6452022-03-08 17:44:06 -0800319 ":upb",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800320 "@com_google_absl//absl/container:flat_hash_set",
Joshua Haberman970c6452022-03-08 17:44:06 -0800321 "@com_google_googletest//:gtest_main",
Joshua Haberman8d148f02022-03-13 18:45:50 -0700322 "@com_google_protobuf//:protobuf",
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800323 ],
324)
325
Protobuf Teame5468b42022-04-19 14:09:14 -0700326cc_test(
Eric Salo27d70ed2022-11-16 22:13:41 -0800327 name = "message_accessors_test",
328 srcs = ["upb/message/accessors_test.cc"],
Protobuf Teame5468b42022-04-19 14:09:14 -0700329 deps = [
Protobuf Teamc7620a42022-04-29 13:21:20 -0700330 ":collections",
Eric Salo27d70ed2022-11-16 22:13:41 -0800331 ":message_accessors",
Protobuf Teame5468b42022-04-19 14:09:14 -0700332 ":mini_table_internal",
Joshua Habermandf93cf62023-04-10 11:25:06 -0700333 ":port",
Protobuf Teame5468b42022-04-19 14:09:14 -0700334 ":upb",
Eric Salob98c7c72022-12-02 12:39:06 -0800335 "//upb/test:test_messages_proto2_upb_proto",
336 "//upb/test:test_messages_proto3_upb_proto",
337 "//upb/test:test_upb_proto",
Protobuf Teame5468b42022-04-19 14:09:14 -0700338 "@com_google_absl//absl/container:flat_hash_set",
339 "@com_google_googletest//:gtest_main",
340 "@com_google_protobuf//:protobuf",
341 ],
342)
343
Protobuf Team Bot3286f942023-03-07 07:09:44 -0800344cc_test(
345 name = "message_copy_test",
346 srcs = ["upb/message/copy_test.cc"],
347 deps = [
348 ":collections",
349 ":message_accessors",
350 ":message_copy",
351 ":mini_table_internal",
352 ":upb",
353 "//upb/test:test_messages_proto2_upb_proto",
354 "//upb/test:test_messages_proto3_upb_proto",
355 "//upb/test:test_upb_proto",
356 "@com_google_absl//absl/container:flat_hash_set",
357 "@com_google_googletest//:gtest_main",
358 "@com_google_protobuf//:protobuf",
359 ],
360)
361
Joshua Haberman8ede0d52022-03-05 18:33:27 -0800362cc_library(
Joshua Habermancb234e62020-10-17 17:48:32 -0700363 name = "fastdecode",
Joshua Habermane86541a2020-10-28 17:53:09 -0700364 copts = UPB_DEFAULT_COPTS,
Joshua Habermanefd576b2020-10-26 21:37:17 -0700365 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800366 ":base",
Eric Salofd143162022-11-03 17:17:17 -0700367 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800368 ":hash",
Eric Salof409c992022-11-03 15:48:59 +0000369 ":mem_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800370 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800371 ":mini_table_internal",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700372 ":port",
Eric Salofb7a6742022-11-17 11:45:26 -0800373 ":wire",
Joshua Habermanefd576b2020-10-26 21:37:17 -0700374 ],
Joshua Habermanba29af32019-06-01 19:27:49 -0700375)
376
377# Common support routines used by generated code. This library has no
378# implementation, but depends on :upb and exposes a few more hdrs.
379#
380# This is public only because we have no way of visibility-limiting it to
381# upb_proto_library() only. This interface is not stable and by using it you
382# give up any backward compatibility guarantees.
383cc_library(
384 name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
Joshua Habermanba29af32019-06-01 19:27:49 -0700385 hdrs = [
Eric Salofd143162022-11-03 17:17:17 -0700386 "upb/collections/array.h",
387 "upb/collections/array_internal.h",
Eric Salofd040a82022-11-04 22:08:16 -0700388 "upb/collections/map_gencode_util.h",
Eric Salofd143162022-11-03 17:17:17 -0700389 "upb/collections/message_value.h",
Protobuf Team Bote4635f22022-06-21 10:43:08 -0700390 "upb/extension_registry.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800391 "upb/message/accessors.h",
Joshua Habermana49ff552023-04-17 08:41:25 -0700392 "upb/message/accessors_internal.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800393 "upb/message/extension_internal.h",
394 "upb/message/internal.h",
395 "upb/message/message.h",
Eric Salo33633fd2022-11-10 12:18:03 -0800396 "upb/mini_table/common.h",
Eric Salo27d70ed2022-11-16 22:13:41 -0800397 "upb/mini_table/enum_internal.h",
398 "upb/mini_table/extension_internal.h",
399 "upb/mini_table/field_internal.h",
400 "upb/mini_table/file_internal.h",
401 "upb/mini_table/message_internal.h",
402 "upb/mini_table/sub_internal.h",
403 "upb/mini_table/types.h",
Eric Salof6307872022-11-05 16:16:27 -0700404 "upb/port/def.inc",
405 "upb/port/undef.inc",
Eric Saloe1371752022-11-03 16:46:34 +0000406 "upb/wire/decode.h",
407 "upb/wire/decode_fast.h",
408 "upb/wire/encode.h",
Joshua Habermanba29af32019-06-01 19:27:49 -0700409 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700410 copts = UPB_DEFAULT_COPTS,
Vishal Powar7031f772018-11-28 15:32:16 -0800411 visibility = ["//visibility:public"],
Anna Rde1bc112020-01-07 15:45:19 -0800412 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800413 ":base",
Eric Salofd040a82022-11-04 22:08:16 -0700414 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800415 ":hash",
Anna Rde1bc112020-01-07 15:45:19 -0800416 ":upb",
417 ],
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700418)
419
Protobuf Team Botff463792022-07-06 09:06:27 -0700420# Common support code for C++ generated code.
421cc_library(
422 name = "generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
423 hdrs = [
Eric Salo27d70ed2022-11-16 22:13:41 -0800424 "upb/message/extension_internal.h",
425 "upb/message/internal.h",
426 "upb/message/message.h",
427 "upb/mini_table/enum_internal.h",
428 "upb/mini_table/extension_internal.h",
429 "upb/mini_table/field_internal.h",
430 "upb/mini_table/file_internal.h",
431 "upb/mini_table/message_internal.h",
432 "upb/mini_table/sub_internal.h",
433 "upb/mini_table/types.h",
Eric Salof6307872022-11-05 16:16:27 -0700434 "upb/port/def.inc",
435 "upb/port/undef.inc",
Protobuf Team Botff463792022-07-06 09:06:27 -0700436 "upb/upb.hpp",
Eric Saloe1371752022-11-03 16:46:34 +0000437 "upb/wire/decode.h",
438 "upb/wire/decode_fast.h",
439 "upb/wire/encode.h",
Protobuf Team Botff463792022-07-06 09:06:27 -0700440 ],
441 copts = UPB_DEFAULT_COPTS,
442 visibility = ["//visibility:public"],
443 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800444 ":base",
Eric Salofd040a82022-11-04 22:08:16 -0700445 ":collections_internal",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800446 ":hash",
Protobuf Team Botff463792022-07-06 09:06:27 -0700447 ":mini_table",
Protobuf Team Botff463792022-07-06 09:06:27 -0700448 ":upb",
449 ],
450)
451
Joshua Haberman8c530f92022-02-22 14:50:55 -0800452cc_library(
453 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
454 hdrs = [
Eric Salof6307872022-11-05 16:16:27 -0700455 "upb/port/def.inc",
456 "upb/port/undef.inc",
Eric Saloedecfd52022-09-15 10:26:14 -0700457 "upb/reflection/def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700458 "upb/reflection/def_pool_internal.h",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800459 ],
460 copts = UPB_DEFAULT_COPTS,
461 visibility = ["//visibility:public"],
462 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800463 ":base",
Eric Saloedecfd52022-09-15 10:26:14 -0700464 ":descriptor_upb_proto",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800465 ":hash",
Joshua Habermane41a2d72023-01-11 21:25:34 -0800466 ":mini_table_internal",
Eric Salo44916d72022-10-04 17:22:07 -0700467 ":reflection_internal",
Joshua Haberman8c530f92022-02-22 14:50:55 -0800468 ],
469)
470
Joshua Habermane41a2d72023-01-11 21:25:34 -0800471bootstrap_upb_proto_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700472 name = "descriptor_upb_proto",
Joshua Habermane41a2d72023-01-11 21:25:34 -0800473 base_dir = "upb/reflection/",
474 google3_src_files = ["net/proto2/proto/descriptor.proto"],
475 google3_src_rules = ["//net/proto2/proto:descriptor_proto_source"],
476 oss_src_files = ["google/protobuf/descriptor.proto"],
477 oss_src_rules = ["@com_google_protobuf//:descriptor_proto_srcs"],
478 oss_strip_prefix = "third_party/protobuf/github/bootstrap/src",
479 proto_lib_deps = ["@com_google_protobuf//:descriptor_proto"],
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700480 visibility = ["//visibility:public"],
Joshua Haberman543a0ce2020-05-26 22:30:50 -0700481)
482
483upb_proto_reflection_library(
484 name = "descriptor_upb_proto_reflection",
Joshua Habermanc58541e2019-05-15 09:49:29 -0700485 visibility = ["//visibility:public"],
Google-Autofuzz8f196672019-06-25 20:14:14 -0400486 deps = ["@com_google_protobuf//:descriptor_proto"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700487)
488
Josh Haberman01ed4ce2018-11-02 12:49:15 -0700489cc_library(
Protobuf Team823ed182022-04-28 16:07:14 -0700490 name = "collections",
Protobuf Team823ed182022-04-28 16:07:14 -0700491 hdrs = [
Eric Salofd143162022-11-03 17:17:17 -0700492 "upb/collections/array.h",
493 "upb/collections/map.h",
Protobuf Team823ed182022-04-28 16:07:14 -0700494 ],
495 copts = UPB_DEFAULT_COPTS,
496 visibility = ["//visibility:public"],
497 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800498 ":base",
Eric Salo63247132022-11-13 16:15:01 -0800499 ":collections_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800500 ":mem",
Eric Salo63247132022-11-13 16:15:01 -0800501 ":port",
502 ],
503)
504
505cc_library(
506 name = "collections_internal",
507 srcs = [
508 "upb/collections/array.c",
509 "upb/collections/map.c",
510 "upb/collections/map_sorter.c",
Eric Salo63247132022-11-13 16:15:01 -0800511 ],
512 hdrs = [
513 "upb/collections/array.h",
514 "upb/collections/array_internal.h",
515 "upb/collections/map.h",
516 "upb/collections/map_gencode_util.h",
517 "upb/collections/map_internal.h",
518 "upb/collections/map_sorter_internal.h",
519 "upb/collections/message_value.h",
520 ],
521 copts = UPB_DEFAULT_COPTS,
522 visibility = ["//:__subpackages__"],
523 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800524 ":base",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800525 ":hash",
Eric Salo63247132022-11-13 16:15:01 -0800526 ":mem",
Joshua Haberman57a79de2023-02-08 16:42:15 -0800527 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800528 ":mini_table_internal",
Protobuf Team823ed182022-04-28 16:07:14 -0700529 ":port",
Protobuf Team823ed182022-04-28 16:07:14 -0700530 ],
531)
532
Eric Salo00765002022-09-14 20:27:24 -0700533# TODO(b/232091617): Once we can delete the deprecated forwarding headers
534# (= everything in upb/) we can move this build target down into reflection/
Joshua Habermane41a2d72023-01-11 21:25:34 -0800535bootstrap_cc_library(
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700536 name = "reflection",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700537 hdrs = [
538 "upb/def.h",
Joshua Haberman2559e782020-04-09 14:36:24 -0700539 "upb/def.hpp",
Joshua Haberman9a360ad2019-11-12 08:08:46 -0800540 "upb/reflection.h",
Joshua Haberman5e550e82021-01-09 15:45:44 -0800541 "upb/reflection.hpp",
Eric Salo00765002022-09-14 20:27:24 -0700542 "upb/reflection/def.h",
543 "upb/reflection/def.hpp",
544 "upb/reflection/message.h",
545 "upb/reflection/message.hpp",
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700546 ],
Joshua Habermane41a2d72023-01-11 21:25:34 -0800547 bootstrap_deps = [":reflection_internal"],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700548 copts = UPB_DEFAULT_COPTS,
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700549 visibility = ["//visibility:public"],
Josh Habermancd9e1e62019-04-17 15:23:00 -0700550 deps = [
Protobuf Team823ed182022-04-28 16:07:14 -0700551 ":collections",
Anna Rfc494112020-01-09 14:16:25 -0800552 ":port",
Joshua Haberman9a663562019-05-13 16:13:39 -0700553 ":upb",
Josh Habermancd9e1e62019-04-17 15:23:00 -0700554 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700555)
556
Joshua Habermane41a2d72023-01-11 21:25:34 -0800557bootstrap_cc_library(
Eric Salo44916d72022-10-04 17:22:07 -0700558 name = "reflection_internal",
559 srcs = [
Eric Salo63247132022-11-13 16:15:01 -0800560 "upb/reflection/def_builder.c",
561 "upb/reflection/def_pool.c",
562 "upb/reflection/def_type.c",
563 "upb/reflection/desc_state.c",
564 "upb/reflection/enum_def.c",
Eric Salo384ffc02022-11-17 12:57:40 -0800565 "upb/reflection/enum_reserved_range.c",
Eric Salo63247132022-11-13 16:15:01 -0800566 "upb/reflection/enum_value_def.c",
567 "upb/reflection/extension_range.c",
568 "upb/reflection/field_def.c",
569 "upb/reflection/file_def.c",
570 "upb/reflection/message.c",
571 "upb/reflection/message_def.c",
Eric Salo384ffc02022-11-17 12:57:40 -0800572 "upb/reflection/message_reserved_range.c",
Eric Salo63247132022-11-13 16:15:01 -0800573 "upb/reflection/method_def.c",
574 "upb/reflection/oneof_def.c",
575 "upb/reflection/service_def.c",
576 ],
577 hdrs = [
Eric Salo44916d72022-10-04 17:22:07 -0700578 "upb/reflection/common.h",
Eric Salo63247132022-11-13 16:15:01 -0800579 "upb/reflection/def.h",
580 "upb/reflection/def.hpp",
Eric Salo44916d72022-10-04 17:22:07 -0700581 "upb/reflection/def_builder_internal.h",
582 "upb/reflection/def_pool.h",
Eric Salo63247132022-11-13 16:15:01 -0800583 "upb/reflection/def_pool_internal.h",
Eric Salo44916d72022-10-04 17:22:07 -0700584 "upb/reflection/def_type.h",
585 "upb/reflection/desc_state_internal.h",
586 "upb/reflection/enum_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700587 "upb/reflection/enum_def_internal.h",
Eric Salo384ffc02022-11-17 12:57:40 -0800588 "upb/reflection/enum_reserved_range.h",
589 "upb/reflection/enum_reserved_range_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800590 "upb/reflection/enum_value_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700591 "upb/reflection/enum_value_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800592 "upb/reflection/extension_range.h",
Eric Salo44916d72022-10-04 17:22:07 -0700593 "upb/reflection/extension_range_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800594 "upb/reflection/field_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700595 "upb/reflection/field_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800596 "upb/reflection/file_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700597 "upb/reflection/file_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800598 "upb/reflection/message.h",
599 "upb/reflection/message.hpp",
600 "upb/reflection/message_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700601 "upb/reflection/message_def_internal.h",
Eric Salo384ffc02022-11-17 12:57:40 -0800602 "upb/reflection/message_reserved_range.h",
603 "upb/reflection/message_reserved_range_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800604 "upb/reflection/method_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700605 "upb/reflection/method_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800606 "upb/reflection/oneof_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700607 "upb/reflection/oneof_def_internal.h",
Eric Salo63247132022-11-13 16:15:01 -0800608 "upb/reflection/service_def.h",
Eric Salo44916d72022-10-04 17:22:07 -0700609 "upb/reflection/service_def_internal.h",
610 ],
Joshua Habermane41a2d72023-01-11 21:25:34 -0800611 bootstrap_deps = [":descriptor_upb_proto"],
Eric Salo44916d72022-10-04 17:22:07 -0700612 copts = UPB_DEFAULT_COPTS,
613 visibility = ["//visibility:public"],
614 deps = [
615 ":collections",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800616 ":hash",
Joshua Haberman9c6223c2022-11-23 16:54:36 -0800617 ":message_accessors",
Eric Salo44916d72022-10-04 17:22:07 -0700618 ":mini_table_internal",
619 ":port",
Eric Salo44916d72022-10-04 17:22:07 -0700620 ":upb",
621 ],
622)
623
624cc_library(
Joshua Habermance1a3992020-02-04 06:22:09 -0800625 name = "textformat",
626 srcs = [
Eric Salo0bb46632022-11-03 10:33:57 -0700627 "upb/text/encode.c",
Joshua Habermance1a3992020-02-04 06:22:09 -0800628 ],
629 hdrs = [
Eric Salo0bb46632022-11-03 10:33:57 -0700630 "upb/text/encode.h",
Joshua Haberman02c89a82020-02-10 14:56:27 -0800631 "upb/text_encode.h",
Joshua Habermance1a3992020-02-04 06:22:09 -0800632 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700633 copts = UPB_DEFAULT_COPTS,
Joshua Habermance1a3992020-02-04 06:22:09 -0800634 visibility = ["//visibility:public"],
635 deps = [
Eric Salo63247132022-11-13 16:15:01 -0800636 ":collections_internal",
Joshua Haberman112f0372022-12-28 11:55:56 -0800637 ":eps_copy_input_stream",
Eric Salo4d3998b2022-11-16 09:04:06 -0800638 ":lex",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800639 ":port",
Joshua Habermance1a3992020-02-04 06:22:09 -0800640 ":reflection",
Eric Saloff6439f2022-11-18 09:59:21 -0800641 ":wire",
Joshua Haberman112f0372022-12-28 11:55:56 -0800642 ":wire_reader",
Eric Salo26e9a752022-12-28 06:09:44 -0800643 ":wire_types",
Joshua Habermance1a3992020-02-04 06:22:09 -0800644 ],
645)
646
Eric Salo8cc3e072022-09-25 20:19:42 -0700647# TODO(b/232091617): Once we can delete the deprecated forwarding headers
648# (= everything in upb/) we can move this build target down into json/
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800649cc_library(
650 name = "json",
651 srcs = [
Eric Salo8cc3e072022-09-25 20:19:42 -0700652 "upb/json/decode.c",
653 "upb/json/encode.c",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800654 ],
655 hdrs = [
Eric Salo8cc3e072022-09-25 20:19:42 -0700656 "upb/json/decode.h",
657 "upb/json/encode.h",
Joshua Habermand49c1db2020-02-23 19:49:39 -0800658 "upb/json_decode.h",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800659 "upb/json_encode.h",
660 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -0700661 copts = UPB_DEFAULT_COPTS,
Lidi Zhengf72c26c2020-12-10 16:23:08 -0800662 visibility = ["//visibility:public"],
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800663 deps = [
Eric Salo85534bb2022-09-06 21:04:59 -0700664 ":collections",
Eric Salo4d3998b2022-11-16 09:04:06 -0800665 ":lex",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800666 ":port",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800667 ":reflection",
Joshua Haberman4b8c04e2020-02-18 16:50:25 -0800668 ":upb",
Joshua Haberman6e9db7d2020-02-15 19:31:51 -0800669 ],
670)
671
Joshua Haberman11b6df02022-02-15 19:55:44 -0800672# Tests ########################################################################
673
674cc_test(
Eric Salo00765002022-09-14 20:27:24 -0700675 name = "def_builder_test",
676 srcs = [
677 "upb/reflection/common.h",
Eric Salo44916d72022-10-04 17:22:07 -0700678 "upb/reflection/def_builder_internal.h",
Eric Salo00765002022-09-14 20:27:24 -0700679 "upb/reflection/def_builder_test.cc",
Eric Salo00765002022-09-14 20:27:24 -0700680 "upb/reflection/def_type.h",
681 ],
Joshua Haberman023c4da2022-11-14 22:37:17 -0800682 # TODO(b/259158612): fix this test on Windows.
683 target_compatible_with = select({
Mike Kruskald260ab32023-03-29 16:51:09 -0700684 "@platforms//os:windows": ["@platforms//:incompatible"],
Joshua Haberman023c4da2022-11-14 22:37:17 -0800685 "//conditions:default": [],
686 }),
Eric Salo00765002022-09-14 20:27:24 -0700687 deps = [
688 ":descriptor_upb_proto",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800689 ":hash",
Eric Salo00765002022-09-14 20:27:24 -0700690 ":port",
691 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -0700692 ":reflection_internal",
Eric Salo00765002022-09-14 20:27:24 -0700693 ":upb",
694 "@com_google_googletest//:gtest_main",
695 ],
696)
697
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700698proto_library(
699 name = "json_test_proto",
700 testonly = 1,
Eric Salo8cc3e072022-09-25 20:19:42 -0700701 srcs = ["upb/json/test.proto"],
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700702 deps = ["@com_google_protobuf//:struct_proto"],
703)
704
705upb_proto_library(
706 name = "json_test_upb_proto",
707 testonly = 1,
708 deps = [":json_test_proto"],
709)
710
711upb_proto_reflection_library(
712 name = "json_test_upb_proto_reflection",
713 testonly = 1,
714 deps = [":json_test_proto"],
715)
716
717cc_test(
Eric Salo4215bc82022-09-07 14:21:18 -0700718 name = "json_decode_test",
Eric Salo8cc3e072022-09-25 20:19:42 -0700719 srcs = ["upb/json/decode_test.cc"],
Eric Salo4215bc82022-09-07 14:21:18 -0700720 deps = [
721 ":json",
722 ":json_test_upb_proto",
723 ":json_test_upb_proto_reflection",
724 ":reflection",
725 ":struct_upb_proto",
726 ":upb",
727 "@com_google_googletest//:gtest_main",
728 ],
729)
730
731cc_test(
732 name = "json_encode_test",
Eric Salo8cc3e072022-09-25 20:19:42 -0700733 srcs = ["upb/json/encode_test.cc"],
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700734 deps = [
735 ":json",
736 ":json_test_upb_proto",
737 ":json_test_upb_proto_reflection",
738 ":reflection",
739 ":struct_upb_proto",
740 ":upb",
741 "@com_google_googletest//:gtest_main",
742 ],
743)
744
Joshua Habermance012b72021-10-01 16:34:42 -0700745cc_test(
Eric Salo02cf7aa2022-12-18 13:58:04 -0800746 name = "collections_test",
747 srcs = ["upb/collections/test.cc"],
748 deps = [
749 ":collections",
750 ":upb",
751 "@com_google_googletest//:gtest_main",
752 ],
753)
754
755cc_test(
Eric Salo27d70ed2022-11-16 22:13:41 -0800756 name = "message_test",
757 srcs = ["upb/message/test.cc"],
Joshua Habermance012b72021-10-01 16:34:42 -0700758 deps = [
Joshua Habermance012b72021-10-01 16:34:42 -0700759 ":json",
Eric Salo27d70ed2022-11-16 22:13:41 -0800760 ":message_test_upb_proto",
761 ":message_test_upb_proto_reflection",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500762 ":reflection",
763 ":upb",
Eric Salob98c7c72022-12-02 12:39:06 -0800764 "//upb/test:fuzz_util",
765 "//upb/test:test_messages_proto3_upb_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500766 "@com_google_googletest//:gtest_main",
Joshua Habermance012b72021-10-01 16:34:42 -0700767 ],
768)
769
770proto_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800771 name = "message_test_proto",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500772 testonly = 1,
Eric Salo27d70ed2022-11-16 22:13:41 -0800773 srcs = ["upb/message/test.proto"],
Protobuf Team Bot04363f72022-10-07 11:49:51 -0700774 deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"],
Joshua Habermance012b72021-10-01 16:34:42 -0700775)
776
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500777upb_proto_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800778 name = "message_test_upb_proto",
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500779 testonly = 1,
Eric Salo27d70ed2022-11-16 22:13:41 -0800780 deps = [":message_test_proto"],
Matt Kulukundisa3bd5f82022-02-21 23:47:27 -0500781)
782
Joshua Habermance012b72021-10-01 16:34:42 -0700783upb_proto_reflection_library(
Eric Salo27d70ed2022-11-16 22:13:41 -0800784 name = "message_test_upb_proto_reflection",
Matt Kulukundis61b09052022-02-19 19:35:58 -0500785 testonly = 1,
Eric Salo27d70ed2022-11-16 22:13:41 -0800786 deps = [":message_test_proto"],
Joshua Habermance012b72021-10-01 16:34:42 -0700787)
788
Matt Kulukundis92d71a42022-02-20 15:20:48 -0500789upb_proto_library(
Protobuf Team Bot6e1aa9f2022-06-08 11:17:20 -0700790 name = "struct_upb_proto",
791 deps = ["@com_google_protobuf//:struct_proto"],
792)
793
Joshua Haberman11b6df02022-02-15 19:55:44 -0800794cc_test(
Eric Saloc67021f2022-08-23 11:21:55 -0700795 name = "atoi_test",
Eric Salo4d3998b2022-11-16 09:04:06 -0800796 srcs = ["upb/lex/atoi_test.cc"],
Eric Saloc67021f2022-08-23 11:21:55 -0700797 copts = UPB_DEFAULT_CPPOPTS,
798 deps = [
Eric Salo4d3998b2022-11-16 09:04:06 -0800799 ":lex",
Eric Saloc67021f2022-08-23 11:21:55 -0700800 "@com_google_absl//absl/strings",
801 "@com_google_googletest//:gtest_main",
802 ],
803)
804
805cc_test(
Eric Salob3cb3fb2022-11-14 09:33:03 -0800806 name = "hash_test",
807 srcs = ["upb/hash/test.cc"],
Joshua Haberman11b6df02022-02-15 19:55:44 -0800808 copts = UPB_DEFAULT_CPPOPTS,
809 deps = [
Eric Salob3cb3fb2022-11-14 09:33:03 -0800810 ":hash",
Eric Salo00765002022-09-14 20:27:24 -0700811 ":port",
Eric Salo00765002022-09-14 20:27:24 -0700812 ":upb",
Joshua Haberman11b6df02022-02-15 19:55:44 -0800813 "@com_google_googletest//:gtest_main",
814 ],
815)
816
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700817# Internal C/C++ libraries #####################################################
818
819cc_library(
Eric Salof409c992022-11-03 15:48:59 +0000820 name = "mem",
Eric Salof409c992022-11-03 15:48:59 +0000821 hdrs = [
822 "upb/mem/alloc.h",
823 "upb/mem/arena.h",
824 ],
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700825 copts = UPB_DEFAULT_COPTS,
826 visibility = ["//:__subpackages__"],
Eric Salo63247132022-11-13 16:15:01 -0800827 deps = [
828 ":mem_internal",
829 ":port",
830 ],
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700831)
832
Matt Kulukundis5bc3cae2023-03-20 10:32:53 -0700833cc_test(
834 name = "arena_test",
835 srcs = ["upb/mem/arena_test.cc"],
836 deps = [
Joshua Haberman6d6ab902023-03-27 11:34:04 -0700837 ":port",
Matt Kulukundis5bc3cae2023-03-20 10:32:53 -0700838 ":upb",
839 "@com_google_absl//absl/random",
840 "@com_google_absl//absl/random:distributions",
841 "@com_google_absl//absl/synchronization",
842 "@com_google_googletest//:gtest_main",
843 ],
844)
845
Protobuf Team Bot8d0d13f2022-06-23 13:43:40 -0700846cc_library(
Eric Salof409c992022-11-03 15:48:59 +0000847 name = "mem_internal",
Eric Salo63247132022-11-13 16:15:01 -0800848 srcs = [
849 "upb/mem/alloc.c",
850 "upb/mem/arena.c",
851 ],
852 hdrs = [
853 "upb/mem/alloc.h",
854 "upb/mem/arena.h",
855 "upb/mem/arena_internal.h",
856 ],
Eric Salof409c992022-11-03 15:48:59 +0000857 copts = UPB_DEFAULT_COPTS,
858 visibility = ["//:__subpackages__"],
Eric Salo63247132022-11-13 16:15:01 -0800859 deps = [":port"],
Eric Salof409c992022-11-03 15:48:59 +0000860)
861
862cc_library(
Eric Salofb7a6742022-11-17 11:45:26 -0800863 name = "wire",
864 hdrs = [
865 "upb/wire/decode.h",
866 "upb/wire/encode.h",
867 ],
868 copts = UPB_DEFAULT_COPTS,
869 visibility = ["//visibility:public"],
870 deps = [
Eric Salofb7a6742022-11-17 11:45:26 -0800871 ":mem",
872 ":message_internal",
Eric Saloa4a7c302022-11-27 14:04:35 -0800873 ":mini_table_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800874 ":port",
875 ":wire_internal",
876 ],
877)
878
879cc_library(
Eric Saloe1371752022-11-03 16:46:34 +0000880 name = "wire_internal",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700881 srcs = [
Eric Salofb7a6742022-11-17 11:45:26 -0800882 "upb/wire/decode.c",
883 "upb/wire/decode_fast.c",
884 "upb/wire/encode.c",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700885 ],
Eric Saloe1371752022-11-03 16:46:34 +0000886 hdrs = [
Protobuf Team Bot9d2b5d12023-04-09 10:01:22 -0700887 "upb/wire/common.h",
Eric Salo46699b72022-11-05 09:51:07 -0700888 "upb/wire/common_internal.h",
Eric Salofb7a6742022-11-17 11:45:26 -0800889 "upb/wire/decode.h",
890 "upb/wire/decode_fast.h",
Eric Saloe1371752022-11-03 16:46:34 +0000891 "upb/wire/decode_internal.h",
Eric Salofb7a6742022-11-17 11:45:26 -0800892 "upb/wire/encode.h",
Eric Saloff8e1b42022-11-13 20:46:22 -0800893 "upb/wire/swap_internal.h",
Eric Saloe1371752022-11-03 16:46:34 +0000894 ],
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700895 copts = UPB_DEFAULT_COPTS,
896 visibility = ["//:__subpackages__"],
897 deps = [
Eric Saloff8e1b42022-11-13 20:46:22 -0800898 ":base",
Eric Salofd040a82022-11-04 22:08:16 -0700899 ":collections_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -0800900 ":eps_copy_input_stream",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800901 ":hash",
Eric Salof409c992022-11-03 15:48:59 +0000902 ":mem_internal",
Eric Salofb7a6742022-11-17 11:45:26 -0800903 ":message_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -0800904 ":mini_table_internal",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700905 ":port",
Joshua Haberman7cd8f6c2022-12-29 20:54:31 -0800906 ":wire_reader",
Joshua Haberman75488a02022-12-27 23:04:44 -0800907 ":wire_types",
Copybara-Service65a329a2022-12-02 13:53:04 -0800908 "@utf8_range",
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700909 ],
910)
911
Joshua Haberman75488a02022-12-27 23:04:44 -0800912cc_library(
913 name = "wire_types",
914 hdrs = ["upb/wire/types.h"],
915 visibility = ["//visibility:public"],
916)
917
918cc_library(
919 name = "eps_copy_input_stream",
920 srcs = ["upb/wire/eps_copy_input_stream.c"],
921 hdrs = ["upb/wire/eps_copy_input_stream.h"],
922 visibility = ["//visibility:public"],
923 deps = [
924 ":mem",
925 ":port",
926 ],
927)
928
929cc_library(
930 name = "wire_reader",
Joshua Haberman112f0372022-12-28 11:55:56 -0800931 srcs = [
932 "upb/wire/reader.c",
933 "upb/wire/swap_internal.h",
934 ],
Joshua Haberman75488a02022-12-27 23:04:44 -0800935 hdrs = ["upb/wire/reader.h"],
936 visibility = ["//visibility:public"],
937 deps = [
938 ":eps_copy_input_stream",
939 ":port",
940 ":wire_types",
941 ],
942)
943
Joshua Haberman68d1d912022-12-10 08:50:36 -0800944cc_test(
945 name = "eps_copy_input_stream_test",
946 srcs = ["upb/wire/eps_copy_input_stream_test.cc"],
947 deps = [
Joshua Haberman75488a02022-12-27 23:04:44 -0800948 ":eps_copy_input_stream",
Joshua Habermana48af3f2022-12-27 20:43:42 -0800949 ":upb",
Joshua Haberman68d1d912022-12-10 08:50:36 -0800950 "@com_google_googletest//:gtest_main",
951 ],
952)
953
Protobuf Team Botca08ff52022-06-24 16:32:40 -0700954cc_library(
Eric Salob3cb3fb2022-11-14 09:33:03 -0800955 name = "hash",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700956 srcs = [
Eric Salob3cb3fb2022-11-14 09:33:03 -0800957 "upb/hash/common.c",
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700958 ],
Joshua Habermancb234e62020-10-17 17:48:32 -0700959 hdrs = [
Eric Salob3cb3fb2022-11-14 09:33:03 -0800960 "upb/hash/common.h",
961 "upb/hash/int_table.h",
962 "upb/hash/str_table.h",
Joshua Habermancb234e62020-10-17 17:48:32 -0700963 ],
Protobuf Team Bot15596be2022-06-24 10:38:27 -0700964 copts = UPB_DEFAULT_COPTS,
965 visibility = ["//:__subpackages__"],
Eric Saloff8e1b42022-11-13 20:46:22 -0800966 deps = [
967 ":base",
Eric Salob3cb3fb2022-11-14 09:33:03 -0800968 ":mem",
Eric Saloff8e1b42022-11-13 20:46:22 -0800969 ":port",
970 ],
Joshua Haberman928ef7f2019-03-27 12:52:33 -0700971)
972
Eric Salo410143b2022-07-08 16:27:56 -0700973cc_library(
Eric Salo4d3998b2022-11-16 09:04:06 -0800974 name = "lex",
Eric Salo410143b2022-07-08 16:27:56 -0700975 srcs = [
Eric Salo4d3998b2022-11-16 09:04:06 -0800976 "upb/lex/atoi.c",
977 "upb/lex/round_trip.c",
978 "upb/lex/strtod.c",
979 "upb/lex/unicode.c",
Eric Salo410143b2022-07-08 16:27:56 -0700980 ],
981 hdrs = [
Eric Salo4d3998b2022-11-16 09:04:06 -0800982 "upb/lex/atoi.h",
983 "upb/lex/round_trip.h",
984 "upb/lex/strtod.h",
985 "upb/lex/unicode.h",
Eric Salo410143b2022-07-08 16:27:56 -0700986 ],
987 copts = UPB_DEFAULT_COPTS,
988 visibility = ["//:__subpackages__"],
989 deps = [":port"],
990)
991
Joshua Haberman77371f02019-01-23 16:26:13 -0800992# Amalgamation #################################################################
993
Protobuf Teamb8edc712022-03-16 08:24:52 -0700994# begin:github_only
Joshua Haberman83c0edb2021-02-28 16:56:49 -0800995
Joshua Haberman77371f02019-01-23 16:26:13 -0800996upb_amalgamation(
997 name = "gen_amalgamation",
998 outs = [
999 "upb.c",
1000 "upb.h",
1001 ],
Joshua Haberman77371f02019-01-23 16:26:13 -08001002 libs = [
Eric Saloff8e1b42022-11-13 20:46:22 -08001003 ":base",
Eric Salofd143162022-11-03 17:17:17 -07001004 ":collections_internal",
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001005 ":descriptor_upb_proto",
Joshua Haberman75488a02022-12-27 23:04:44 -08001006 ":eps_copy_input_stream",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001007 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -08001008 ":hash",
Eric Salo4d3998b2022-11-16 09:04:06 -08001009 ":lex",
Eric Salof409c992022-11-03 15:48:59 +00001010 ":mem_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -08001011 ":mini_table_internal",
1012 ":message_accessors",
Eric Salofb7a6742022-11-17 11:45:26 -08001013 ":message_internal",
Anna Rde1bc112020-01-07 15:45:19 -08001014 ":port",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001015 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -07001016 ":reflection_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001017 ":upb",
Eric Saloe1371752022-11-03 16:46:34 +00001018 ":wire_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -08001019 ":wire_reader",
1020 ":wire_types",
Joshua Haberman77371f02019-01-23 16:26:13 -08001021 ],
Mike Kruskal17b64512022-07-13 15:00:01 -07001022 strip_import_prefix = ["src"],
Joshua Haberman77371f02019-01-23 16:26:13 -08001023)
1024
1025cc_library(
1026 name = "amalgamation",
1027 srcs = ["upb.c"],
1028 hdrs = ["upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -07001029 copts = UPB_DEFAULT_COPTS,
Copybara-Service65a329a2022-12-02 13:53:04 -08001030 deps = ["@utf8_range"],
Joshua Haberman77371f02019-01-23 16:26:13 -08001031)
1032
Joshua Haberman16facab2020-05-08 16:40:24 -07001033upb_amalgamation(
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001034 name = "gen_php_amalgamation",
Joshua Haberman16facab2020-05-08 16:40:24 -07001035 outs = [
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001036 "php-upb.c",
1037 "php-upb.h",
Joshua Haberman16facab2020-05-08 16:40:24 -07001038 ],
Joshua Haberman16facab2020-05-08 16:40:24 -07001039 libs = [
Eric Saloff8e1b42022-11-13 20:46:22 -08001040 ":base",
Eric Salofd143162022-11-03 17:17:17 -07001041 ":collections_internal",
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001042 ":descriptor_upb_proto",
1043 ":descriptor_upb_proto_reflection",
Joshua Haberman75488a02022-12-27 23:04:44 -08001044 ":eps_copy_input_stream",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001045 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -08001046 ":hash",
Joshua Haberman16facab2020-05-08 16:40:24 -07001047 ":json",
Eric Salo4d3998b2022-11-16 09:04:06 -08001048 ":lex",
Eric Salof409c992022-11-03 15:48:59 +00001049 ":mem_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -08001050 ":message_accessors",
Eric Salofb7a6742022-11-17 11:45:26 -08001051 ":message_internal",
1052 ":mini_table_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001053 ":port",
1054 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -07001055 ":reflection_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001056 ":upb",
Eric Saloe1371752022-11-03 16:46:34 +00001057 ":wire_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -08001058 ":wire_reader",
1059 ":wire_types",
Joshua Haberman16facab2020-05-08 16:40:24 -07001060 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -07001061 prefix = "php-",
Mike Kruskal17b64512022-07-13 15:00:01 -07001062 strip_import_prefix = ["src"],
Mike Kruskal1fee6d82022-12-05 12:03:38 -08001063 visibility = ["@com_google_protobuf//php:__subpackages__"],
Joshua Haberman16facab2020-05-08 16:40:24 -07001064)
1065
1066cc_library(
Joshua Haberman543a0ce2020-05-26 22:30:50 -07001067 name = "php_amalgamation",
1068 srcs = ["php-upb.c"],
1069 hdrs = ["php-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -07001070 copts = UPB_DEFAULT_COPTS,
Copybara-Service65a329a2022-12-02 13:53:04 -08001071 deps = ["@utf8_range"],
Joshua Haberman16facab2020-05-08 16:40:24 -07001072)
1073
Joshua Habermanefefbff2020-08-03 10:12:31 -07001074upb_amalgamation(
1075 name = "gen_ruby_amalgamation",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001076 outs = [
1077 "ruby-upb.c",
1078 "ruby-upb.h",
1079 ],
Joshua Habermanefefbff2020-08-03 10:12:31 -07001080 libs = [
Eric Saloff8e1b42022-11-13 20:46:22 -08001081 ":base",
Eric Salofd143162022-11-03 17:17:17 -07001082 ":collections_internal",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001083 ":descriptor_upb_proto",
Joshua Haberman75488a02022-12-27 23:04:44 -08001084 ":eps_copy_input_stream",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001085 ":fastdecode",
Eric Salob3cb3fb2022-11-14 09:33:03 -08001086 ":hash",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001087 ":json",
Eric Salo4d3998b2022-11-16 09:04:06 -08001088 ":lex",
Eric Salof409c992022-11-03 15:48:59 +00001089 ":mem_internal",
Eric Salo27d70ed2022-11-16 22:13:41 -08001090 ":message_accessors",
Eric Salofb7a6742022-11-17 11:45:26 -08001091 ":message_internal",
1092 ":mini_table_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001093 ":port",
1094 ":reflection",
Eric Salo44916d72022-10-04 17:22:07 -07001095 ":reflection_internal",
Joshua Habermanfa8b6052022-04-19 13:15:55 -07001096 ":upb",
Eric Saloe1371752022-11-03 16:46:34 +00001097 ":wire_internal",
Joshua Haberman75488a02022-12-27 23:04:44 -08001098 ":wire_reader",
1099 ":wire_types",
Joshua Habermanefefbff2020-08-03 10:12:31 -07001100 ],
Joshua Habermane3f41de2020-10-17 13:15:58 -07001101 prefix = "ruby-",
Mike Kruskal17b64512022-07-13 15:00:01 -07001102 strip_import_prefix = ["src"],
Mike Kruskal1fee6d82022-12-05 12:03:38 -08001103 visibility = ["@com_google_protobuf//ruby:__subpackages__"],
Joshua Habermanefefbff2020-08-03 10:12:31 -07001104)
1105
1106cc_library(
1107 name = "ruby_amalgamation",
1108 srcs = ["ruby-upb.c"],
1109 hdrs = ["ruby-upb.h"],
Joshua Habermane86541a2020-10-28 17:53:09 -07001110 copts = UPB_DEFAULT_COPTS,
Copybara-Service65a329a2022-12-02 13:53:04 -08001111 deps = ["@utf8_range"],
Joshua Habermanefefbff2020-08-03 10:12:31 -07001112)
1113
Joshua Habermane3f41de2020-10-17 13:15:58 -07001114exports_files(
1115 [
Joshua Habermanbfc86d32019-12-04 16:56:40 -08001116 "third_party/lunit/console.lua",
1117 "third_party/lunit/lunit.lua",
1118 ],
Eric Saloa77b9662022-11-07 15:54:10 -08001119 visibility = ["//lua:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -07001120)
1121
Joshua Haberman985145c2019-04-24 17:36:17 +00001122filegroup(
1123 name = "cmake_files",
1124 srcs = glob([
Joshua Haberman985145c2019-04-24 17:36:17 +00001125 "upb/**/*",
Joshua Haberman4f901b62020-10-14 16:32:43 -07001126 "third_party/**/*",
Joshua Haberman9a663562019-05-13 16:13:39 -07001127 ]),
Joshua Habermane3f41de2020-10-17 13:15:58 -07001128 visibility = ["//cmake:__pkg__"],
Josh Haberman01ed4ce2018-11-02 12:49:15 -07001129)
Joshua Haberman83c0edb2021-02-28 16:56:49 -08001130
Copybara-Serviceaaf9e432023-01-13 13:41:03 -08001131
Deanna Garciaf887fe32022-12-31 02:37:52 +00001132pkg_files(
Copybara-Serviceaaf9e432023-01-13 13:41:03 -08001133 name = "upb_source_files",
1134 srcs = glob(
1135 [
1136 "upb/**/*.c",
1137 "upb/**/*.h",
1138 "upb/**/*.hpp",
1139 "upb/**/*.inc",
1140 ],
Eric Salo4843fd02023-01-17 18:50:18 -08001141 exclude = ["upb/**/conformance_upb.c"],
Copybara-Serviceaaf9e432023-01-13 13:41:03 -08001142 ),
1143 strip_prefix = "",
1144 visibility = ["//python/dist:__pkg__"],
Deanna Garciaf887fe32022-12-31 02:37:52 +00001145)
1146
Protobuf Teamb8edc712022-03-16 08:24:52 -07001147# end:github_only
Joshua Haberman4ffeaa62022-06-01 12:25:11 -07001148
1149# begin:google_only
1150#
1151# py_binary(
1152# name = "update_check_runs",
1153# srcs = ["update_check_runs.py"],
1154# main = "update_check_runs.py",
1155# deps = [
1156# "//third_party/py/absl:app",
Mike Kruskale1b11b62022-09-30 13:28:24 -07001157# "//third_party/py/absl/flags",
Joshua Haberman4ffeaa62022-06-01 12:25:11 -07001158# ],
1159# )
1160#
Protobuf Team Botbe98a912022-10-11 12:14:01 -07001161# kt_native_interop_hint(
1162# name = "upb_kotlin_native_hint",
1163# compatible_with = ["//buildenv/target:non_prod"],
1164# headers_to_exclude = glob([
1165# "**/*.hpp",
Eric Salo4f098fd2022-11-23 17:59:55 -08001166# ]),
Protobuf Team Botbe98a912022-10-11 12:14:01 -07001167# no_string_conversion = ["upb_MiniTable_Build"],
1168# strict_enums = ["upb_FieldType"],
1169# )
1170#
1171# kt_native_interop_hint(
1172# name = "suppress_kotlin_interop",
1173# compatible_with = ["//buildenv/target:non_prod"],
1174# suppressed = True,
1175# )
1176#
Joshua Haberman4ffeaa62022-06-01 12:25:11 -07001177# end:google_only