Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1138 lines
39 KiB

# Bazel (https://bazel.build/) BUILD file for Protobuf.
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
load(
":protobuf.bzl",
"adapt_proto_library",
"py_proto_library",
)
licenses(["notice"])
exports_files(["LICENSE"])
################################################################################
# Protobuf Runtime Library
################################################################################
cc_library(
name = "protobuf_lite",
srcs = [
# AUTOGEN(protobuf_lite_srcs)
"src/google/protobuf/any_lite.cc",
"src/google/protobuf/arena.cc",
"src/google/protobuf/arenastring.cc",
"src/google/protobuf/arenaz_sampler.cc",
"src/google/protobuf/extension_set.cc",
"src/google/protobuf/generated_enum_util.cc",
"src/google/protobuf/generated_message_tctable_lite.cc",
"src/google/protobuf/generated_message_util.cc",
"src/google/protobuf/implicit_weak_message.cc",
"src/google/protobuf/inlined_string_field.cc",
"src/google/protobuf/io/coded_stream.cc",
"src/google/protobuf/io/io_win32.cc",
"src/google/protobuf/io/strtod.cc",
"src/google/protobuf/io/zero_copy_stream.cc",
"src/google/protobuf/io/zero_copy_stream_impl.cc",
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
"src/google/protobuf/map.cc",
"src/google/protobuf/message_lite.cc",
"src/google/protobuf/parse_context.cc",
"src/google/protobuf/repeated_field.cc",
"src/google/protobuf/repeated_ptr_field.cc",
"src/google/protobuf/stubs/bytestream.cc",
"src/google/protobuf/stubs/common.cc",
"src/google/protobuf/stubs/int128.cc",
"src/google/protobuf/stubs/status.cc",
"src/google/protobuf/stubs/statusor.cc",
"src/google/protobuf/stubs/stringpiece.cc",
"src/google/protobuf/stubs/stringprintf.cc",
"src/google/protobuf/stubs/structurally_valid.cc",
"src/google/protobuf/stubs/strutil.cc",
"src/google/protobuf/stubs/time.cc",
"src/google/protobuf/wire_format_lite.cc",
],
hdrs = glob([
"src/google/protobuf/**/*.h",
"src/google/protobuf/**/*.inc",
]),
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
)
cc_library(
name = "protobuf",
srcs = [
# AUTOGEN(protobuf_srcs)
"src/google/protobuf/any.cc",
"src/google/protobuf/any.pb.cc",
"src/google/protobuf/api.pb.cc",
"src/google/protobuf/compiler/importer.cc",
"src/google/protobuf/compiler/parser.cc",
"src/google/protobuf/descriptor.cc",
"src/google/protobuf/descriptor.pb.cc",
"src/google/protobuf/descriptor_database.cc",
"src/google/protobuf/duration.pb.cc",
"src/google/protobuf/dynamic_message.cc",
"src/google/protobuf/empty.pb.cc",
"src/google/protobuf/extension_set_heavy.cc",
"src/google/protobuf/field_mask.pb.cc",
"src/google/protobuf/generated_message_bases.cc",
"src/google/protobuf/generated_message_reflection.cc",
"src/google/protobuf/generated_message_tctable_full.cc",
"src/google/protobuf/io/gzip_stream.cc",
"src/google/protobuf/io/printer.cc",
"src/google/protobuf/io/tokenizer.cc",
"src/google/protobuf/map_field.cc",
"src/google/protobuf/message.cc",
"src/google/protobuf/reflection_ops.cc",
"src/google/protobuf/service.cc",
"src/google/protobuf/source_context.pb.cc",
"src/google/protobuf/struct.pb.cc",
"src/google/protobuf/stubs/substitute.cc",
"src/google/protobuf/text_format.cc",
"src/google/protobuf/timestamp.pb.cc",
"src/google/protobuf/type.pb.cc",
"src/google/protobuf/unknown_field_set.cc",
"src/google/protobuf/util/delimited_message_util.cc",
"src/google/protobuf/util/field_comparator.cc",
"src/google/protobuf/util/field_mask_util.cc",
"src/google/protobuf/util/internal/datapiece.cc",
"src/google/protobuf/util/internal/default_value_objectwriter.cc",
"src/google/protobuf/util/internal/error_listener.cc",
"src/google/protobuf/util/internal/field_mask_utility.cc",
"src/google/protobuf/util/internal/json_escaping.cc",
"src/google/protobuf/util/internal/json_objectwriter.cc",
"src/google/protobuf/util/internal/json_stream_parser.cc",
"src/google/protobuf/util/internal/object_writer.cc",
"src/google/protobuf/util/internal/proto_writer.cc",
"src/google/protobuf/util/internal/protostream_objectsource.cc",
"src/google/protobuf/util/internal/protostream_objectwriter.cc",
"src/google/protobuf/util/internal/type_info.cc",
"src/google/protobuf/util/internal/utility.cc",
"src/google/protobuf/util/json_util.cc",
"src/google/protobuf/util/message_differencer.cc",
"src/google/protobuf/util/time_util.cc",
"src/google/protobuf/util/type_resolver_util.cc",
"src/google/protobuf/wire_format.cc",
"src/google/protobuf/wrappers.pb.cc",
],
hdrs = glob([
"src/**/*.h",
"src/**/*.inc",
]),
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protobuf_lite"] + select({
"//build_defs:config_msvc": [],
"//conditions:default": ["@zlib//:zlib"],
}),
)
# 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([
"src/**/*.h",
"src/**/*.inc",
]),
includes = ["src/"],
visibility = ["//visibility:public"],
)
filegroup(
name = "well_known_type_protos",
srcs = [
"src/google/protobuf/any.proto",
"src/google/protobuf/api.proto",
"src/google/protobuf/duration.proto",
"src/google/protobuf/empty.proto",
"src/google/protobuf/field_mask.proto",
"src/google/protobuf/source_context.proto",
"src/google/protobuf/struct.proto",
"src/google/protobuf/timestamp.proto",
"src/google/protobuf/type.proto",
"src/google/protobuf/wrappers.proto",
],
visibility = ["//visibility:public"],
)
filegroup(
name = "built_in_runtime_protos",
srcs = [
"src/google/protobuf/compiler/plugin.proto",
"src/google/protobuf/descriptor.proto",
],
visibility = ["//:__subpackages__"],
)
exports_files(
srcs = [
"src/google/protobuf/any.proto",
"src/google/protobuf/api.proto",
"src/google/protobuf/duration.proto",
"src/google/protobuf/empty.proto",
"src/google/protobuf/field_mask.proto",
"src/google/protobuf/source_context.proto",
"src/google/protobuf/struct.proto",
"src/google/protobuf/timestamp.proto",
"src/google/protobuf/type.proto",
"src/google/protobuf/wrappers.proto",
],
visibility = ["//pkg:__pkg__"],
)
alias(
name = "lite_well_known_protos",
actual = ":well_known_type_protos",
visibility = ["//visibility:public"],
)
adapt_proto_library(
name = "cc_wkt_protos_genproto",
visibility = ["//visibility:public"],
deps = [
"//:any_proto",
"//:api_proto",
"//:compiler_plugin_proto",
"//:descriptor_proto",
"//:duration_proto",
"//:empty_proto",
"//:field_mask_proto",
"//:source_context_proto",
"//:struct_proto",
"//:timestamp_proto",
"//:type_proto",
"//:wrappers_proto",
],
)
cc_library(
name = "cc_wkt_protos",
deprecation = "Only for backward compatibility. Do not use.",
visibility = ["//visibility:public"],
)
################################################################################
# Well Known Types Proto Library Rules
#
# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
################################################################################
# These proto_library rules can be used with one of the language specific proto
# library rules i.e. java_proto_library:
#
# java_proto_library(
# name = "any_java_proto",
# deps = ["@com_google_protobuf//:any_proto],
# )
################################################################################
proto_library(
name = "any_proto",
srcs = ["src/google/protobuf/any.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "api_proto",
srcs = ["src/google/protobuf/api.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//:source_context_proto",
"//:type_proto",
],
)
proto_library(
name = "duration_proto",
srcs = ["//:src/google/protobuf/duration.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "empty_proto",
srcs = ["src/google/protobuf/empty.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "field_mask_proto",
srcs = ["src/google/protobuf/field_mask.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "source_context_proto",
srcs = ["src/google/protobuf/source_context.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "struct_proto",
srcs = ["src/google/protobuf/struct.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "timestamp_proto",
srcs = ["src/google/protobuf/timestamp.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
proto_library(
name = "type_proto",
srcs = ["src/google/protobuf/type.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//:any_proto",
"//:source_context_proto",
],
)
proto_library(
name = "wrappers_proto",
srcs = ["src/google/protobuf/wrappers.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
# Built-in runtime types
proto_library(
name = "compiler_plugin_proto",
srcs = ["src/google/protobuf/compiler/plugin.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
deps = ["//:descriptor_proto"],
)
proto_library(
name = "descriptor_proto",
srcs = ["src/google/protobuf/descriptor.proto"],
strip_import_prefix = "src",
visibility = ["//visibility:public"],
)
################################################################################
# Protocol Buffers Compiler
################################################################################
cc_library(
name = "protoc_lib",
srcs = [
# AUTOGEN(protoc_lib_srcs)
"src/google/protobuf/compiler/code_generator.cc",
"src/google/protobuf/compiler/command_line_interface.cc",
"src/google/protobuf/compiler/cpp/enum.cc",
"src/google/protobuf/compiler/cpp/enum_field.cc",
"src/google/protobuf/compiler/cpp/extension.cc",
"src/google/protobuf/compiler/cpp/field.cc",
"src/google/protobuf/compiler/cpp/file.cc",
"src/google/protobuf/compiler/cpp/generator.cc",
"src/google/protobuf/compiler/cpp/helpers.cc",
"src/google/protobuf/compiler/cpp/map_field.cc",
"src/google/protobuf/compiler/cpp/message.cc",
"src/google/protobuf/compiler/cpp/message_field.cc",
"src/google/protobuf/compiler/cpp/padding_optimizer.cc",
"src/google/protobuf/compiler/cpp/parse_function_generator.cc",
"src/google/protobuf/compiler/cpp/primitive_field.cc",
"src/google/protobuf/compiler/cpp/service.cc",
"src/google/protobuf/compiler/cpp/string_field.cc",
"src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
"src/google/protobuf/compiler/csharp/csharp_enum.cc",
"src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
"src/google/protobuf/compiler/csharp/csharp_field_base.cc",
"src/google/protobuf/compiler/csharp/csharp_generator.cc",
"src/google/protobuf/compiler/csharp/csharp_helpers.cc",
"src/google/protobuf/compiler/csharp/csharp_map_field.cc",
"src/google/protobuf/compiler/csharp/csharp_message.cc",
"src/google/protobuf/compiler/csharp/csharp_message_field.cc",
"src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
"src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
"src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
"src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
"src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
"src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
"src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
"src/google/protobuf/compiler/java/context.cc",
"src/google/protobuf/compiler/java/doc_comment.cc",
"src/google/protobuf/compiler/java/enum.cc",
"src/google/protobuf/compiler/java/enum_field.cc",
"src/google/protobuf/compiler/java/enum_field_lite.cc",
"src/google/protobuf/compiler/java/enum_lite.cc",
"src/google/protobuf/compiler/java/extension.cc",
"src/google/protobuf/compiler/java/extension_lite.cc",
"src/google/protobuf/compiler/java/field.cc",
"src/google/protobuf/compiler/java/file.cc",
"src/google/protobuf/compiler/java/generator.cc",
"src/google/protobuf/compiler/java/generator_factory.cc",
"src/google/protobuf/compiler/java/helpers.cc",
"src/google/protobuf/compiler/java/kotlin_generator.cc",
"src/google/protobuf/compiler/java/map_field.cc",
"src/google/protobuf/compiler/java/map_field_lite.cc",
"src/google/protobuf/compiler/java/message.cc",
"src/google/protobuf/compiler/java/message_builder.cc",
"src/google/protobuf/compiler/java/message_builder_lite.cc",
"src/google/protobuf/compiler/java/message_field.cc",
"src/google/protobuf/compiler/java/message_field_lite.cc",
"src/google/protobuf/compiler/java/message_lite.cc",
"src/google/protobuf/compiler/java/name_resolver.cc",
"src/google/protobuf/compiler/java/primitive_field.cc",
"src/google/protobuf/compiler/java/primitive_field_lite.cc",
"src/google/protobuf/compiler/java/service.cc",
"src/google/protobuf/compiler/java/shared_code_generator.cc",
"src/google/protobuf/compiler/java/string_field.cc",
"src/google/protobuf/compiler/java/string_field_lite.cc",
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
"src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
"src/google/protobuf/compiler/objectivec/objectivec_field.cc",
"src/google/protobuf/compiler/objectivec/objectivec_file.cc",
"src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
"src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
"src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
"src/google/protobuf/compiler/objectivec/objectivec_message.cc",
"src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
"src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
"src/google/protobuf/compiler/php/php_generator.cc",
"src/google/protobuf/compiler/plugin.cc",
"src/google/protobuf/compiler/plugin.pb.cc",
"src/google/protobuf/compiler/python/generator.cc",
"src/google/protobuf/compiler/python/helpers.cc",
"src/google/protobuf/compiler/python/pyi_generator.cc",
"src/google/protobuf/compiler/ruby/ruby_generator.cc",
"src/google/protobuf/compiler/subprocess.cc",
"src/google/protobuf/compiler/zip_writer.cc",
],
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protobuf"],
)
cc_binary(
name = "protoc",
srcs = ["src/google/protobuf/compiler/main.cc"],
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = [":protoc_lib"],
)
################################################################################
# Tests
################################################################################
filegroup(
name = "testdata",
srcs = glob(["src/google/protobuf/testdata/**/*"]),
visibility = [
"//:__subpackages__",
"@upb//:__subpackages__",
],
)
RELATIVE_LITE_TEST_PROTOS = [
# AUTOGEN(lite_test_protos)
"google/protobuf/map_lite_unittest.proto",
"google/protobuf/unittest_import_lite.proto",
"google/protobuf/unittest_import_public_lite.proto",
"google/protobuf/unittest_lite.proto",
]
LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS]
proto_library(
name = "lite_test_protos",
srcs = LITE_TEST_PROTOS,
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",
],
)
RELATIVE_TEST_PROTOS = [
# AUTOGEN(test_protos)
"google/protobuf/any_test.proto",
"google/protobuf/compiler/cpp/test_bad_identifiers.proto",
"google/protobuf/compiler/cpp/test_large_enum_value.proto",
"google/protobuf/map_proto2_unittest.proto",
"google/protobuf/map_unittest.proto",
"google/protobuf/unittest.proto",
"google/protobuf/unittest_arena.proto",
"google/protobuf/unittest_custom_options.proto",
"google/protobuf/unittest_drop_unknown_fields.proto",
"google/protobuf/unittest_embed_optimize_for.proto",
"google/protobuf/unittest_empty.proto",
"google/protobuf/unittest_enormous_descriptor.proto",
"google/protobuf/unittest_import.proto",
"google/protobuf/unittest_import_public.proto",
"google/protobuf/unittest_lazy_dependencies.proto",
"google/protobuf/unittest_lazy_dependencies_custom_option.proto",
"google/protobuf/unittest_lazy_dependencies_enum.proto",
"google/protobuf/unittest_lite_imports_nonlite.proto",
"google/protobuf/unittest_mset.proto",
"google/protobuf/unittest_mset_wire_format.proto",
"google/protobuf/unittest_no_field_presence.proto",
"google/protobuf/unittest_no_generic_services.proto",
"google/protobuf/unittest_optimize_for.proto",
"google/protobuf/unittest_preserve_unknown_enum.proto",
"google/protobuf/unittest_preserve_unknown_enum2.proto",
"google/protobuf/unittest_proto3.proto",
"google/protobuf/unittest_proto3_arena.proto",
"google/protobuf/unittest_proto3_arena_lite.proto",
"google/protobuf/unittest_proto3_lite.proto",
"google/protobuf/unittest_proto3_optional.proto",
"google/protobuf/unittest_well_known_types.proto",
"google/protobuf/util/internal/testdata/anys.proto",
"google/protobuf/util/internal/testdata/books.proto",
"google/protobuf/util/internal/testdata/default_value.proto",
"google/protobuf/util/internal/testdata/default_value_test.proto",
"google/protobuf/util/internal/testdata/field_mask.proto",
"google/protobuf/util/internal/testdata/maps.proto",
"google/protobuf/util/internal/testdata/oneofs.proto",
"google/protobuf/util/internal/testdata/proto3.proto",
"google/protobuf/util/internal/testdata/struct.proto",
"google/protobuf/util/internal/testdata/timestamp_duration.proto",
"google/protobuf/util/internal/testdata/wrappers.proto",
"google/protobuf/util/json_format.proto",
"google/protobuf/util/json_format_proto3.proto",
"google/protobuf/util/message_differencer_unittest.proto",
]
TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS]
filegroup(
name = "test_proto_srcs",
srcs = TEST_PROTOS,
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",
],
)
GENERIC_RELATIVE_TEST_PROTOS = [
"google/protobuf/map_proto2_unittest.proto",
"google/protobuf/map_unittest.proto",
"google/protobuf/unittest.proto",
"google/protobuf/unittest_arena.proto",
"google/protobuf/unittest_custom_options.proto",
"google/protobuf/unittest_drop_unknown_fields.proto",
"google/protobuf/unittest_embed_optimize_for.proto",
"google/protobuf/unittest_empty.proto",
"google/protobuf/unittest_enormous_descriptor.proto",
"google/protobuf/unittest_import.proto",
"google/protobuf/unittest_import_public.proto",
"google/protobuf/unittest_lazy_dependencies.proto",
"google/protobuf/unittest_lazy_dependencies_custom_option.proto",
"google/protobuf/unittest_lazy_dependencies_enum.proto",
"google/protobuf/unittest_lite_imports_nonlite.proto",
"google/protobuf/unittest_mset.proto",
"google/protobuf/unittest_mset_wire_format.proto",
"google/protobuf/unittest_no_field_presence.proto",
"google/protobuf/unittest_no_generic_services.proto",
"google/protobuf/unittest_optimize_for.proto",
"google/protobuf/unittest_preserve_unknown_enum.proto",
"google/protobuf/unittest_preserve_unknown_enum2.proto",
"google/protobuf/unittest_proto3.proto",
"google/protobuf/unittest_proto3_arena.proto",
"google/protobuf/unittest_proto3_arena_lite.proto",
"google/protobuf/unittest_proto3_lite.proto",
"google/protobuf/unittest_proto3_optional.proto",
"google/protobuf/unittest_well_known_types.proto",
]
proto_library(
name = "generic_test_protos",
srcs = ["src/" + s for s in GENERIC_RELATIVE_TEST_PROTOS],
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",
],
)
cc_proto_library(
name = "cc_lite_test_protos",
deps = [":lite_test_protos"],
)
cc_proto_library(
name = "cc_test_protos",
deps = [":test_protos"],
)
COMMON_TEST_SRCS = [
# AUTOGEN(common_test_srcs)
"src/google/protobuf/arena_test_util.cc",
"src/google/protobuf/map_lite_test_util.cc",
"src/google/protobuf/test_util_lite.cc",
"src/google/protobuf/map_test_util.inc",
"src/google/protobuf/reflection_tester.cc",
"src/google/protobuf/test_util.cc",
"src/google/protobuf/test_util.inc",
"src/google/protobuf/testing/file.cc",
"src/google/protobuf/testing/googletest.cc",
]
cc_binary(
name = "test_plugin",
testonly = True,
srcs = [
# AUTOGEN(test_plugin_srcs)
"src/google/protobuf/compiler/mock_code_generator.cc",
"src/google/protobuf/compiler/test_plugin.cc",
"src/google/protobuf/testing/file.cc",
],
deps = [
":protobuf",
":protoc_lib",
"@com_google_googletest//:gtest",
],
)
cc_test(
name = "win32_test",
srcs = ["src/google/protobuf/io/io_win32_unittest.cc"],
tags = [
"manual",
"windows",
],
deps = [
":protobuf_lite",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "protobuf_test",
srcs = COMMON_TEST_SRCS + [
# AUTOGEN(test_srcs)
"src/google/protobuf/any_test.cc",
"src/google/protobuf/arena_unittest.cc",
"src/google/protobuf/arenastring_unittest.cc",
"src/google/protobuf/arenaz_sampler_test.cc",
"src/google/protobuf/compiler/annotation_test_util.cc",
"src/google/protobuf/compiler/command_line_interface_unittest.cc",
"src/google/protobuf/compiler/cpp/bootstrap_unittest.cc",
"src/google/protobuf/compiler/cpp/metadata_test.cc",
"src/google/protobuf/compiler/cpp/move_unittest.cc",
"src/google/protobuf/compiler/cpp/plugin_unittest.cc",
"src/google/protobuf/compiler/cpp/unittest.cc",
"src/google/protobuf/compiler/cpp/unittest.inc",
"src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
"src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
"src/google/protobuf/compiler/importer_unittest.cc",
"src/google/protobuf/compiler/java/doc_comment_unittest.cc",
"src/google/protobuf/compiler/java/plugin_unittest.cc",
"src/google/protobuf/compiler/mock_code_generator.cc",
"src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
"src/google/protobuf/compiler/parser_unittest.cc",
"src/google/protobuf/compiler/python/plugin_unittest.cc",
"src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
"src/google/protobuf/descriptor_database_unittest.cc",
"src/google/protobuf/descriptor_unittest.cc",
"src/google/protobuf/drop_unknown_fields_test.cc",
"src/google/protobuf/dynamic_message_unittest.cc",
"src/google/protobuf/extension_set_unittest.cc",
"src/google/protobuf/generated_message_reflection_unittest.cc",
"src/google/protobuf/generated_message_tctable_lite_test.cc",
"src/google/protobuf/inlined_string_field_unittest.cc",
"src/google/protobuf/io/coded_stream_unittest.cc",
"src/google/protobuf/io/io_win32_unittest.cc",
"src/google/protobuf/io/printer_unittest.cc",
"src/google/protobuf/io/tokenizer_unittest.cc",
"src/google/protobuf/io/zero_copy_stream_unittest.cc",
"src/google/protobuf/map_field_test.cc",
"src/google/protobuf/map_test.cc",
"src/google/protobuf/map_test.inc",
"src/google/protobuf/message_unittest.cc",
"src/google/protobuf/message_unittest.inc",
"src/google/protobuf/no_field_presence_test.cc",
"src/google/protobuf/preserve_unknown_enum_test.cc",
"src/google/protobuf/proto3_arena_lite_unittest.cc",
"src/google/protobuf/proto3_arena_unittest.cc",
"src/google/protobuf/proto3_lite_unittest.cc",
"src/google/protobuf/proto3_lite_unittest.inc",
"src/google/protobuf/reflection_ops_unittest.cc",
"src/google/protobuf/repeated_field_reflection_unittest.cc",
"src/google/protobuf/repeated_field_unittest.cc",
"src/google/protobuf/stubs/bytestream_unittest.cc",
"src/google/protobuf/stubs/common_unittest.cc",
"src/google/protobuf/stubs/int128_unittest.cc",
"src/google/protobuf/stubs/status_test.cc",
"src/google/protobuf/stubs/statusor_test.cc",
"src/google/protobuf/stubs/stringpiece_unittest.cc",
"src/google/protobuf/stubs/stringprintf_unittest.cc",
"src/google/protobuf/stubs/structurally_valid_unittest.cc",
"src/google/protobuf/stubs/strutil_unittest.cc",
"src/google/protobuf/stubs/template_util_unittest.cc",
"src/google/protobuf/stubs/time_test.cc",
"src/google/protobuf/text_format_unittest.cc",
"src/google/protobuf/unknown_field_set_unittest.cc",
"src/google/protobuf/util/delimited_message_util_test.cc",
"src/google/protobuf/util/field_comparator_test.cc",
"src/google/protobuf/util/field_mask_util_test.cc",
"src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
"src/google/protobuf/util/internal/json_objectwriter_test.cc",
"src/google/protobuf/util/internal/json_stream_parser_test.cc",
"src/google/protobuf/util/internal/protostream_objectsource_test.cc",
"src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
"src/google/protobuf/util/internal/type_info_test_helper.cc",
"src/google/protobuf/util/json_util_test.cc",
"src/google/protobuf/util/message_differencer_unittest.cc",
"src/google/protobuf/util/time_util_test.cc",
"src/google/protobuf/util/type_resolver_util_test.cc",
"src/google/protobuf/well_known_types_unittest.cc",
"src/google/protobuf/wire_format_unittest.cc",
"src/google/protobuf/wire_format_unittest.inc",
],
copts = COPTS + select({
"//build_defs:config_msvc": [],
"//conditions:default": [
"-Wno-deprecated-declarations",
],
}),
data = [
# Files for csharp_bootstrap_unittest.cc.
"//conformance:all_files",
":test_plugin",
] + glob([
"src/google/protobuf/**/*",
]) + glob(
[
# Files for csharp_bootstrap_unittest.cc.
"csharp/src/**/*",
],
allow_empty = True,
),
includes = [
"src/",
],
linkopts = LINK_OPTS,
deps = [
":cc_lite_test_protos",
":cc_test_protos",
":protobuf",
":protoc_lib",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
] + select({
"//build_defs:config_msvc": [],
"//conditions:default": ["@zlib//:zlib"],
}),
)
################################################################################
# Java support
################################################################################
alias(
name = "protobuf_java",
actual = "//java/core",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_javalite",
actual = "//java/lite",
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_java_util",
actual = "//java/util",
visibility = ["//visibility:public"],
)
alias(
name = "java_toolchain",
actual = "//java/core:toolchain",
visibility = ["//visibility:public"],
)
alias(
name = "javalite_toolchain",
actual = "//java/lite:toolchain",
visibility = ["//visibility:public"],
)
################################################################################
# Python support
################################################################################
alias(
name = "protobuf_python",
actual = "//python:protobuf_python",
visibility = ["//visibility:public"],
)
alias(
name = "python_srcs",
actual = "//python:python_srcs",
visibility = ["@upb//:__subpackages__"],
)
alias(
name = "python_test_srcs",
actual = "//python:python_test_srcs",
visibility = ["@upb//:__subpackages__"],
)
alias(
name = "well_known_types_py_pb2",
actual = "//python:well_known_types_py_pb2",
visibility = ["@upb//:__subpackages__"],
)
alias(
name = "python_common_test_protos",
actual = "//python:python_common_test_protos",
visibility = ["//visibility:public"],
)
alias(
name = "python_specific_test_protos",
actual = "//python:python_specific_test_protos",
visibility = ["//visibility:public"],
)
proto_lang_toolchain(
name = "cc_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=$(OUT)",
runtime = ":protobuf",
visibility = ["//visibility:public"],
)
alias(
name = "objectivec",
actual = "//objectivec",
tags = ["manual"],
visibility = ["//visibility:public"],
)
alias(
name = "protobuf_objc",
actual = "//objectivec",
tags = ["manual"],
visibility = ["//visibility:public"],
)
################################################################################
# Test generated proto support
################################################################################
genrule(
name = "generated_protos",
srcs = ["src/google/protobuf/unittest_import.proto"],
outs = ["unittest_gen_import.proto"],
cmd = "cat $(SRCS) > $(OUTS)",
)
proto_library(
name = "generated_protos_proto",
srcs = [":generated_protos"],
deps = [":generic_test_protos"],
)
py_proto_library(
name = "generated_protos_py",
srcs = [":generated_protos"],
default_runtime = "",
protoc = ":protoc",
deps = ["//python:python_common_test_protos"],
)
################################################################################
# Conformance tests
################################################################################
alias(
name = "conformance_test_runner",
actual = "//conformance:conformance_test_runner",
visibility = ["//visibility:public"],
)
proto_library(
name = "test_messages_proto2_proto",
strip_import_prefix = "src",
srcs = ["src/google/protobuf/test_messages_proto2.proto"],
visibility = ["//visibility:public"],
)
proto_library(
name = "test_messages_proto3_proto",
strip_import_prefix = "src",
srcs = ["src/google/protobuf/test_messages_proto3.proto"],
visibility = ["//visibility:public"],
deps = [
":any_proto",
":duration_proto",
":field_mask_proto",
":struct_proto",
":timestamp_proto",
":wrappers_proto",
],
)
# TODO: re-enable this test if appropriate, or replace with something that
# uses the new setup.
# sh_test(
# name = "build_files_updated_unittest",
# srcs = [
# "build_files_updated_unittest.sh",
# ],
# data = [
# "BUILD",
# "cmake/extract_includes.bat.in",
# "cmake/libprotobuf.cmake",
# "cmake/libprotobuf-lite.cmake",
# "cmake/libprotoc.cmake",
# "cmake/tests.cmake",
# "src/Makefile.am",
# "update_file_lists.sh",
# ],
# )
java_proto_library(
name = "test_messages_proto2_java_proto",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto2_proto"],
)
java_proto_library(
name = "test_messages_proto3_java_proto",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto3_proto"],
)
java_lite_proto_library(
name = "test_messages_proto2_java_proto_lite",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto2_proto"],
)
java_lite_proto_library(
name = "test_messages_proto3_java_proto_lite",
visibility = [
"//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto3_proto"],
)
filegroup(
name = "bzl_srcs",
srcs = glob(["**/*.bzl"]),
visibility = ["//visibility:public"],
)
# Kotlin proto rules
proto_library(
name = "kt_unittest_lite",
srcs = [
"src/google/protobuf/map_lite_unittest.proto",
"src/google/protobuf/unittest_import_lite.proto",
"src/google/protobuf/unittest_import_public_lite.proto",
"src/google/protobuf/unittest_lite.proto",
],
visibility = ["//java/kotlin-lite:__subpackages__"],
strip_import_prefix = "src",
)
proto_library(
name = "kt_unittest",
srcs = [
"src/google/protobuf/map_proto2_unittest.proto",
"src/google/protobuf/unittest.proto",
"src/google/protobuf/unittest_import.proto",
"src/google/protobuf/unittest_import_public.proto",
],
visibility = ["//java/kotlin:__subpackages__"],
strip_import_prefix = "src",
)
proto_library(
name = "kt_proto3_unittest",
srcs = [
"src/google/protobuf/unittest_import.proto",
"src/google/protobuf/unittest_import_public.proto",
"src/google/protobuf/unittest_proto3.proto",
],
visibility = [
"//java/kotlin:__subpackages__",
"//java/kotlin-lite:__subpackages__",
],
strip_import_prefix = "src",
)
################################################################################
# Packaging rules
################################################################################
# Files included in all source distributions
pkg_files(
name = "common_dist_files",
srcs = glob(
[
"*.bzl",
"cmake/*.cmake",
"cmake/*.in",
"editors/*",
# Several of these files are generated by autogen.sh, so using
# glob() lets us ignore them if they are missing. (This is not good
# practice, though.)
"Makefile.in",
"aclocal.m4",
"ar-lib",
"compile",
"config*",
"depcomp",
"install-sh",
"ltmain.sh",
"m4/*.m4",
"missing",
"protobuf*.pc.in",
"test-driver",
],
allow_empty = True,
) + [
"BUILD.bazel",
"CHANGES.txt",
"CMakeLists.txt",
"CONTRIBUTORS.txt",
"LICENSE",
"Makefile.am",
"README.md",
"WORKSPACE",
"autogen.sh",
"build_files_updated_unittest.sh",
"cmake/CMakeLists.txt",
"cmake/README.md",
"generate_descriptor_proto.sh",
"maven_install.json",
"update_file_lists.sh",
"//third_party:BUILD.bazel",
"//third_party:zlib.BUILD",
"//util/python:BUILD.bazel",
],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
# C++ runtime
pkg_files(
name = "cpp_dist_files",
srcs = glob(
["src/**/*"],
exclude = [
"src/google/protobuf/compiler/objectivec/method_dump.sh", # not in autotools dist
],
),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//pkg:__pkg__"],
)
# Additional files for C#
pkg_files(
name = "csharp_dist_files",
srcs = [
"global.json",
],
visibility = ["//pkg:__pkg__"],
)
# Additional files for ObjC
pkg_files(
name = "objectivec_dist_files",
srcs = [
"Protobuf.podspec",
],
visibility = ["//pkg:__pkg__"],
)