| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406 |
- ################################################################################
- # Protocol Buffers: C++ Runtime and common proto files
- ################################################################################
- load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
- load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
- load("@rules_proto//proto:defs.bzl", "proto_library")
- load("@upb//cmake:build_defs.bzl", "staleness_test")
- load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
- package(
- default_visibility = [
- "//:__pkg__", # "public" targets are alias rules in //.
- "//json:__subpackages__",
- ],
- )
- proto_library(
- name = "any_proto",
- srcs = ["any.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "api_proto",
- srcs = ["api.proto"],
- strip_import_prefix = "/src",
- deps = [
- "//:source_context_proto",
- "//:type_proto",
- ],
- )
- proto_library(
- name = "duration_proto",
- srcs = ["duration.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "empty_proto",
- srcs = ["empty.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "field_mask_proto",
- srcs = ["field_mask.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "source_context_proto",
- srcs = ["source_context.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "struct_proto",
- srcs = ["struct.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "timestamp_proto",
- srcs = ["timestamp.proto"],
- strip_import_prefix = "/src",
- )
- proto_library(
- name = "type_proto",
- srcs = ["type.proto"],
- strip_import_prefix = "/src",
- deps = [
- "//:any_proto",
- "//:source_context_proto",
- ],
- )
- proto_library(
- name = "wrappers_proto",
- srcs = ["wrappers.proto"],
- strip_import_prefix = "/src",
- )
- # Generate code for the well-known types on demand.
- # This needs to be done in a separate genrule because we publish protoc and the
- # C++ runtime with the WKT code linked in. We need to use a stripped down
- # compiler and runtime library to generate them, and cc_proto_library doesn't
- # support swapping out the compiler binary (even though a custom runtime can
- # be passed to proto_lang_toolchain).
- #
- # TODO(b/246826624) We still check in generated pb.h and pb.cc files purely to
- # support CMake builds. These aren't used at all by Bazel and will be removed
- # in the future once CMake can generate them too.
- WELL_KNOWN_TYPES = [
- "any",
- "api",
- "duration",
- "empty",
- "field_mask",
- "source_context",
- "struct",
- "timestamp",
- "type",
- "wrappers",
- ]
- proto_library(
- name = "wkt_proto",
- visibility = ["//visibility:private"],
- deps = [wkt + "_proto" for wkt in WELL_KNOWN_TYPES],
- )
- cc_proto_library(
- name = "wkt_cc_proto",
- visibility = ["//pkg:__pkg__"],
- deps = ["wkt_proto"],
- )
- # When we generate code for the well-known types, we put the resulting files in
- # wkt/google/protobuf and add ./wkt to the include paths below. This is a
- # somewhat strange setup but is necessary to satisfy these two constraints:
- # - We need to keep the checked-in sources for now, since Cocoapods relies on
- # them.
- # - The Bazel build should always use the generated sources so that developers
- # don't have to worry about manually updating the checked-in sources.
- genrule(
- name = "gen_wkt_cc_sources",
- srcs = [wkt + ".proto" for wkt in WELL_KNOWN_TYPES],
- outs =
- ["wkt/google/protobuf/" + wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
- ["wkt/google/protobuf/" + wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
- cmd = """
- $(execpath //:protoc) \
- --cpp_out=dllexport_decl=PROTOBUF_EXPORT:$(RULEDIR)/wkt \
- --proto_path=$$(dirname $$(dirname $$(dirname $(location any.proto)))) \
- $(SRCS)
- """,
- exec_tools = ["//:protoc"],
- visibility = ["//visibility:private"],
- )
- staleness_test(
- name = "well_known_types_staleness_test",
- outs =
- [wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES] +
- [wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
- generated_pattern = "wkt/google/protobuf/%s",
- tags = ["manual"],
- )
- # This is necessary for our generated cmake configs to pick up the checked in
- # WKT files.
- # TODO(b/246826624) Remove this once we generate WKT code from cmake.
- cc_library(
- name = "cmake_wkt_cc_proto",
- srcs = ["wkt/google/protobuf/" + wkt + ".pb.cc" for wkt in WELL_KNOWN_TYPES],
- hdrs = ["wkt/google/protobuf/" + wkt + ".pb.h" for wkt in WELL_KNOWN_TYPES],
- copts = COPTS,
- includes = ["wkt"],
- linkopts = LINK_OPTS,
- visibility = ["//pkg:__pkg__"],
- deps = [":protobuf_nowkt"],
- )
- # Built-in runtime types
- proto_library(
- name = "descriptor_proto",
- srcs = ["descriptor.proto"],
- strip_import_prefix = "/src",
- visibility = [
- "//:__pkg__",
- "//pkg:__pkg__",
- ],
- )
- ################################################################################
- # C++ Runtime Library
- ################################################################################
- cc_library(
- name = "port_def",
- hdrs = [
- "port.h",
- "port_def.inc",
- "port_undef.inc",
- ],
- include_prefix = "google/protobuf",
- visibility = [
- "//:__subpackages__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- "@com_google_absl//absl/meta:type_traits",
- ],
- )
- cc_library(
- name = "arena_align",
- srcs = ["arena_align.cc"],
- hdrs = ["arena_align.h"],
- include_prefix = "google/protobuf",
- visibility = [
- "//:__subpackages__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- "//src/google/protobuf/stubs:lite",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_absl//absl/log:absl_log",
- "@com_google_absl//absl/numeric:bits",
- ],
- )
- cc_library(
- name = "arena_cleanup",
- hdrs = ["arena_cleanup.h"],
- include_prefix = "google/protobuf",
- visibility = [
- "//:__subpackages__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- "@com_google_absl//absl/base:core_headers",
- "@com_google_absl//absl/log:absl_log",
- ],
- )
- cc_library(
- name = "arena_config",
- srcs = ["arena_config.cc"],
- hdrs = ["arena_config.h"],
- include_prefix = "google/protobuf",
- visibility = [
- "//:__subpackages__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- "//src/google/protobuf/stubs:lite",
- ],
- )
- cc_library(
- name = "arena_allocation_policy",
- hdrs = ["arena_allocation_policy.h"],
- include_prefix = "google/protobuf",
- visibility = [
- "//:__subpackages__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- ":arena_config",
- "//src/google/protobuf/stubs:lite",
- ],
- )
- cc_library(
- name = "string_block",
- hdrs = ["string_block.h"],
- include_prefix = "google/protobuf",
- deps = [
- ":arena_align",
- "@com_google_absl//absl/base:core_headers",
- "@com_google_absl//absl/log:absl_check",
- ],
- )
- cc_test(
- name = "string_block_test",
- srcs = ["string_block_test.cc"],
- deps = [
- ":string_block",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_library(
- name = "arena",
- srcs = [
- "arena.cc",
- ],
- hdrs = [
- "arena.h",
- "arena_config.h",
- "arenaz_sampler.h",
- "serial_arena.h",
- "thread_safe_arena.h",
- ],
- include_prefix = "google/protobuf",
- visibility = [
- "//:__subpackages__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- ":arena_align",
- ":arena_allocation_policy",
- ":arena_cleanup",
- ":arena_config",
- ":string_block",
- "//src/google/protobuf/stubs:lite",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_absl//absl/log:absl_log",
- "@com_google_absl//absl/synchronization",
- ],
- )
- cc_library(
- name = "protobuf_lite",
- srcs = [
- "any_lite.cc",
- "arenastring.cc",
- "arenaz_sampler.cc",
- "extension_set.cc",
- "generated_enum_util.cc",
- "generated_message_tctable_lite.cc",
- "generated_message_util.cc",
- "implicit_weak_message.cc",
- "inlined_string_field.cc",
- "map.cc",
- "message_lite.cc",
- "parse_context.cc",
- "repeated_field.cc",
- "repeated_ptr_field.cc",
- "wire_format_lite.cc",
- ],
- hdrs = [
- "any.h",
- "arena.h",
- "arenastring.h",
- "arenaz_sampler.h",
- "endian.h",
- "explicitly_constructed.h",
- "extension_set.h",
- "extension_set_inl.h",
- "generated_enum_util.h",
- "generated_message_tctable_decl.h",
- "generated_message_tctable_impl.h",
- "generated_message_util.h",
- "has_bits.h",
- "implicit_weak_message.h",
- "inlined_string_field.h",
- "map.h",
- "map_entry_lite.h",
- "map_field_lite.h",
- "map_type_handler.h",
- "message_lite.h",
- "metadata_lite.h",
- "parse_context.h",
- "port.h",
- "repeated_field.h",
- "repeated_ptr_field.h",
- "serial_arena.h",
- "thread_safe_arena.h",
- "wire_format_lite.h",
- ],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error",
- ],
- }),
- include_prefix = "google/protobuf",
- linkopts = LINK_OPTS,
- visibility = [
- "//:__pkg__",
- "//pkg:__pkg__",
- "//src/google/protobuf:__subpackages__",
- ],
- # In Bazel 6.0+, these will be `interface_deps`:
- deps = [
- ":arena",
- ":arena_align",
- ":arena_config",
- ":string_block",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs:lite",
- "@com_google_absl//absl/container:btree",
- "@com_google_absl//absl/container:flat_hash_set",
- "@com_google_absl//absl/hash",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_absl//absl/log:absl_log",
- "@com_google_absl//absl/meta:type_traits",
- "@com_google_absl//absl/numeric:bits",
- "@com_google_absl//absl/strings:internal",
- "@com_google_absl//absl/synchronization",
- "@com_google_absl//absl/time",
- "@utf8_range//:utf8_validity",
- ],
- )
- cc_library(
- name = "protobuf_nowkt",
- srcs = [
- "any.cc",
- "descriptor.cc",
- "descriptor.pb.cc",
- "descriptor_database.cc",
- "dynamic_message.cc",
- "extension_set_heavy.cc",
- "generated_message_bases.cc",
- "generated_message_reflection.cc",
- "generated_message_tctable_full.cc",
- "generated_message_tctable_gen.cc",
- "map_field.cc",
- "message.cc",
- "reflection_ops.cc",
- "service.cc",
- "text_format.cc",
- "unknown_field_set.cc",
- "wire_format.cc",
- ],
- hdrs = [
- "descriptor.h",
- "descriptor.pb.h",
- "descriptor_database.h",
- "dynamic_message.h",
- "field_access_listener.h",
- "generated_enum_reflection.h",
- "generated_message_bases.h",
- "generated_message_reflection.h",
- "generated_message_tctable_gen.h",
- "map_entry.h",
- "map_field.h",
- "map_field_inl.h",
- "message.h",
- "metadata.h",
- "reflection.h",
- "reflection_internal.h",
- "reflection_ops.h",
- "service.h",
- "text_format.h",
- "unknown_field_set.h",
- "wire_format.h",
- ],
- copts = COPTS,
- include_prefix = "google/protobuf",
- linkopts = LINK_OPTS,
- visibility = [
- "//:__pkg__",
- "//pkg:__pkg__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- ":protobuf_lite",
- "//src/google/protobuf/io",
- "//src/google/protobuf/io:gzip_stream",
- "//src/google/protobuf/io:printer",
- "//src/google/protobuf/io:tokenizer",
- "//src/google/protobuf/stubs",
- "@com_google_absl//absl/base",
- "@com_google_absl//absl/base:dynamic_annotations",
- "@com_google_absl//absl/container:btree",
- "@com_google_absl//absl/container:flat_hash_map",
- "@com_google_absl//absl/container:flat_hash_set",
- "@com_google_absl//absl/hash",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_absl//absl/log:absl_log",
- "@com_google_absl//absl/strings:internal",
- "@com_google_absl//absl/synchronization",
- "@com_google_absl//absl/time",
- "@utf8_range//:utf8_validity",
- ],
- )
- cc_library(
- name = "protobuf",
- copts = COPTS,
- include_prefix = "google/protobuf",
- linkopts = LINK_OPTS,
- visibility = [
- "//:__pkg__",
- "//pkg:__pkg__",
- "//src/google/protobuf:__subpackages__",
- ],
- deps = [
- ":protobuf_nowkt",
- ":wkt_cc_proto",
- ],
- )
- # This provides just the header files for use in projects that need to build
- # shared libraries for dynamic loading. This target is available until Bazel
- # adds native support for such use cases.
- # TODO(keveman): Remove this target once the support gets added to Bazel.
- cc_library(
- name = "protobuf_headers",
- hdrs = glob([
- "**/*.h",
- "**/*.inc",
- ]),
- )
- filegroup(
- name = "well_known_type_protos",
- srcs = [
- "any.proto",
- "api.proto",
- "duration.proto",
- "empty.proto",
- "field_mask.proto",
- "source_context.proto",
- "struct.proto",
- "timestamp.proto",
- "type.proto",
- "wrappers.proto",
- ],
- visibility = ["//:__subpackages__"],
- )
- filegroup(
- name = "descriptor_proto_srcs",
- srcs = ["descriptor.proto"],
- visibility = ["//:__subpackages__"],
- )
- filegroup(
- name = "testdata",
- srcs = glob(["testdata/**/*"]) + [
- "descriptor.cc",
- ],
- visibility = [
- "//:__subpackages__",
- "@upb//:__subpackages__",
- ],
- )
- filegroup(
- name = "lite_test_proto_srcs",
- srcs = [
- "map_lite_unittest.proto",
- "unittest_import_lite.proto",
- "unittest_import_public_lite.proto",
- "unittest_lite.proto",
- ],
- visibility = ["//:__subpackages__"],
- )
- proto_library(
- name = "lite_test_protos",
- srcs = [":lite_test_proto_srcs"],
- strip_import_prefix = "/src",
- visibility = ["//:__subpackages__"],
- deps = [
- ":any_proto",
- ":api_proto",
- ":descriptor_proto",
- ":duration_proto",
- ":empty_proto",
- ":field_mask_proto",
- ":source_context_proto",
- ":struct_proto",
- ":timestamp_proto",
- ":type_proto",
- ":wrappers_proto",
- ],
- )
- filegroup(
- name = "test_proto_srcs",
- srcs = [
- "any_test.proto",
- "map_proto2_unittest.proto",
- "map_unittest.proto",
- "unittest.proto",
- "unittest_arena.proto",
- "unittest_custom_options.proto",
- "unittest_drop_unknown_fields.proto",
- "unittest_embed_optimize_for.proto",
- "unittest_empty.proto",
- "unittest_enormous_descriptor.proto",
- "unittest_import.proto",
- "unittest_import_public.proto",
- "unittest_lazy_dependencies.proto",
- "unittest_lazy_dependencies_custom_option.proto",
- "unittest_lazy_dependencies_enum.proto",
- "unittest_lite_imports_nonlite.proto",
- "unittest_mset.proto",
- "unittest_mset_wire_format.proto",
- "unittest_no_field_presence.proto",
- "unittest_no_generic_services.proto",
- "unittest_optimize_for.proto",
- "unittest_preserve_unknown_enum.proto",
- "unittest_preserve_unknown_enum2.proto",
- "unittest_proto3.proto",
- "unittest_proto3_arena.proto",
- "unittest_proto3_arena_lite.proto",
- "unittest_proto3_lite.proto",
- "unittest_proto3_optional.proto",
- "unittest_retention.proto",
- "unittest_well_known_types.proto",
- ],
- visibility = ["//:__subpackages__"],
- )
- proto_library(
- name = "test_protos",
- srcs = [":test_proto_srcs"],
- strip_import_prefix = "/src",
- visibility = ["//:__subpackages__"],
- deps = [
- ":any_proto",
- ":api_proto",
- ":descriptor_proto",
- ":duration_proto",
- ":empty_proto",
- ":field_mask_proto",
- ":source_context_proto",
- ":struct_proto",
- ":timestamp_proto",
- ":type_proto",
- ":wrappers_proto",
- ],
- )
- proto_library(
- name = "generic_test_protos",
- srcs = [
- "map_proto2_unittest.proto",
- "map_unittest.proto",
- "unittest.proto",
- "unittest_arena.proto",
- "unittest_custom_options.proto",
- "unittest_drop_unknown_fields.proto",
- "unittest_embed_optimize_for.proto",
- "unittest_empty.proto",
- "unittest_enormous_descriptor.proto",
- "unittest_import.proto",
- "unittest_import_public.proto",
- "unittest_lazy_dependencies.proto",
- "unittest_lazy_dependencies_custom_option.proto",
- "unittest_lazy_dependencies_enum.proto",
- "unittest_lite_imports_nonlite.proto",
- "unittest_mset.proto",
- "unittest_mset_wire_format.proto",
- "unittest_no_field_presence.proto",
- "unittest_no_generic_services.proto",
- "unittest_optimize_for.proto",
- "unittest_preserve_unknown_enum.proto",
- "unittest_preserve_unknown_enum2.proto",
- "unittest_proto3.proto",
- "unittest_proto3_arena.proto",
- "unittest_proto3_arena_lite.proto",
- "unittest_proto3_lite.proto",
- "unittest_proto3_optional.proto",
- "unittest_retention.proto",
- "unittest_well_known_types.proto",
- ],
- strip_import_prefix = "/src",
- visibility = ["//:__subpackages__"],
- deps = [
- ":any_proto",
- ":api_proto",
- ":descriptor_proto",
- ":duration_proto",
- ":empty_proto",
- ":field_mask_proto",
- ":source_context_proto",
- ":struct_proto",
- ":timestamp_proto",
- ":type_proto",
- ":wrappers_proto",
- ],
- )
- exports_files(
- [
- "test_messages_proto2.proto",
- "test_messages_proto3.proto",
- ],
- visibility = [
- "//:__pkg__",
- "//python:__pkg__",
- ],
- )
- proto_library(
- name = "test_messages_proto2_proto",
- srcs = ["test_messages_proto2.proto"],
- strip_import_prefix = "/src",
- visibility = [
- "//:__pkg__",
- "//conformance:__pkg__",
- "@upb//:__subpackages__",
- ],
- )
- proto_library(
- name = "test_messages_proto3_proto",
- srcs = ["test_messages_proto3.proto"],
- strip_import_prefix = "/src",
- visibility = [
- "//:__pkg__",
- "//conformance:__pkg__",
- "@upb//:__subpackages__",
- ],
- deps = [
- ":any_proto",
- ":duration_proto",
- ":field_mask_proto",
- ":struct_proto",
- ":timestamp_proto",
- ":wrappers_proto",
- ],
- )
- cc_proto_library(
- name = "cc_lite_test_protos",
- deps = [":lite_test_protos"],
- )
- cc_proto_library(
- name = "cc_test_protos",
- visibility = ["//src/google/protobuf:__subpackages__"],
- deps = [":test_protos"],
- )
- # Filegroup for golden comparison test:
- filegroup(
- name = "descriptor_cc_srcs",
- testonly = 1,
- data = [
- "descriptor.pb.cc",
- "descriptor.pb.h",
- ],
- visibility = ["//src/google/protobuf/compiler/cpp:__pkg__"],
- )
- cc_library(
- name = "lite_test_util",
- testonly = 1,
- srcs = [
- "arena_test_util.cc",
- "map_lite_test_util.cc",
- "test_util_lite.cc",
- ],
- hdrs = [
- "arena_test_util.h",
- "map_lite_test_util.h",
- "map_test_util_impl.h",
- "proto3_lite_unittest.inc",
- "test_util_lite.h",
- ],
- strip_include_prefix = "/src",
- visibility = ["//:__subpackages__"],
- deps = [
- ":cc_lite_test_protos",
- ":test_util2",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_googletest//:gtest",
- ],
- )
- cc_library(
- name = "test_util",
- testonly = 1,
- srcs = [
- "reflection_tester.cc",
- "test_util.cc",
- ],
- hdrs = [
- "map_test.inc",
- "map_test_util.h",
- "map_test_util.inc",
- "message_unittest.inc",
- "reflection_tester.h",
- "test_util.h",
- "test_util.inc",
- "test_util_lite.h",
- "wire_format_unittest.inc",
- ],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- strip_include_prefix = "/src",
- visibility = ["//:__subpackages__"],
- deps = [
- ":cc_lite_test_protos",
- ":cc_test_protos",
- ":lite_test_util",
- "//src/google/protobuf/testing",
- "@com_google_absl//absl/container:flat_hash_map",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_googletest//:gtest",
- ],
- )
- cc_library(
- name = "test_util2",
- testonly = 1,
- hdrs = ["test_util2.h"],
- strip_include_prefix = "/src",
- textual_hdrs = ["test_util.inc"],
- visibility = ["//:__subpackages__"],
- deps = [
- "//src/google/protobuf/io",
- "//src/google/protobuf/util:differencer",
- "@com_google_googletest//:gtest",
- ],
- )
- cc_test(
- name = "any_test",
- srcs = ["any_test.cc"],
- deps = [
- ":protobuf",
- ":test_util",
- "@com_google_absl//absl/log:absl_check",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "arena_align_test",
- srcs = ["arena_align_test.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":arena_align",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "arena_unittest",
- srcs = ["arena_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":lite_test_util",
- ":protobuf",
- ":test_util",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "arenastring_unittest",
- srcs = ["arenastring_unittest.cc"],
- deps = [
- ":protobuf",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "arenaz_sampler_test",
- srcs = ["arenaz_sampler_test.cc"],
- deps = [
- ":protobuf",
- "//src/google/protobuf/stubs",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "descriptor_database_unittest",
- srcs = ["descriptor_database_unittest.cc"],
- deps = [
- ":protobuf",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "descriptor_unittest",
- srcs = ["descriptor_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "//src/google/protobuf/compiler:importer",
- "//src/google/protobuf/testing",
- "@com_google_absl//absl/log:die_if_null",
- "@com_google_absl//absl/log:scoped_mock_log",
- "@com_google_absl//absl/strings:str_format",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "drop_unknown_fields_test",
- srcs = ["drop_unknown_fields_test.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "dynamic_message_unittest",
- srcs = ["dynamic_message_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "extension_set_unittest",
- srcs = ["extension_set_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- ":test_util2",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "//src/google/protobuf/util:differencer",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "generated_message_reflection_unittest",
- srcs = ["generated_message_reflection_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "generated_message_tctable_lite_test",
- srcs = ["generated_message_tctable_lite_test.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":protobuf_lite",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "inlined_string_field_unittest",
- srcs = ["inlined_string_field_unittest.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "lite_arena_unittest",
- srcs = ["lite_arena_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":lite_test_util",
- ":protobuf",
- ":test_util",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "lite_unittest",
- srcs = ["lite_unittest.cc"],
- deps = [
- ":cc_lite_test_protos",
- ":lite_test_util",
- ":protobuf",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "map_field_test",
- srcs = ["map_field_test.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/stubs",
- "@com_google_absl//absl/container:flat_hash_map",
- "@com_google_absl//absl/strings:str_format",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "map_test",
- timeout = "long",
- srcs = [
- "map_test.cc",
- "map_test.inc",
- ],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- data = [":testdata"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- ":test_util2",
- "//src/google/protobuf/util:differencer",
- "//src/google/protobuf/util:time_util",
- "@com_google_absl//absl/container:flat_hash_map",
- "@com_google_absl//absl/container:flat_hash_set",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "message_unittest",
- srcs = [
- "message_unittest.cc",
- "message_unittest.inc",
- ],
- data = [":testdata"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "//src/google/protobuf/util:differencer",
- "@com_google_absl//absl/log:scoped_mock_log",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "no_field_presence_test",
- srcs = ["no_field_presence_test.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "preserve_unknown_enum_test",
- srcs = ["preserve_unknown_enum_test.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "proto3_arena_lite_unittest",
- srcs = ["proto3_arena_lite_unittest.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "proto3_arena_unittest",
- srcs = ["proto3_arena_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "proto3_lite_unittest",
- srcs = [
- "proto3_lite_unittest.cc",
- "proto3_lite_unittest.inc",
- ],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":lite_test_util",
- ":protobuf",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "reflection_ops_unittest",
- srcs = ["reflection_ops_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "repeated_field_reflection_unittest",
- srcs = ["repeated_field_reflection_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/stubs",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "repeated_field_unittest",
- srcs = ["repeated_field_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "text_format_unittest",
- srcs = ["text_format_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- data = [":testdata"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_absl//absl/log:die_if_null",
- "@com_google_absl//absl/log:scoped_mock_log",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "unknown_field_set_unittest",
- srcs = ["unknown_field_set_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-error=sign-compare",
- ],
- }),
- deps = [
- ":cc_lite_test_protos",
- ":protobuf",
- ":test_util",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_absl//absl/synchronization",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "well_known_types_unittest",
- srcs = ["well_known_types_unittest.cc"],
- copts = COPTS + select({
- "//build_defs:config_msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "wire_format_unittest",
- srcs = [
- "wire_format_unittest.cc",
- "wire_format_unittest.inc",
- ],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- ":test_util",
- ":test_util2",
- "//src/google/protobuf/io",
- "//src/google/protobuf/stubs",
- "//src/google/protobuf/testing",
- "//src/google/protobuf/util:differencer",
- "@com_google_absl//absl/log:scoped_mock_log",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "retention_test",
- srcs = ["retention_test.cc"],
- deps = [
- ":cc_test_protos",
- ":protobuf",
- "//src/google/protobuf/compiler:importer",
- "//src/google/protobuf/compiler:retention",
- "//src/google/protobuf/util:differencer",
- "@com_google_googletest//:gtest_main",
- ],
- )
- ################################################################################
- # Helper targets for Kotlin tests
- ################################################################################
- proto_library(
- name = "kt_unittest_protos",
- srcs = [
- "map_proto2_unittest.proto",
- "unittest.proto",
- "unittest_import.proto",
- "unittest_import_public.proto",
- ],
- strip_import_prefix = "/src",
- visibility = ["//java/kotlin:__pkg__"],
- )
- proto_library(
- name = "kt_proto3_unittest_protos",
- srcs = [
- "unittest_import.proto",
- "unittest_import_public.proto",
- "unittest_proto3.proto",
- ],
- strip_import_prefix = "/src",
- visibility = [
- "//java/kotlin:__pkg__",
- "//java/kotlin-lite:__pkg__",
- ],
- )
- ################################################################################
- # Packaging rules
- ################################################################################
- pkg_files(
- name = "dist_files",
- srcs = glob(["**"]),
- strip_prefix = strip_prefix.from_root(""),
- visibility = ["//src:__pkg__"],
- )
- filegroup(
- name = "full_test_srcs",
- srcs = glob(
- include = [
- "*_test.cc",
- "*unittest.cc",
- ],
- exclude = [
- "lite_unittest.cc",
- "lite_arena_unittest.cc",
- ],
- ),
- visibility = ["//pkg:__pkg__"],
- )
- filegroup(
- name = "lite_test_srcs",
- srcs = [
- "lite_arena_unittest.cc",
- "lite_unittest.cc",
- ],
- visibility = ["//pkg:__pkg__"],
- )
|