[Bazel/C++] Move core C++ implementation to //src/google/protobuf package. (#9988)
This is somewhat of a rough cut, since it doesn't split apart the lite and full targets, or unit tests. However, it does split sources under src/google/protobuf into a separate package, which is a fairly impactful change.pull/9994/head
parent
d2292fc5f6
commit
171a6b1155
25 changed files with 848 additions and 773 deletions
@ -0,0 +1,35 @@ |
||||
################################################################################ |
||||
# Protocol Buffers: C++ Runtime |
||||
################################################################################ |
||||
|
||||
# Most rules are under google/protobuf. This package exists for convenience. |
||||
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") |
||||
|
||||
pkg_files( |
||||
name = "dist_files", |
||||
srcs = glob(["**"]), |
||||
strip_prefix = strip_prefix.from_root(""), |
||||
visibility = ["//src:__pkg__"], |
||||
) |
||||
|
||||
pkg_filegroup( |
||||
name = "all_dist_files", |
||||
srcs = [ |
||||
":dist_files", |
||||
"//src/google/protobuf:dist_files", |
||||
"//src/google/protobuf/compiler:dist_files", |
||||
"//src/google/protobuf/compiler/cpp:dist_files", |
||||
"//src/google/protobuf/compiler/csharp:dist_files", |
||||
"//src/google/protobuf/compiler/java:dist_files", |
||||
"//src/google/protobuf/compiler/objectivec:dist_files", |
||||
"//src/google/protobuf/compiler/php:dist_files", |
||||
"//src/google/protobuf/compiler/python:dist_files", |
||||
"//src/google/protobuf/compiler/ruby:dist_files", |
||||
"//src/google/protobuf/io:dist_files", |
||||
"//src/google/protobuf/stubs:dist_files", |
||||
"//src/google/protobuf/testing:dist_files", |
||||
"//src/google/protobuf/util:dist_files", |
||||
"//src/google/protobuf/util/internal:dist_files", |
||||
], |
||||
visibility = ["//pkg:__pkg__"], |
||||
) |
@ -0,0 +1,577 @@ |
||||
################################################################################ |
||||
# 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("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") |
||||
|
||||
package( |
||||
default_visibility = [ |
||||
"//:__pkg__", # "public" targets are alias rules in //. |
||||
], |
||||
) |
||||
|
||||
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", |
||||
) |
||||
|
||||
# Built-in runtime types |
||||
|
||||
proto_library( |
||||
name = "descriptor_proto", |
||||
srcs = ["descriptor.proto"], |
||||
strip_import_prefix = "/src", |
||||
) |
||||
|
||||
################################################################################ |
||||
# 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__", |
||||
], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "arena", |
||||
srcs = [ |
||||
"arena.cc", |
||||
], |
||||
hdrs = [ |
||||
"arena.h", |
||||
"arena_impl.h", |
||||
"arenaz_sampler.h", |
||||
], |
||||
include_prefix = "google/protobuf", |
||||
visibility = [ |
||||
"//:__subpackages__", |
||||
"//src/google/protobuf:__subpackages__", |
||||
], |
||||
deps = [ |
||||
"//src/google/protobuf/stubs:lite", |
||||
], |
||||
) |
||||
|
||||
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 = glob([ |
||||
"**/*.h", |
||||
"**/*.inc", |
||||
]), |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": [ |
||||
"-Wno-error", |
||||
], |
||||
}), |
||||
include_prefix = "google/protobuf", |
||||
linkopts = LINK_OPTS, |
||||
visibility = [ |
||||
"//:__pkg__", |
||||
"//src/google/protobuf:__subpackages__", |
||||
], |
||||
# In Bazel 6.0+, these will be `interface_deps`: |
||||
deps = [ |
||||
":arena", |
||||
"//src/google/protobuf/io", |
||||
"//src/google/protobuf/stubs:lite", |
||||
], |
||||
) |
||||
|
||||
cc_library( |
||||
name = "protobuf", |
||||
srcs = [ |
||||
"any.cc", |
||||
"any.pb.cc", |
||||
"api.pb.cc", |
||||
"descriptor.cc", |
||||
"descriptor.pb.cc", |
||||
"descriptor_database.cc", |
||||
"duration.pb.cc", |
||||
"dynamic_message.cc", |
||||
"empty.pb.cc", |
||||
"extension_set_heavy.cc", |
||||
"field_mask.pb.cc", |
||||
"generated_message_bases.cc", |
||||
"generated_message_reflection.cc", |
||||
"generated_message_tctable_full.cc", |
||||
"map_field.cc", |
||||
"message.cc", |
||||
"reflection_ops.cc", |
||||
"service.cc", |
||||
"source_context.pb.cc", |
||||
"struct.pb.cc", |
||||
"text_format.cc", |
||||
"timestamp.pb.cc", |
||||
"type.pb.cc", |
||||
"unknown_field_set.cc", |
||||
"wire_format.cc", |
||||
"wrappers.pb.cc", |
||||
], |
||||
hdrs = glob([ |
||||
"**/*.h", |
||||
"**/*.inc", |
||||
]), |
||||
copts = COPTS, |
||||
include_prefix = "google/protobuf", |
||||
linkopts = LINK_OPTS, |
||||
visibility = [ |
||||
"//:__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", |
||||
], |
||||
) |
||||
|
||||
# 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__", |
||||
], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "lite_test_protos", |
||||
srcs = [ |
||||
"map_lite_unittest.proto", |
||||
"unittest_import_lite.proto", |
||||
"unittest_import_public_lite.proto", |
||||
"unittest_lite.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", |
||||
], |
||||
) |
||||
|
||||
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_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_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", |
||||
], |
||||
) |
||||
|
||||
proto_library( |
||||
name = "test_messages_proto2_proto", |
||||
srcs = ["test_messages_proto2.proto"], |
||||
strip_import_prefix = "/src", |
||||
) |
||||
|
||||
proto_library( |
||||
name = "test_messages_proto3_proto", |
||||
srcs = ["test_messages_proto3.proto"], |
||||
strip_import_prefix = "/src", |
||||
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 = "test_util", |
||||
testonly = 1, |
||||
srcs = [ |
||||
"arena_test_util.cc", |
||||
"map_lite_test_util.cc", |
||||
"reflection_tester.cc", |
||||
"test_util.cc", |
||||
"test_util_lite.cc", |
||||
], |
||||
hdrs = [ |
||||
"arena_test_util.h", |
||||
"map_lite_test_util.h", |
||||
"map_test_util.h", |
||||
"map_test_util_impl.h", |
||||
"test_util.h", |
||||
"test_util2.h", |
||||
"test_util_lite.h", |
||||
], |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": [ |
||||
"-Wno-error=sign-compare", |
||||
], |
||||
}), |
||||
strip_include_prefix = "/src", |
||||
textual_hdrs = [ |
||||
"map_test_util.inc", |
||||
"test_util.inc", |
||||
], |
||||
visibility = ["//:__subpackages__"], |
||||
deps = [ |
||||
":cc_lite_test_protos", |
||||
":cc_test_protos", |
||||
"@com_google_googletest//:gtest", |
||||
], |
||||
) |
||||
|
||||
cc_test( |
||||
name = "protobuf_test", |
||||
srcs = [ |
||||
"any_test.cc", |
||||
"arena_unittest.cc", |
||||
"arenastring_unittest.cc", |
||||
"arenaz_sampler_test.cc", |
||||
"descriptor_database_unittest.cc", |
||||
"descriptor_unittest.cc", |
||||
"drop_unknown_fields_test.cc", |
||||
"dynamic_message_unittest.cc", |
||||
"extension_set_unittest.cc", |
||||
"generated_message_reflection_unittest.cc", |
||||
"generated_message_tctable_lite_test.cc", |
||||
"inlined_string_field_unittest.cc", |
||||
"map_field_test.cc", |
||||
"map_test.cc", |
||||
"map_test.inc", |
||||
"message_unittest.cc", |
||||
"message_unittest.inc", |
||||
"no_field_presence_test.cc", |
||||
"preserve_unknown_enum_test.cc", |
||||
"proto3_arena_lite_unittest.cc", |
||||
"proto3_arena_unittest.cc", |
||||
"proto3_lite_unittest.cc", |
||||
"proto3_lite_unittest.inc", |
||||
"reflection_ops_unittest.cc", |
||||
"repeated_field_reflection_unittest.cc", |
||||
"repeated_field_unittest.cc", |
||||
"text_format_unittest.cc", |
||||
"unknown_field_set_unittest.cc", |
||||
"well_known_types_unittest.cc", |
||||
"wire_format_unittest.cc", |
||||
"wire_format_unittest.inc", |
||||
], |
||||
copts = COPTS + select({ |
||||
"//build_defs:config_msvc": [], |
||||
"//conditions:default": [ |
||||
"-Wno-deprecated-declarations", |
||||
"-Wno-error=sign-compare", |
||||
], |
||||
}), |
||||
data = [ |
||||
":testdata", |
||||
] + glob([ |
||||
"**/*", |
||||
]), |
||||
linkopts = LINK_OPTS, |
||||
deps = [ |
||||
":cc_lite_test_protos", |
||||
":cc_test_protos", |
||||
":protobuf", |
||||
":test_util", |
||||
"//src/google/protobuf/testing", |
||||
"@com_google_googletest//:gtest", |
||||
"@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__"], |
||||
) |
Loading…
Reference in new issue