• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2009-2021, Google LLC
2# 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
26load(
27    "//bazel:build_defs.bzl",
28    "UPB_DEFAULT_COPTS",
29    "UPB_DEFAULT_CPPOPTS",
30)
31load(
32    "//bazel:upb_proto_library.bzl",
33    "upb_proto_library",
34    "upb_proto_library_copts",
35    "upb_proto_reflection_library",
36)
37load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
38load(
39    "//upbc:bootstrap_compiler.bzl",
40    "bootstrap_cc_library",
41    "bootstrap_upb_proto_library",
42)
43
44# 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
51# begin:github_only
52load(
53    "//bazel:amalgamation.bzl",
54    "upb_amalgamation",
55)
56load("@rules_pkg//:mappings.bzl", "pkg_files")
57# end:github_only
58
59licenses(["notice"])
60
61exports_files(["LICENSE"])
62
63exports_files(
64    [
65        "BUILD",
66        "WORKSPACE",
67    ],
68    visibility = ["//cmake:__pkg__"],
69)
70
71config_setting(
72    name = "windows",
73    constraint_values = ["@platforms//os:windows"],
74    visibility = ["//visibility:public"],
75)
76
77bool_flag(
78    name = "fasttable_enabled",
79    build_setting_default = False,
80    visibility = ["//visibility:public"],
81)
82
83config_setting(
84    name = "fasttable_enabled_setting",
85    flag_values = {"//:fasttable_enabled": "true"},
86    visibility = ["//visibility:public"],
87)
88
89upb_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
95# Please update copy.bara.sky target = ":friends" if
96# you make changes to this list.
97package_group(
98    name = "friends",
99    packages = [],
100)
101
102# Public C/C++ libraries #######################################################
103
104cc_library(
105    name = "port",
106    hdrs = [
107        "upb/port/atomic.h",
108        "upb/port/vsnprintf_compat.h",
109    ],
110    copts = UPB_DEFAULT_COPTS,
111    textual_hdrs = [
112        "upb/port/def.inc",
113        "upb/port/undef.inc",
114    ],
115    visibility = ["//:__subpackages__"],
116)
117
118cc_library(
119    name = "upb",
120    hdrs = [
121        "upb/alloc.h",
122        "upb/arena.h",
123        "upb/array.h",
124        "upb/base/descriptor_constants.h",
125        "upb/base/status.h",
126        "upb/base/string_view.h",
127        "upb/collections/array.h",
128        "upb/decode.h",
129        "upb/encode.h",
130        "upb/extension_registry.h",
131        "upb/map.h",
132        "upb/mem/alloc.h",
133        "upb/mem/arena.h",
134        "upb/message/extension_internal.h",
135        "upb/message/message.h",
136        "upb/mini_table/extension_registry.h",
137        "upb/msg.h",
138        "upb/status.h",
139        "upb/string_view.h",
140        "upb/upb.h",
141        "upb/upb.hpp",
142        "upb/wire/common.h",
143        "upb/wire/decode.h",
144        "upb/wire/encode.h",
145    ],
146    copts = UPB_DEFAULT_COPTS,
147    visibility = ["//visibility:public"],
148    deps = [
149        ":base",
150        ":collections_internal",
151        ":fastdecode",
152        ":hash",
153        ":lex",
154        ":mem",
155        ":message_internal",
156        ":mini_table_internal",
157        ":port",
158        ":wire",
159    ],
160)
161
162cc_library(
163    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(
179    name = "mini_table",
180    hdrs = [
181        "upb/mini_table.h",
182        "upb/mini_table/decode.h",
183        "upb/mini_table/extension_registry.h",
184        "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",
192        ":port",
193    ],
194)
195
196cc_library(
197    name = "mini_table_internal",
198    srcs = [
199        "upb/mini_table/common.c",
200        "upb/mini_table/decode.c",
201        "upb/mini_table/encode.c",
202        "upb/mini_table/extension_registry.c",
203    ],
204    hdrs = [
205        "upb/mini_table/common.h",
206        "upb/mini_table/common_internal.h",
207        "upb/mini_table/decode.h",
208        "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",
212        "upb/mini_table/extension_registry.h",
213        "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",
218    ],
219    visibility = ["//visibility:public"],
220    deps = [
221        ":base",
222        ":hash",
223        ":mem",
224        ":port",
225    ],
226)
227
228cc_library(
229    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",
257        ":hash",
258        ":mem",
259        ":mini_table_internal",
260        ":port",
261    ],
262)
263
264cc_library(
265    name = "message_accessors",
266    srcs = [
267        "upb/message/accessors.c",
268        "upb/message/accessors_internal.h",
269    ],
270    hdrs = [
271        "upb/message/accessors.h",
272    ],
273    copts = UPB_DEFAULT_COPTS,
274    visibility = ["//visibility:public"],
275    deps = [
276        ":collections_internal",
277        ":eps_copy_input_stream",
278        ":hash",
279        ":message_internal",
280        ":mini_table_internal",
281        ":port",
282        ":upb",
283        ":wire",
284        ":wire_reader",
285    ],
286)
287
288cc_library(
289    name = "message_promote",
290    srcs = [
291        "upb/message/promote.c",
292    ],
293    hdrs = [
294        "upb/message/promote.h",
295    ],
296    copts = UPB_DEFAULT_COPTS,
297    visibility = ["//visibility:public"],
298    deps = [
299        ":collections_internal",
300        ":eps_copy_input_stream",
301        ":hash",
302        ":message_accessors",
303        ":message_internal",
304        ":mini_table_internal",
305        ":port",
306        ":upb",
307        ":wire",
308        ":wire_reader",
309    ],
310)
311
312cc_library(
313    name = "message_copy",
314    srcs = [
315        "upb/message/copy.c",
316    ],
317    hdrs = [
318        "upb/message/copy.h",
319    ],
320    copts = UPB_DEFAULT_COPTS,
321    visibility = ["//visibility:public"],
322    deps = [
323        ":collections_internal",
324        ":message_accessors",
325        ":message_internal",
326        ":mini_table_internal",
327        ":port",
328        ":upb",
329    ],
330)
331
332cc_test(
333    name = "mini_table_encode_test",
334    srcs = [
335        "upb/mini_table/encode_test.cc",
336    ],
337    deps = [
338        ":collections_internal",
339        ":hash",
340        ":message_internal",
341        ":mini_table_internal",
342        ":port",
343        ":upb",
344        "@com_google_absl//absl/container:flat_hash_set",
345        "@com_google_googletest//:gtest_main",
346        "@com_google_protobuf//:protobuf",
347    ],
348)
349
350cc_test(
351    name = "message_accessors_test",
352    srcs = ["upb/message/accessors_test.cc"],
353    deps = [
354        ":collections",
355        ":message_accessors",
356        ":mini_table_internal",
357        ":port",
358        ":upb",
359        "//upb/test:test_messages_proto2_upb_proto",
360        "//upb/test:test_messages_proto3_upb_proto",
361        "//upb/test:test_upb_proto",
362        "@com_google_absl//absl/container:flat_hash_set",
363        "@com_google_googletest//:gtest_main",
364        "@com_google_protobuf//:protobuf",
365    ],
366)
367
368cc_test(
369    name = "message_promote_test",
370    srcs = ["upb/message/promote_test.cc"],
371    deps = [
372        ":collections",
373        ":message_accessors",
374        ":message_promote",
375        ":mini_table_internal",
376        ":port",
377        ":upb",
378        "//upb/test:test_messages_proto2_upb_proto",
379        "//upb/test:test_messages_proto3_upb_proto",
380        "//upb/test:test_upb_proto",
381        "@com_google_absl//absl/container:flat_hash_set",
382        "@com_google_googletest//:gtest_main",
383        "@com_google_protobuf//:protobuf",
384    ],
385)
386
387cc_test(
388    name = "message_copy_test",
389    srcs = ["upb/message/copy_test.cc"],
390    deps = [
391        ":collections",
392        ":message_accessors",
393        ":message_copy",
394        ":mini_table_internal",
395        ":upb",
396        "//upb/test:test_messages_proto2_upb_proto",
397        "//upb/test:test_messages_proto3_upb_proto",
398        "//upb/test:test_upb_proto",
399        "@com_google_absl//absl/container:flat_hash_set",
400        "@com_google_googletest//:gtest_main",
401        "@com_google_protobuf//:protobuf",
402    ],
403)
404
405cc_library(
406    name = "fastdecode",
407    copts = UPB_DEFAULT_COPTS,
408    deps = [
409        ":base",
410        ":collections_internal",
411        ":hash",
412        ":mem_internal",
413        ":message_internal",
414        ":mini_table_internal",
415        ":port",
416        ":wire",
417    ],
418)
419
420# Common support routines used by generated code.  This library has no
421# implementation, but depends on :upb and exposes a few more hdrs.
422#
423# This is public only because we have no way of visibility-limiting it to
424# upb_proto_library() only.  This interface is not stable and by using it you
425# give up any backward compatibility guarantees.
426cc_library(
427    name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
428    hdrs = [
429        "upb/collections/array.h",
430        "upb/collections/array_internal.h",
431        "upb/collections/map_gencode_util.h",
432        "upb/collections/message_value.h",
433        "upb/extension_registry.h",
434        "upb/message/accessors.h",
435        "upb/message/accessors_internal.h",
436        "upb/message/extension_internal.h",
437        "upb/message/internal.h",
438        "upb/message/message.h",
439        "upb/mini_table/common.h",
440        "upb/mini_table/enum_internal.h",
441        "upb/mini_table/extension_internal.h",
442        "upb/mini_table/field_internal.h",
443        "upb/mini_table/file_internal.h",
444        "upb/mini_table/message_internal.h",
445        "upb/mini_table/sub_internal.h",
446        "upb/mini_table/types.h",
447        "upb/port/def.inc",
448        "upb/port/undef.inc",
449        "upb/wire/decode.h",
450        "upb/wire/decode_fast.h",
451        "upb/wire/encode.h",
452    ],
453    copts = UPB_DEFAULT_COPTS,
454    visibility = ["//visibility:public"],
455    deps = [
456        ":base",
457        ":collections_internal",
458        ":hash",
459        ":upb",
460    ],
461)
462
463# Common support code for C++ generated code.
464cc_library(
465    name = "generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
466    hdrs = [
467        "upb/message/copy.h",
468        "upb/message/extension_internal.h",
469        "upb/message/internal.h",
470        "upb/message/message.h",
471        "upb/mini_table/common.h",
472        "upb/mini_table/enum_internal.h",
473        "upb/mini_table/extension_internal.h",
474        "upb/mini_table/field_internal.h",
475        "upb/mini_table/file_internal.h",
476        "upb/mini_table/message_internal.h",
477        "upb/mini_table/sub_internal.h",
478        "upb/mini_table/types.h",
479        "upb/port/def.inc",
480        "upb/port/undef.inc",
481        "upb/upb.hpp",
482        "upb/wire/decode.h",
483        "upb/wire/decode_fast.h",
484        "upb/wire/encode.h",
485    ],
486    copts = UPB_DEFAULT_COPTS,
487    visibility = ["//visibility:public"],
488    deps = [
489        ":base",
490        ":collections_internal",
491        ":hash",
492        ":message_copy",
493        ":mini_table",
494        ":upb",
495    ],
496)
497
498cc_library(
499    name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
500    hdrs = [
501        "upb/port/def.inc",
502        "upb/port/undef.inc",
503        "upb/reflection/def.h",
504        "upb/reflection/def_pool_internal.h",
505    ],
506    copts = UPB_DEFAULT_COPTS,
507    visibility = ["//visibility:public"],
508    deps = [
509        ":base",
510        ":descriptor_upb_proto",
511        ":hash",
512        ":mini_table_internal",
513        ":reflection_internal",
514    ],
515)
516
517bootstrap_upb_proto_library(
518    name = "descriptor_upb_proto",
519    base_dir = "upb/reflection/",
520    google3_src_files = ["net/proto2/proto/descriptor.proto"],
521    google3_src_rules = ["//net/proto2/proto:descriptor_proto_source"],
522    oss_src_files = ["google/protobuf/descriptor.proto"],
523    oss_src_rules = ["@com_google_protobuf//:descriptor_proto_srcs"],
524    oss_strip_prefix = "third_party/protobuf/github/bootstrap/src",
525    proto_lib_deps = ["@com_google_protobuf//:descriptor_proto"],
526    visibility = ["//visibility:public"],
527)
528
529upb_proto_reflection_library(
530    name = "descriptor_upb_proto_reflection",
531    visibility = ["//visibility:public"],
532    deps = ["@com_google_protobuf//:descriptor_proto"],
533)
534
535cc_library(
536    name = "collections",
537    hdrs = [
538        "upb/collections/array.h",
539        "upb/collections/map.h",
540    ],
541    copts = UPB_DEFAULT_COPTS,
542    visibility = ["//visibility:public"],
543    deps = [
544        ":base",
545        ":collections_internal",
546        ":mem",
547        ":port",
548    ],
549)
550
551cc_library(
552    name = "collections_internal",
553    srcs = [
554        "upb/collections/array.c",
555        "upb/collections/map.c",
556        "upb/collections/map_sorter.c",
557    ],
558    hdrs = [
559        "upb/collections/array.h",
560        "upb/collections/array_internal.h",
561        "upb/collections/map.h",
562        "upb/collections/map_gencode_util.h",
563        "upb/collections/map_internal.h",
564        "upb/collections/map_sorter_internal.h",
565        "upb/collections/message_value.h",
566    ],
567    copts = UPB_DEFAULT_COPTS,
568    visibility = ["//:__subpackages__"],
569    deps = [
570        ":base",
571        ":hash",
572        ":mem",
573        ":message_internal",
574        ":mini_table_internal",
575        ":port",
576    ],
577)
578
579# TODO(b/232091617): Once we can delete the deprecated forwarding headers
580# (= everything in upb/) we can move this build target down into reflection/
581bootstrap_cc_library(
582    name = "reflection",
583    hdrs = [
584        "upb/def.h",
585        "upb/def.hpp",
586        "upb/reflection.h",
587        "upb/reflection.hpp",
588        "upb/reflection/def.h",
589        "upb/reflection/def.hpp",
590        "upb/reflection/message.h",
591        "upb/reflection/message.hpp",
592    ],
593    bootstrap_deps = [":reflection_internal"],
594    copts = UPB_DEFAULT_COPTS,
595    visibility = ["//visibility:public"],
596    deps = [
597        ":collections",
598        ":port",
599        ":upb",
600    ],
601)
602
603bootstrap_cc_library(
604    name = "reflection_internal",
605    srcs = [
606        "upb/reflection/def_builder.c",
607        "upb/reflection/def_pool.c",
608        "upb/reflection/def_type.c",
609        "upb/reflection/desc_state.c",
610        "upb/reflection/enum_def.c",
611        "upb/reflection/enum_reserved_range.c",
612        "upb/reflection/enum_value_def.c",
613        "upb/reflection/extension_range.c",
614        "upb/reflection/field_def.c",
615        "upb/reflection/file_def.c",
616        "upb/reflection/message.c",
617        "upb/reflection/message_def.c",
618        "upb/reflection/message_reserved_range.c",
619        "upb/reflection/method_def.c",
620        "upb/reflection/oneof_def.c",
621        "upb/reflection/service_def.c",
622    ],
623    hdrs = [
624        "upb/reflection/common.h",
625        "upb/reflection/def.h",
626        "upb/reflection/def.hpp",
627        "upb/reflection/def_builder_internal.h",
628        "upb/reflection/def_pool.h",
629        "upb/reflection/def_pool_internal.h",
630        "upb/reflection/def_type.h",
631        "upb/reflection/desc_state_internal.h",
632        "upb/reflection/enum_def.h",
633        "upb/reflection/enum_def_internal.h",
634        "upb/reflection/enum_reserved_range.h",
635        "upb/reflection/enum_reserved_range_internal.h",
636        "upb/reflection/enum_value_def.h",
637        "upb/reflection/enum_value_def_internal.h",
638        "upb/reflection/extension_range.h",
639        "upb/reflection/extension_range_internal.h",
640        "upb/reflection/field_def.h",
641        "upb/reflection/field_def_internal.h",
642        "upb/reflection/file_def.h",
643        "upb/reflection/file_def_internal.h",
644        "upb/reflection/message.h",
645        "upb/reflection/message.hpp",
646        "upb/reflection/message_def.h",
647        "upb/reflection/message_def_internal.h",
648        "upb/reflection/message_reserved_range.h",
649        "upb/reflection/message_reserved_range_internal.h",
650        "upb/reflection/method_def.h",
651        "upb/reflection/method_def_internal.h",
652        "upb/reflection/oneof_def.h",
653        "upb/reflection/oneof_def_internal.h",
654        "upb/reflection/service_def.h",
655        "upb/reflection/service_def_internal.h",
656    ],
657    bootstrap_deps = [":descriptor_upb_proto"],
658    copts = UPB_DEFAULT_COPTS,
659    visibility = ["//visibility:public"],
660    deps = [
661        ":collections",
662        ":hash",
663        ":message_accessors",
664        ":mini_table_internal",
665        ":port",
666        ":upb",
667    ],
668)
669
670cc_library(
671    name = "textformat",
672    srcs = [
673        "upb/text/encode.c",
674    ],
675    hdrs = [
676        "upb/text/encode.h",
677        "upb/text_encode.h",
678    ],
679    copts = UPB_DEFAULT_COPTS,
680    visibility = ["//visibility:public"],
681    deps = [
682        ":collections_internal",
683        ":eps_copy_input_stream",
684        ":lex",
685        ":port",
686        ":reflection",
687        ":wire",
688        ":wire_reader",
689        ":wire_types",
690    ],
691)
692
693# TODO(b/232091617): Once we can delete the deprecated forwarding headers
694# (= everything in upb/) we can move this build target down into json/
695cc_library(
696    name = "json",
697    srcs = [
698        "upb/json/decode.c",
699        "upb/json/encode.c",
700    ],
701    hdrs = [
702        "upb/json/decode.h",
703        "upb/json/encode.h",
704        "upb/json_decode.h",
705        "upb/json_encode.h",
706    ],
707    copts = UPB_DEFAULT_COPTS,
708    visibility = ["//visibility:public"],
709    deps = [
710        ":collections",
711        ":lex",
712        ":port",
713        ":reflection",
714        ":upb",
715    ],
716)
717
718# Tests ########################################################################
719
720cc_test(
721    name = "def_builder_test",
722    srcs = [
723        "upb/reflection/common.h",
724        "upb/reflection/def_builder_internal.h",
725        "upb/reflection/def_builder_test.cc",
726        "upb/reflection/def_type.h",
727    ],
728    deps = [
729        ":descriptor_upb_proto",
730        ":hash",
731        ":port",
732        ":reflection",
733        ":reflection_internal",
734        ":upb",
735        "@com_google_absl//absl/strings",
736        "@com_google_googletest//:gtest_main",
737    ],
738)
739
740proto_library(
741    name = "json_test_proto",
742    testonly = 1,
743    srcs = ["upb/json/test.proto"],
744    deps = ["@com_google_protobuf//:struct_proto"],
745)
746
747upb_proto_library(
748    name = "json_test_upb_proto",
749    testonly = 1,
750    deps = [":json_test_proto"],
751)
752
753upb_proto_reflection_library(
754    name = "json_test_upb_proto_reflection",
755    testonly = 1,
756    deps = [":json_test_proto"],
757)
758
759cc_test(
760    name = "json_decode_test",
761    srcs = ["upb/json/decode_test.cc"],
762    deps = [
763        ":json",
764        ":json_test_upb_proto",
765        ":json_test_upb_proto_reflection",
766        ":reflection",
767        ":struct_upb_proto",
768        ":upb",
769        "@com_google_googletest//:gtest_main",
770    ],
771)
772
773cc_test(
774    name = "json_encode_test",
775    srcs = ["upb/json/encode_test.cc"],
776    deps = [
777        ":json",
778        ":json_test_upb_proto",
779        ":json_test_upb_proto_reflection",
780        ":reflection",
781        ":struct_upb_proto",
782        ":upb",
783        "@com_google_googletest//:gtest_main",
784    ],
785)
786
787cc_test(
788    name = "collections_test",
789    srcs = ["upb/collections/test.cc"],
790    deps = [
791        ":collections",
792        ":upb",
793        "@com_google_googletest//:gtest_main",
794    ],
795)
796
797cc_test(
798    name = "message_test",
799    srcs = ["upb/message/test.cc"],
800    deps = [
801        ":json",
802        ":message_test_upb_proto",
803        ":message_test_upb_proto_reflection",
804        ":reflection",
805        ":upb",
806        "//upb/test:fuzz_util",
807        "//upb/test:test_messages_proto3_upb_proto",
808        "@com_google_googletest//:gtest_main",
809    ],
810)
811
812proto_library(
813    name = "message_test_proto",
814    testonly = 1,
815    srcs = ["upb/message/test.proto"],
816    deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"],
817)
818
819upb_proto_library(
820    name = "message_test_upb_proto",
821    testonly = 1,
822    deps = [":message_test_proto"],
823)
824
825upb_proto_reflection_library(
826    name = "message_test_upb_proto_reflection",
827    testonly = 1,
828    deps = [":message_test_proto"],
829)
830
831upb_proto_library(
832    name = "struct_upb_proto",
833    deps = ["@com_google_protobuf//:struct_proto"],
834)
835
836cc_test(
837    name = "atoi_test",
838    srcs = ["upb/lex/atoi_test.cc"],
839    copts = UPB_DEFAULT_CPPOPTS,
840    deps = [
841        ":lex",
842        "@com_google_absl//absl/strings",
843        "@com_google_googletest//:gtest_main",
844    ],
845)
846
847cc_test(
848    name = "hash_test",
849    srcs = ["upb/hash/test.cc"],
850    copts = UPB_DEFAULT_CPPOPTS,
851    deps = [
852        ":hash",
853        ":port",
854        ":upb",
855        "@com_google_googletest//:gtest_main",
856    ],
857)
858
859# Internal C/C++ libraries #####################################################
860
861cc_library(
862    name = "mem",
863    hdrs = [
864        "upb/mem/alloc.h",
865        "upb/mem/arena.h",
866    ],
867    copts = UPB_DEFAULT_COPTS,
868    visibility = ["//:__subpackages__"],
869    deps = [
870        ":mem_internal",
871        ":port",
872    ],
873)
874
875cc_test(
876    name = "arena_test",
877    srcs = ["upb/mem/arena_test.cc"],
878    deps = [
879        ":port",
880        ":upb",
881        "@com_google_absl//absl/random",
882        "@com_google_absl//absl/random:distributions",
883        "@com_google_absl//absl/synchronization",
884        "@com_google_googletest//:gtest_main",
885    ],
886)
887
888cc_library(
889    name = "mem_internal",
890    srcs = [
891        "upb/mem/alloc.c",
892        "upb/mem/arena.c",
893    ],
894    hdrs = [
895        "upb/mem/alloc.h",
896        "upb/mem/arena.h",
897        "upb/mem/arena_internal.h",
898    ],
899    copts = UPB_DEFAULT_COPTS,
900    visibility = ["//:__subpackages__"],
901    deps = [":port"],
902)
903
904cc_library(
905    name = "wire",
906    hdrs = [
907        "upb/wire/decode.h",
908        "upb/wire/encode.h",
909    ],
910    copts = UPB_DEFAULT_COPTS,
911    visibility = ["//visibility:public"],
912    deps = [
913        ":mem",
914        ":message_internal",
915        ":mini_table_internal",
916        ":port",
917        ":wire_internal",
918    ],
919)
920
921cc_library(
922    name = "wire_internal",
923    srcs = [
924        "upb/wire/decode.c",
925        "upb/wire/decode_fast.c",
926        "upb/wire/encode.c",
927    ],
928    hdrs = [
929        "upb/wire/common.h",
930        "upb/wire/common_internal.h",
931        "upb/wire/decode.h",
932        "upb/wire/decode_fast.h",
933        "upb/wire/decode_internal.h",
934        "upb/wire/encode.h",
935        "upb/wire/swap_internal.h",
936    ],
937    copts = UPB_DEFAULT_COPTS,
938    visibility = ["//:__subpackages__"],
939    deps = [
940        ":base",
941        ":collections_internal",
942        ":eps_copy_input_stream",
943        ":hash",
944        ":mem_internal",
945        ":message_internal",
946        ":mini_table_internal",
947        ":port",
948        ":wire_reader",
949        ":wire_types",
950        "@utf8_range",
951    ],
952)
953
954cc_library(
955    name = "wire_types",
956    hdrs = ["upb/wire/types.h"],
957    visibility = ["//visibility:public"],
958)
959
960cc_library(
961    name = "eps_copy_input_stream",
962    srcs = ["upb/wire/eps_copy_input_stream.c"],
963    hdrs = ["upb/wire/eps_copy_input_stream.h"],
964    visibility = ["//visibility:public"],
965    deps = [
966        ":mem",
967        ":port",
968    ],
969)
970
971cc_library(
972    name = "wire_reader",
973    srcs = [
974        "upb/wire/reader.c",
975        "upb/wire/swap_internal.h",
976    ],
977    hdrs = ["upb/wire/reader.h"],
978    visibility = ["//visibility:public"],
979    deps = [
980        ":eps_copy_input_stream",
981        ":port",
982        ":wire_types",
983    ],
984)
985
986cc_test(
987    name = "eps_copy_input_stream_test",
988    srcs = ["upb/wire/eps_copy_input_stream_test.cc"],
989    deps = [
990        ":eps_copy_input_stream",
991        ":upb",
992        "@com_google_googletest//:gtest_main",
993    ],
994)
995
996cc_library(
997    name = "hash",
998    srcs = [
999        "upb/hash/common.c",
1000    ],
1001    hdrs = [
1002        "upb/hash/common.h",
1003        "upb/hash/int_table.h",
1004        "upb/hash/str_table.h",
1005    ],
1006    copts = UPB_DEFAULT_COPTS,
1007    visibility = ["//:__subpackages__"],
1008    deps = [
1009        ":base",
1010        ":mem",
1011        ":port",
1012    ],
1013)
1014
1015cc_library(
1016    name = "lex",
1017    srcs = [
1018        "upb/lex/atoi.c",
1019        "upb/lex/round_trip.c",
1020        "upb/lex/strtod.c",
1021        "upb/lex/unicode.c",
1022    ],
1023    hdrs = [
1024        "upb/lex/atoi.h",
1025        "upb/lex/round_trip.h",
1026        "upb/lex/strtod.h",
1027        "upb/lex/unicode.h",
1028    ],
1029    copts = UPB_DEFAULT_COPTS,
1030    visibility = ["//:__subpackages__"],
1031    deps = [":port"],
1032)
1033
1034# Amalgamation #################################################################
1035
1036# begin:github_only
1037
1038upb_amalgamation(
1039    name = "gen_amalgamation",
1040    outs = [
1041        "upb.c",
1042        "upb.h",
1043    ],
1044    libs = [
1045        ":base",
1046        ":collections_internal",
1047        ":descriptor_upb_proto",
1048        ":eps_copy_input_stream",
1049        ":fastdecode",
1050        ":hash",
1051        ":lex",
1052        ":mem_internal",
1053        ":mini_table_internal",
1054        ":message_accessors",
1055        ":message_internal",
1056        ":port",
1057        ":reflection",
1058        ":reflection_internal",
1059        ":upb",
1060        ":wire_internal",
1061        ":wire_reader",
1062        ":wire_types",
1063    ],
1064    strip_import_prefix = ["src"],
1065)
1066
1067cc_library(
1068    name = "amalgamation",
1069    srcs = ["upb.c"],
1070    hdrs = ["upb.h"],
1071    copts = UPB_DEFAULT_COPTS,
1072    deps = ["@utf8_range"],
1073)
1074
1075upb_amalgamation(
1076    name = "gen_php_amalgamation",
1077    outs = [
1078        "php-upb.c",
1079        "php-upb.h",
1080    ],
1081    libs = [
1082        ":base",
1083        ":collections_internal",
1084        ":descriptor_upb_proto",
1085        ":descriptor_upb_proto_reflection",
1086        ":eps_copy_input_stream",
1087        ":fastdecode",
1088        ":hash",
1089        ":json",
1090        ":lex",
1091        ":mem_internal",
1092        ":message_accessors",
1093        ":message_internal",
1094        ":mini_table_internal",
1095        ":port",
1096        ":reflection",
1097        ":reflection_internal",
1098        ":upb",
1099        ":wire_internal",
1100        ":wire_reader",
1101        ":wire_types",
1102    ],
1103    prefix = "php-",
1104    strip_import_prefix = ["src"],
1105    visibility = ["@com_google_protobuf//php:__subpackages__"],
1106)
1107
1108cc_library(
1109    name = "php_amalgamation",
1110    srcs = ["php-upb.c"],
1111    hdrs = ["php-upb.h"],
1112    copts = UPB_DEFAULT_COPTS,
1113    deps = ["@utf8_range"],
1114)
1115
1116upb_amalgamation(
1117    name = "gen_ruby_amalgamation",
1118    outs = [
1119        "ruby-upb.c",
1120        "ruby-upb.h",
1121    ],
1122    libs = [
1123        ":base",
1124        ":collections_internal",
1125        ":descriptor_upb_proto",
1126        ":eps_copy_input_stream",
1127        ":fastdecode",
1128        ":hash",
1129        ":json",
1130        ":lex",
1131        ":mem_internal",
1132        ":message_accessors",
1133        ":message_internal",
1134        ":mini_table_internal",
1135        ":port",
1136        ":reflection",
1137        ":reflection_internal",
1138        ":upb",
1139        ":wire_internal",
1140        ":wire_reader",
1141        ":wire_types",
1142    ],
1143    prefix = "ruby-",
1144    strip_import_prefix = ["src"],
1145    visibility = ["@com_google_protobuf//ruby:__subpackages__"],
1146)
1147
1148cc_library(
1149    name = "ruby_amalgamation",
1150    srcs = ["ruby-upb.c"],
1151    hdrs = ["ruby-upb.h"],
1152    copts = UPB_DEFAULT_COPTS,
1153    deps = ["@utf8_range"],
1154)
1155
1156exports_files(
1157    [
1158        "third_party/lunit/console.lua",
1159        "third_party/lunit/lunit.lua",
1160    ],
1161    visibility = ["//lua:__pkg__"],
1162)
1163
1164filegroup(
1165    name = "cmake_files",
1166    srcs = glob([
1167        "upb/**/*",
1168        "third_party/**/*",
1169    ]),
1170    visibility = ["//cmake:__pkg__"],
1171)
1172
1173
1174pkg_files(
1175   name = "upb_source_files",
1176   srcs = glob(
1177       [
1178           "upb/**/*.c",
1179           "upb/**/*.h",
1180           "upb/**/*.hpp",
1181           "upb/**/*.inc",
1182      ],
1183       exclude = ["upb/**/conformance_upb.c"],
1184   ),
1185   strip_prefix = "",
1186   visibility = ["//python/dist:__pkg__"],
1187)
1188
1189# end:github_only
1190
1191# begin:google_only
1192#
1193# py_binary(
1194#     name = "update_check_runs",
1195#     srcs = ["update_check_runs.py"],
1196#     main = "update_check_runs.py",
1197#     deps = [
1198#         "//third_party/py/absl:app",
1199#         "//third_party/py/absl/flags",
1200#     ],
1201# )
1202#
1203# kt_native_interop_hint(
1204#     name = "upb_kotlin_native_hint",
1205#     compatible_with = ["//buildenv/target:non_prod"],
1206#     headers_to_exclude = glob([
1207#         "**/*.hpp",
1208#     ]),
1209#     no_string_conversion = ["upb_MiniTable_Build"],
1210#     strict_enums = ["upb_FieldType"],
1211# )
1212#
1213# kt_native_interop_hint(
1214#     name = "suppress_kotlin_interop",
1215#     compatible_with = ["//buildenv/target:non_prod"],
1216#     suppressed = True,
1217# )
1218#
1219# end:google_only
1220