diff --git a/BUILD.bazel b/BUILD.bazel
index cc623aac7..98584b604 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,384 +1,22 @@
# 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_test", "objc_library", native_cc_proto_library = "cc_proto_library")
+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_python//python:defs.bzl", "py_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
-load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
-load(":protobuf_release.bzl", "package_naming")
+load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
+load(":protobuf.bzl", "py_proto_library")
licenses(["notice"])
exports_files(["LICENSE"])
-################################################################################
-# build configuration
-################################################################################
-
-################################################################################
-# ZLIB configuration
-################################################################################
-
-ZLIB_DEPS = ["@zlib//:zlib"]
-
-################################################################################
-# Protobuf Runtime Library
-################################################################################
-
-MSVC_COPTS = [
- "/wd4065", # switch statement contains 'default' but no 'case' labels
- "/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
- "/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
- "/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
- "/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
- "/wd4307", # 'operator' : integral constant overflow
- "/wd4309", # 'conversion' : truncation of constant value
- "/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
- "/wd4355", # 'this' : used in base member initializer list
- "/wd4506", # no definition for inline function 'function'
- "/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
- "/wd4996", # The compiler encountered a deprecated declaration.
-]
-
-COPTS = select({
- ":msvc": MSVC_COPTS,
- "//conditions:default": [
- "-DHAVE_ZLIB",
- "-Woverloaded-virtual",
- "-Wno-sign-compare",
- ],
-})
-
-load(":compiler_config_setting.bzl", "create_compiler_config_setting")
-
-create_compiler_config_setting(
- name = "msvc",
- value = "msvc-cl",
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-# Android NDK builds can specify different crosstool_top flags to choose which
-# STL they use for C++. We need these multiple variants to catch all of those
-# versions of crosstool_top and reliably detect Android.
-#
-# For more info on the various crosstool_tops used by NDK Bazel builds, see:
-# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl
-
-config_setting(
- name = "android",
- values = {
- "crosstool_top": "//external:android/crosstool",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-config_setting(
- name = "android-stlport",
- values = {
- "crosstool_top": "@androidndk//:toolchain-stlport",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-config_setting(
- name = "android-libcpp",
- values = {
- "crosstool_top": "@androidndk//:toolchain-libcpp",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-config_setting(
- name = "android-gnu-libstdcpp",
- values = {
- "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-config_setting(
- name = "android-default",
- values = {
- "crosstool_top": "@androidndk//:default_crosstool",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-# Android and MSVC builds do not need to link in a separate pthread library.
-LINK_OPTS = select({
- ":android": [],
- ":android-stlport": [],
- ":android-libcpp": [],
- ":android-gnu-libstdcpp": [],
- ":android-default": [],
- ":msvc": [
- # Suppress linker warnings about files with no symbols defined.
- "-ignore:4221",
- ],
- "//conditions:default": [
- "-lpthread",
- "-lm",
- ],
-})
-
-load(
- ":protobuf.bzl",
- "adapt_proto_library",
- "cc_proto_library",
- "internal_copied_filegroup",
- "internal_gen_kt_protos",
- "internal_gen_well_known_protos_java",
- "internal_protobuf_py_tests",
- "py_proto_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"],
-)
-
-PROTOBUF_DEPS = select({
- ":msvc": [],
- "//conditions:default": ZLIB_DEPS,
-})
-
-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"] + PROTOBUF_DEPS,
-)
-
-# 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"],
-)
-
-# Map of all well known protos.
-# name => (include path, imports)
-WELL_KNOWN_PROTO_MAP = {
- "any": ("src/google/protobuf/any.proto", []),
- "api": (
- "src/google/protobuf/api.proto",
- [
- "source_context",
- "type",
- ],
- ),
- "compiler_plugin": (
- "src/google/protobuf/compiler/plugin.proto",
- ["descriptor"],
- ),
- "descriptor": ("src/google/protobuf/descriptor.proto", []),
- "duration": ("src/google/protobuf/duration.proto", []),
- "empty": ("src/google/protobuf/empty.proto", []),
- "field_mask": ("src/google/protobuf/field_mask.proto", []),
- "source_context": ("src/google/protobuf/source_context.proto", []),
- "struct": ("src/google/protobuf/struct.proto", []),
- "timestamp": ("src/google/protobuf/timestamp.proto", []),
- "type": (
- "src/google/protobuf/type.proto",
- [
- "any",
- "source_context",
- ],
- ),
- "wrappers": ("src/google/protobuf/wrappers.proto", []),
-}
-
-WELL_KNOWN_PROTOS = [value[0] for value in WELL_KNOWN_PROTO_MAP.values()]
-
-LITE_WELL_KNOWN_PROTO_MAP = {
- "any": ("src/google/protobuf/any.proto", []),
- "api": (
- "src/google/protobuf/api.proto",
- [
- "source_context",
- "type",
- ],
- ),
- "duration": ("src/google/protobuf/duration.proto", []),
- "empty": ("src/google/protobuf/empty.proto", []),
- "field_mask": ("src/google/protobuf/field_mask.proto", []),
- "source_context": ("src/google/protobuf/source_context.proto", []),
- "struct": ("src/google/protobuf/struct.proto", []),
- "timestamp": ("src/google/protobuf/timestamp.proto", []),
- "type": (
- "src/google/protobuf/type.proto",
- [
- "any",
- "source_context",
- ],
- ),
- "wrappers": ("src/google/protobuf/wrappers.proto", []),
-}
-
-LITE_WELL_KNOWN_PROTOS = [value[0] for value in LITE_WELL_KNOWN_PROTO_MAP.values()]
-
-filegroup(
- name = "well_known_protos",
- srcs = WELL_KNOWN_PROTOS,
- visibility = ["//visibility:public"],
-)
-
-exports_files(
- srcs = WELL_KNOWN_PROTOS,
- visibility = ["//pkg:__pkg__"],
-)
-
-filegroup(
- name = "lite_well_known_protos",
- srcs = LITE_WELL_KNOWN_PROTOS,
- visibility = ["//visibility:public"],
-)
-
-adapt_proto_library(
- name = "cc_wkt_protos_genproto",
- visibility = ["//visibility:public"],
- deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
-)
-
-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:
#
@@ -388,477 +26,174 @@ cc_library(
# )
################################################################################
-[proto_library(
- name = proto[0] + "_proto",
- srcs = [proto[1][0]],
- strip_import_prefix = "src",
+alias(
+ name = "any_proto",
+ actual = "//src/google/protobuf:any_proto",
visibility = ["//visibility:public"],
- deps = [dep + "_proto" for dep in proto[1][1]],
-) for proto in WELL_KNOWN_PROTO_MAP.items()]
+)
-[native_cc_proto_library(
- name = proto + "_cc_proto",
- visibility = ["//visibility:private"],
- deps = [proto + "_proto"],
-) for proto in WELL_KNOWN_PROTO_MAP.keys()]
+alias(
+ name = "api_proto",
+ actual = "//src/google/protobuf:api_proto",
+ visibility = ["//visibility:public"],
+)
-cc_proto_blacklist_test(
- name = "cc_proto_blacklist_test",
- tags = [
- # Exclude this target from wildcard expansion (//...). Due to
- # https://github.com/bazelbuild/bazel/issues/10590, this test has to
- # be nominated using the `@com_google_protobuf//` prefix. We do that,
- # e.g., in kokoro/linux/bazel/build.sh.
- # See also https://github.com/protocolbuffers/protobuf/pull/7096.
- "manual",
- ],
- deps = [proto + "_cc_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
+alias(
+ name = "duration_proto",
+ actual = "//src/google/protobuf:duration_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "empty_proto",
+ actual = "//src/google/protobuf:empty_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "field_mask_proto",
+ actual = "//src/google/protobuf:field_mask_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "source_context_proto",
+ actual = "//src/google/protobuf:source_context_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "struct_proto",
+ actual = "//src/google/protobuf:struct_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "timestamp_proto",
+ actual = "//src/google/protobuf:timestamp_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "type_proto",
+ actual = "//src/google/protobuf:type_proto",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "wrappers_proto",
+ actual = "//src/google/protobuf:wrappers_proto",
+ visibility = ["//visibility:public"],
+)
+
+# Source files: these are aliases to a filegroup, not a `proto_library`.
+#
+# (This is _probably_ not what you want.)
+alias(
+ name = "lite_well_known_protos",
+ actual = "//src/google/protobuf:well_known_type_protos", # filegroup
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "well_known_type_protos",
+ actual = "//src/google/protobuf:well_known_type_protos", # filegroup
+ visibility = ["//visibility:public"],
+)
+
+# Built-in runtime protos: these are part of protobuf's internal
+# implementation, but are not Well-Known Types.
+
+alias(
+ name = "descriptor_proto",
+ actual = "//src/google/protobuf:descriptor_proto", # proto_library
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "descriptor_proto_srcs",
+ actual = "//src/google/protobuf:descriptor_proto_srcs", # filegroup
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "compiler_plugin_proto",
+ actual = "//src/google/protobuf/compiler:plugin_proto", # proto_library
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "cc_wkt_protos",
+ deprecation = "Only for backward compatibility. Do not use.",
+ 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"],
+ deps = ["//src/google/protobuf/compiler:protoc_lib"],
)
################################################################################
-# Tests
+# C++ runtime
################################################################################
-filegroup(
- name = "testdata",
- srcs = glob(["src/google/protobuf/testdata/**/*"]),
- visibility = [
- "//:__subpackages__",
- "@upb//:__subpackages__",
- ],
+# The "lite" runtime works for .proto files that specify the option:
+# optimize_for = LITE_RUNTIME;
+#
+# The lite runtime does not include the `Reflection` APIs (including
+# `Descriptor` and related types) or Well-Known Types.
+#
+# See also:
+# https://developers.google.com/protocol-buffers/docs/reference/cpp-generated#message
+# https://developers.google.com/protocol-buffers/docs/reference/google.protobuf
+alias(
+ name = "protobuf_lite",
+ actual = "//src/google/protobuf:protobuf_lite",
+ visibility = ["//visibility:public"],
)
-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]
-
-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]
-
-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",
-]
-
-GENERIC_TEST_PROTOS = ["src/" + s for s in GENERIC_RELATIVE_TEST_PROTOS]
-
-proto_library(
- name = "generic_test_protos",
- srcs = LITE_TEST_PROTOS + GENERIC_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_test_protos",
- srcs = LITE_TEST_PROTOS + TEST_PROTOS,
- include = "src",
- default_runtime = ":protobuf",
- protoc = ":protoc",
- deps = [":cc_wkt_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",
- ] + select({
- "//conditions:default": [
- # AUTOGEN(non_msvc_test_srcs)
- ],
- ":msvc": [],
- }),
- copts = COPTS + select({
- ":msvc": [],
- "//conditions:default": [
- "-Wno-deprecated-declarations",
- ],
- }),
- data = [
- ":test_plugin",
- ] + glob([
- "src/google/protobuf/**/*",
- # Files for csharp_bootstrap_unittest.cc.
- "conformance/**/*",
- ]) + glob(
- [
- # Files for csharp_bootstrap_unittest.cc.
- "csharp/src/**/*",
- ],
- allow_empty = True,
- ),
- includes = [
- "src/",
- ],
+cc_library(
+ name = "protobuf",
+ hdrs = glob([
+ "src/**/*.h",
+ "src/**/*.inc",
+ ]),
+ copts = COPTS,
+ include_prefix = "google/protobuf/io",
linkopts = LINK_OPTS,
+ visibility = ["//visibility:public"],
deps = [
- ":cc_test_protos",
- ":protobuf",
- ":protoc_lib",
- "@com_google_googletest//:gtest",
- "@com_google_googletest//:gtest_main",
- ] + PROTOBUF_DEPS,
+ "//src/google/protobuf",
+ "//src/google/protobuf/compiler:importer",
+ "//src/google/protobuf/util:delimited_message_util",
+ "//src/google/protobuf/util:differencer",
+ "//src/google/protobuf/util:field_mask_util",
+ "//src/google/protobuf/util:json_util",
+ "//src/google/protobuf/util:time_util",
+ "//src/google/protobuf/util:type_resolver_util",
+ ],
+)
+
+# 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.
+alias(
+ name = "protobuf_headers",
+ actual = "//src/google/protobuf:protobuf_headers",
+ visibility = ["//visibility:public"],
)
################################################################################
# Java support
################################################################################
-internal_gen_well_known_protos_java(
- name = "gen_well_known_protos_java",
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
-)
-
-internal_gen_well_known_protos_java(
- name = "gen_well_known_protos_javalite",
- javalite = True,
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [proto + "_proto" for proto in LITE_WELL_KNOWN_PROTO_MAP.keys()],
-)
-
-internal_gen_kt_protos(
- name = "gen_well_known_protos_kotlin",
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
-)
-
-internal_gen_kt_protos(
- name = "gen_well_known_protos_kotlinlite",
- lite = True,
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [proto + "_proto" for proto in LITE_WELL_KNOWN_PROTO_MAP.keys()],
-)
-
alias(
name = "protobuf_java",
actual = "//java/core",
@@ -893,247 +228,58 @@ alias(
# Python support
################################################################################
-py_library(
- name = "python_srcs",
- srcs = glob(
- [
- "python/google/protobuf/**/*.py",
- ],
- ),
- imports = ["python"],
- srcs_version = "PY2AND3",
- visibility = ["@upb//:__subpackages__"],
-)
-
-py_library(
- name = "python_test_srcs",
- srcs = glob(
- [
- "python/google/protobuf/internal/*_test.py",
- "python/google/protobuf/internal/test_util.py",
- ],
- ),
- imports = ["python"],
- srcs_version = "PY3",
- visibility = ["@upb//:__subpackages__"],
-)
-
-cc_binary(
- name = "python/google/protobuf/internal/_api_implementation.so",
- srcs = ["python/google/protobuf/internal/api_implementation.cc"],
- copts = COPTS + [
- "-DPYTHON_PROTO2_CPP_IMPL_V2",
- ],
- linkshared = 1,
- linkstatic = 1,
- tags = [
- # Exclude this target from wildcard expansion (//...) because it may
- # not even be buildable. It will be built if it is needed according
- # to :use_fast_cpp_protos.
- # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
- "manual",
- ],
- deps = select({
- "//conditions:default": [],
- ":use_fast_cpp_protos": ["//external:python_headers"],
- }),
-)
-
-cc_binary(
- name = "python/google/protobuf/pyext/_message.so",
- srcs = glob([
- "python/google/protobuf/pyext/*.cc",
- "python/google/protobuf/pyext/*.h",
- ]),
- copts = COPTS + [
- "-DGOOGLE_PROTOBUF_HAS_ONEOF=1",
- ] + select({
- "//conditions:default": [],
- ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"],
- }),
- includes = [
- "python/",
- "src/",
- ],
- linkshared = 1,
- linkstatic = 1,
- tags = [
- # Exclude this target from wildcard expansion (//...) because it may
- # not even be buildable. It will be built if it is needed according
- # to :use_fast_cpp_protos.
- # https://docs.bazel.build/versions/master/be/common-definitions.html#common-attributes
- "manual",
- ],
- deps = [
- ":protobuf",
- ":proto_api",
- ] + select({
- "//conditions:default": [],
- ":use_fast_cpp_protos": ["//external:python_headers"],
- }),
-)
-
-config_setting(
- name = "use_fast_cpp_protos",
- values = {
- "define": "use_fast_cpp_protos=true",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-config_setting(
- name = "allow_oversize_protos",
- values = {
- "define": "allow_oversize_protos=true",
- },
- visibility = [
- # Public, but Protobuf only visibility.
- "//:__subpackages__",
- ],
-)
-
-# Copy the builtin proto files from src/google/protobuf to
-# python/google/protobuf. This way, the generated Python sources will be in the
-# same directory as the Python runtime sources. This is necessary for the
-# modules to be imported correctly since they are all part of the same Python
-# package.
-internal_copied_filegroup(
- name = "protos_python",
- srcs = WELL_KNOWN_PROTOS,
- dest = "python",
- strip_prefix = "src",
-)
-
-# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
-# which case we can simply add :protos_python in srcs.
-COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS]
-
-py_proto_library(
- name = "well_known_types_py_pb2",
- srcs = COPIED_WELL_KNOWN_PROTOS,
- include = "python",
- default_runtime = "",
- protoc = ":protoc",
- srcs_version = "PY2AND3",
- visibility = ["@upb//:__subpackages__"],
-)
-
-py_library(
+alias(
name = "protobuf_python",
- data = select({
- "//conditions:default": [],
- ":use_fast_cpp_protos": [
- ":python/google/protobuf/internal/_api_implementation.so",
- ":python/google/protobuf/pyext/_message.so",
- ],
- }),
- deps = [
- ":python_srcs",
- ":well_known_types_py_pb2",
- ],
+ actual = "//python:protobuf_python",
+ visibility = ["//visibility:public"],
)
-# Copy the test proto files from src/google/protobuf to
-# python/google/protobuf. This way, the generated Python sources will be in the
-# same directory as the Python runtime sources. This is necessary for the
-# modules to be imported correctly by the tests since they are all part of the
-# same Python package.
-internal_copied_filegroup(
- name = "protos_python_test",
- srcs = LITE_TEST_PROTOS + TEST_PROTOS,
- dest = "python",
- strip_prefix = "src",
+alias(
+ name = "python_srcs",
+ actual = "//python:python_srcs",
+ visibility = ["@upb//:__subpackages__"],
)
-# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
-# which case we can simply add :protos_python_test in srcs.
-COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
+alias(
+ name = "python_test_srcs",
+ actual = "//python:python_test_srcs",
+ visibility = ["@upb//:__subpackages__"],
+)
-COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
+alias(
+ name = "well_known_types_py_pb2",
+ actual = "//python:well_known_types_py_pb2",
+ visibility = ["@upb//:__subpackages__"],
+)
-py_proto_library(
+alias(
name = "python_common_test_protos",
- srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
- include = "python",
- default_runtime = "",
- protoc = ":protoc",
- srcs_version = "PY2AND3",
+ actual = "//python:python_common_test_protos",
visibility = ["//visibility:public"],
- deps = [":well_known_types_py_pb2"],
)
-py_proto_library(
+alias(
name = "python_specific_test_protos",
- srcs = glob([
- "python/google/protobuf/internal/*.proto",
- "python/google/protobuf/internal/import_test_package/*.proto",
- ]),
- include = "python",
- default_runtime = ":protobuf_python",
- protoc = ":protoc",
- srcs_version = "PY2AND3",
+ actual = "//python:python_specific_test_protos",
visibility = ["//visibility:public"],
- deps = [":python_common_test_protos"],
-)
-
-py_library(
- name = "python_tests",
- srcs = glob(
- [
- "python/google/protobuf/internal/*_test.py",
- "python/google/protobuf/internal/test_util.py",
- "python/google/protobuf/internal/import_test_package/__init__.py",
- ],
- ),
- imports = ["python"],
- srcs_version = "PY2AND3",
- deps = [
- ":protobuf_python",
- ":python_common_test_protos",
- ":python_specific_test_protos",
- ],
-)
-
-internal_protobuf_py_tests(
- name = "python_tests_batch",
- data = glob([
- "src/google/protobuf/**/*",
- ]),
- modules = [
- "descriptor_database_test",
- "descriptor_pool_test",
- "descriptor_test",
- "generator_test",
- "json_format_test",
- "message_factory_test",
- "message_test",
- "proto_builder_test",
- "reflection_test",
- "service_reflection_test",
- "symbol_database_test",
- "text_encoding_test",
- "text_format_test",
- "unknown_fields_test",
- "wire_format_test",
- ],
- deps = [":python_tests"],
-)
-
-cc_library(
- name = "proto_api",
- hdrs = ["python/google/protobuf/proto_api.h"],
- visibility = ["//visibility:public"],
- deps = [
- "//external:python_headers",
- ],
)
proto_lang_toolchain(
name = "cc_toolchain",
- blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()],
+ 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"],
@@ -1154,137 +300,73 @@ alias(
)
################################################################################
-# Test generated proto support
+# Test protos
################################################################################
+alias(
+ name = "lite_test_protos",
+ actual = "//src/google/protobuf:lite_test_protos", # proto_library
+ visibility = ["//:__subpackages__"],
+)
+
+alias(
+ name = "test_proto_srcs",
+ actual = "//src/google/protobuf:test_proto_srcs", # filegroup
+ visibility = ["//:__subpackages__"],
+)
+
+alias(
+ name = "test_protos",
+ actual = "//src/google/protobuf:test_protos", # proto_library
+ visibility = ["//:__subpackages__"],
+)
+
+# Validate generated proto source inputs:
+
genrule(
name = "generated_protos",
- srcs = ["src/google/protobuf/unittest_import.proto"],
+ testonly = 1,
+ srcs = ["//src/google/protobuf:test_proto_srcs"],
outs = ["unittest_gen_import.proto"],
- cmd = "cat $(SRCS) | sed 's|google/|src/google/|' > $(OUTS)",
+ cmd = "cat src/google/protobuf/unittest_import.proto > $@",
)
proto_library(
name = "generated_protos_proto",
- srcs = [
- "src/google/protobuf/unittest_import_public.proto",
- "unittest_gen_import.proto",
- ],
+ testonly = 1,
+ srcs = [":generated_protos"],
+ deps = ["//src/google/protobuf:generic_test_protos"],
)
py_proto_library(
name = "generated_protos_py",
- srcs = [
- "src/google/protobuf/unittest_import_public.proto",
- "unittest_gen_import.proto",
- ],
+ testonly = 1,
+ srcs = [":generated_protos"],
default_runtime = "",
protoc = ":protoc",
+ deps = ["//python:python_common_test_protos"],
)
################################################################################
# Conformance tests
################################################################################
-proto_library(
- name = "test_messages_proto2_proto",
- srcs = ["src/google/protobuf/test_messages_proto2.proto"],
- visibility = ["//visibility:public"],
-)
-
-proto_library(
- name = "test_messages_proto3_proto",
- 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",
- ],
-)
-
-cc_proto_library(
- name = "test_messages_proto2_proto_cc",
- srcs = ["src/google/protobuf/test_messages_proto2.proto"],
-)
-
-cc_proto_library(
- name = "test_messages_proto3_proto_cc",
- srcs = ["src/google/protobuf/test_messages_proto3.proto"],
- deps = [
- ":cc_wkt_protos",
- ],
-)
-
-proto_library(
- name = "conformance_proto",
- srcs = ["conformance/conformance.proto"],
- visibility = ["//visibility:public"],
-)
-
-cc_proto_library(
- name = "conformance_proto_cc",
- srcs = ["conformance/conformance.proto"],
-)
-
-cc_library(
- name = "jsoncpp",
- srcs = ["conformance/third_party/jsoncpp/jsoncpp.cpp"],
- hdrs = ["conformance/third_party/jsoncpp/json.h"],
- includes = ["conformance"],
-)
-
-cc_library(
- name = "conformance_test",
- srcs = [
- "conformance/conformance_test.cc",
- "conformance/conformance_test_runner.cc",
- ],
- hdrs = [
- "conformance/conformance_test.h",
- ],
- includes = [
- "conformance",
- "src",
- ],
- deps = [":conformance_proto_cc"],
-)
-
-cc_library(
- name = "binary_json_conformance_suite",
- srcs = ["conformance/binary_json_conformance_suite.cc"],
- hdrs = ["conformance/binary_json_conformance_suite.h"],
- deps = [
- ":conformance_test",
- ":jsoncpp",
- ":test_messages_proto2_proto_cc",
- ":test_messages_proto3_proto_cc",
- ],
-)
-
-cc_library(
- name = "text_format_conformance_suite",
- srcs = ["conformance/text_format_conformance_suite.cc"],
- hdrs = ["conformance/text_format_conformance_suite.h"],
- deps = [
- ":conformance_test",
- ":test_messages_proto2_proto_cc",
- ":test_messages_proto3_proto_cc",
- ],
-)
-
-cc_binary(
+alias(
name = "conformance_test_runner",
- srcs = ["conformance/conformance_test_main.cc"],
+ actual = "//conformance:conformance_test_runner",
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "test_messages_proto2_proto",
+ actual = "//src/google/protobuf:test_messages_proto2_proto", # proto_library
+ visibility = ["//visibility:public"],
+)
+
+alias(
+ name = "test_messages_proto3_proto",
+ actual = "//src/google/protobuf:test_messages_proto3_proto", # proto_library
visibility = ["//visibility:public"],
- deps = [
- ":binary_json_conformance_suite",
- ":conformance_test",
- ":text_format_conformance_suite",
- ],
)
# TODO: re-enable this test if appropriate, or replace with something that
@@ -1306,21 +388,10 @@ cc_binary(
# ],
# )
-java_proto_library(
- name = "java_test_protos",
- visibility = ["//java:__subpackages__"],
- deps = [":generic_test_protos"],
-)
-
-java_lite_proto_library(
- name = "java_lite_test_protos",
- visibility = ["//java:__subpackages__"],
- deps = [":generic_test_protos"],
-)
-
java_proto_library(
name = "test_messages_proto2_java_proto",
visibility = [
+ "//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto2_proto"],
@@ -1329,149 +400,36 @@ java_proto_library(
java_proto_library(
name = "test_messages_proto3_java_proto",
visibility = [
+ "//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto3_proto"],
)
-java_proto_library(
- name = "conformance_java_proto",
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [":conformance_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 = "conformance_java_proto_lite",
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [":conformance_proto"],
-)
-
java_lite_proto_library(
name = "test_messages_proto3_java_proto_lite",
visibility = [
+ "//conformance:__pkg__",
"//java:__subpackages__",
],
deps = [":test_messages_proto3_proto"],
)
-java_binary(
- name = "conformance_java",
- srcs = ["conformance/ConformanceJava.java"],
- main_class = "ConformanceJava",
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [
- ":conformance_java_proto",
- ":test_messages_proto2_java_proto",
- ":test_messages_proto3_java_proto",
- "//:protobuf_java",
- "//:protobuf_java_util",
- ],
-)
-
-java_binary(
- name = "conformance_java_lite",
- srcs = ["conformance/ConformanceJavaLite.java"],
- main_class = "ConformanceJavaLite",
- visibility = [
- "//java:__subpackages__",
- ],
- deps = [
- ":conformance_java_proto_lite",
- ":test_messages_proto2_java_proto_lite",
- ":test_messages_proto3_java_proto_lite",
- "//:protobuf_java_util",
- "//:protobuf_javalite",
- ],
-)
-
-exports_files([
- "conformance/conformance_test_runner.sh",
- "conformance/failure_list_java.txt",
- "conformance/failure_list_java_lite.txt",
- "conformance/text_format_failure_list_java.txt",
- "conformance/text_format_failure_list_java_lite.txt",
-])
-
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",
- ],
- strip_import_prefix = "src",
-)
-
-internal_gen_kt_protos(
- name = "gen_kotlin_unittest_lite",
- lite = True,
- visibility = ["//java:__subpackages__"],
- deps = [":kt_unittest_lite"],
-)
-
-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",
- ],
- strip_import_prefix = "src",
-)
-
-internal_gen_kt_protos(
- name = "gen_kotlin_unittest",
- visibility = ["//java:__subpackages__"],
- deps = [":kt_unittest"],
-)
-
-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",
- ],
- strip_import_prefix = "src",
-)
-
-internal_gen_kt_protos(
- name = "gen_kotlin_proto3_unittest_lite",
- lite = True,
- visibility = ["//java:__subpackages__"],
- deps = [":kt_proto3_unittest"],
-)
-
-internal_gen_kt_protos(
- name = "gen_kotlin_proto3_unittest",
- visibility = ["//java:__subpackages__"],
- deps = [":kt_proto3_unittest"],
-)
-
################################################################################
# Packaging rules
################################################################################
@@ -1519,6 +477,7 @@ pkg_files(
"generate_descriptor_proto.sh",
"maven_install.json",
"update_file_lists.sh",
+ "//third_party:BUILD.bazel",
"//third_party:zlib.BUILD",
"//util/python:BUILD.bazel",
],
@@ -1526,39 +485,6 @@ pkg_files(
visibility = ["//pkg:__pkg__"],
)
-# Conformance tests
-pkg_files(
- name = "conformance_dist_files",
- srcs = glob(
- ["conformance/**/*"],
- exclude = [
- # The following are not in autotools dist:
- "conformance/autoload.php",
- "conformance/conformance_nodejs.js",
- "conformance/conformance_test_runner.sh",
- "conformance/failure_list_java_lite.txt",
- "conformance/failure_list_jruby.txt",
- "conformance/text_format_failure_list_*.txt",
- "conformance/update_failure_list.py",
- ],
- ),
- 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",
@@ -1576,29 +502,3 @@ pkg_files(
],
visibility = ["//pkg:__pkg__"],
)
-
-# Python runtime
-pkg_files(
- name = "python_dist_files",
- srcs = glob([
- "python/google/**/*.proto",
- "python/google/**/*.py",
- "python/google/protobuf/internal/*.cc",
- "python/google/protobuf/pyext/*.cc",
- "python/google/protobuf/pyext/*.h",
- ]) + [
- "python/MANIFEST.in",
- "python/README.md",
- "python/google/protobuf/proto_api.h",
- "python/google/protobuf/pyext/README",
- "python/google/protobuf/python_protobuf.h",
- "python/mox.py",
- "python/release.sh",
- "python/setup.cfg",
- "python/setup.py",
- "python/stubout.py",
- "python/tox.ini",
- ],
- strip_prefix = strip_prefix.from_root(""),
- visibility = ["//pkg:__pkg__"],
-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 4ef9bdbac..3c6bc3510 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,34 +1,66 @@
-Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
-
- PHP
- * Fix building packaged PHP extension (#9727)
- * Fixed composer.json to only advertise compatibility with PHP 7.0+. (#9819)
-
- Ruby
- * Disable the aarch64 build on macOS until it can be fixed. (#9816)
-
- Other
- * Fix versioning issues in 3.20.0
+2022-05-10 version 21.0-rc1 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
C++
+ * Rename main cmake/CMakeLists.txt to CMakeLists.txt (#9603)
+ * avoid allocating memory if all extension are cleared (#9345)
+ * cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
+ * Escape GetObject macro inside protoc-generated code (#9739)
+ * Update CMake configuration to add a dependency on Abseil (#9793)
+ * Use __constinit only in GCC 12.2 and up (#9936)
* Refactor generated message class layout
* Optimize tokenizer ParseInteger by removing division
* Reserve exactly the right amount of capacity in ExtensionSet::MergeFrom
* Parse FLT_MAX correctly when represented in JSON
+ Java
+ * Update protobuf_version.bzl to separate protoc and per-language java … (#9900)
+ * 6x speedup in ArrayEncoder.writeUInt32NotTag
+
+ Python
+ * Increment python major version to 4 in version.json for python upb (#9926)
+ * The C extension module for Python has been rewritten to use the upb library.
+ This is expected to deliver significant performance benefits, especially when
+ parsing large payloads. There are some minor breaking changes, but these
+ should not impact most users. For more information see:
+ https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
+ * Due to the breaking changes for Python, the major version number for Python
+ has been incremented.
+ * The binary wheel for macOS now supports Apple silicon.
+
+
+ PHP
+ * chore: [PHP] fix phpdoc for MapField keys (#9536)
+ * [PHP] Remove unnecessary zval initialization (#9600)
+ * [PHP] fix PHP build system (#9571)
+ * Fix building packaged PHP extension (#9727)
+ * fix: reserve "ReadOnly" keyword for PHP 8.1 and add compatibility (#9633)
+ * fix: phpdoc syntax for repeatedfield parameters (#9784)
+ * fix: phpdoc for repeatedfield (#9783)
+ * Change enum string name for reserved words (#9780)
+ * Fixed composer.json to only advertise compatibility with PHP 7.0+. (#9819)
+
+ Ruby
+ * Allow pre-compiled binaries for ruby 3.1.0 (#9566)
+ * Implement `respond_to?` in RubyMessage (#9677)
+ * [Ruby] Fix RepeatedField#last, #first inconsistencies (#9722)
+ * Do not use range based UTF-8 validation in truffleruby (#9769)
+ * Improve range handling logic of `RepeatedField` (#9799)
+ * Disable the aarch64 build on macOS until it can be fixed. (#9816)
+
+ Other
+ * [Kotlin] remove redundant public modifiers for compiled code (#9642)
+ * [C#] Update GetExtension to support getting typed value (#9655)
+ * Fix invalid dependency manifest when using `descriptor_set_out` (#9647)
+ * Fix C# generator handling of a field named "none" in a oneof (#9636)
+ * Add initial version.json file for 21-dev (#9840)
+ * Remove duplicate java generated code (#9909)
+ * Fix versioning issues in 3.20.0
+
Compiler
* Protoc outputs the list of suggested field numbers when invalid field
numbers are specified in the .proto file.
* Require package names to be less than 512 bytes in length
- Java
- * 6x speedup in ArrayEncoder.writeUInt32NotTag
-
- Python
- * Added UnknownFieldSet(message) for pure Python. The old
- message.UnknownFields() will be deprecated after UnknownFieldSet(message) is
- added for cpp extension.
-
2022-04-21 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
PHP
diff --git a/Makefile.am b/Makefile.am
index 98d45b613..7f064294b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -993,6 +993,7 @@ php_EXTRA_DIST= \
# Note: please keep this in sync with the python_dist_files rule in BUILD.bazel.
python_EXTRA_DIST= \
+ python/BUILD.bazel \
python/MANIFEST.in \
python/google/__init__.py \
python/google/protobuf/__init__.py \
@@ -1107,6 +1108,7 @@ python_EXTRA_DIST= \
python/google/protobuf/text_format.py \
python/google/protobuf/unknown_fields.py \
python/google/protobuf/util/__init__.py \
+ python/internal.bzl \
python/release.sh \
python/mox.py \
python/setup.cfg \
@@ -1205,15 +1207,20 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
BUILD.bazel \
WORKSPACE \
CMakeLists.txt \
- cmake/abseil-cpp.cmake \
+ build_defs/BUILD.bazel \
+ build_defs/cc_proto_blacklist_test.bzl \
+ build_defs/compiler_config_setting.bzl \
+ build_defs/cpp_opts.bzl \
+ build_files_updated_unittest.sh \
cmake/CMakeLists.txt \
cmake/README.md \
+ cmake/abseil-cpp.cmake \
cmake/conformance.cmake \
cmake/examples.cmake \
cmake/extract_includes.bat.in \
cmake/install.cmake \
- cmake/libprotobuf.cmake \
cmake/libprotobuf-lite.cmake \
+ cmake/libprotobuf.cmake \
cmake/libprotoc.cmake \
cmake/protobuf-config-version.cmake.in \
cmake/protobuf-config.cmake.in \
@@ -1224,9 +1231,6 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
cmake/protoc.cmake \
cmake/tests.cmake \
cmake/version.rc.in \
- compiler_config_setting.bzl \
- build_files_updated_unittest.sh \
- cc_proto_blacklist_test.bzl \
csharp/BUILD.bazel \
editors/README.txt \
editors/proto.vim \
@@ -1252,7 +1256,8 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
examples/list_people.dart \
examples/list_people.py \
examples/pubspec.yaml \
- internal.bzl \
+ conformance/BUILD.bazel \
+ conformance/defs.bzl \
maven_install.json \
php/BUILD.bazel \
protobuf.bzl \
diff --git a/Protobuf-C++.podspec b/Protobuf-C++.podspec
index 780445961..9d8815a8c 100644
--- a/Protobuf-C++.podspec
+++ b/Protobuf-C++.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Protobuf-C++'
- s.version = '3.20.1'
+ s.version = '3.21.0-rc1'
s.summary = 'Protocol Buffers v3 runtime library for C++.'
s.homepage = 'https://github.com/google/protobuf'
s.license = 'BSD-3-Clause'
diff --git a/Protobuf.podspec b/Protobuf.podspec
index 3a5132d09..37d7fc9a9 100644
--- a/Protobuf.podspec
+++ b/Protobuf.podspec
@@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
- s.version = '3.20.1'
+ s.version = '3.21.0-rc1'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause'
diff --git a/benchmarks/BUILD.bazel b/benchmarks/BUILD.bazel
index 83b2c7ee5..36f6283f6 100644
--- a/benchmarks/BUILD.bazel
+++ b/benchmarks/BUILD.bazel
@@ -75,7 +75,6 @@ pkg_files(
],
exclude = [
"__init__.py", # not in autotools dist
- "BUILD.bazel",
"go/*",
],
),
diff --git a/benchmarks/cpp/BUILD.bazel b/benchmarks/cpp/BUILD.bazel
index ba93f641e..7a3d3ba63 100644
--- a/benchmarks/cpp/BUILD.bazel
+++ b/benchmarks/cpp/BUILD.bazel
@@ -17,7 +17,10 @@ cc_binary(
pkg_files(
name = "dist_files",
- srcs = ["cpp_benchmark.cc"],
+ srcs = [
+ "BUILD.bazel",
+ "cpp_benchmark.cc",
+ ],
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)
diff --git a/benchmarks/datasets/google_message1/proto2/BUILD.bazel b/benchmarks/datasets/google_message1/proto2/BUILD.bazel
index e3159327b..30caed574 100644
--- a/benchmarks/datasets/google_message1/proto2/BUILD.bazel
+++ b/benchmarks/datasets/google_message1/proto2/BUILD.bazel
@@ -46,7 +46,7 @@ java_proto_library(
pkg_files(
name = "dist_files",
- srcs = glob(["*.proto"]),
+ srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)
diff --git a/benchmarks/datasets/google_message1/proto3/BUILD.bazel b/benchmarks/datasets/google_message1/proto3/BUILD.bazel
index 2628d020a..0dc59d144 100644
--- a/benchmarks/datasets/google_message1/proto3/BUILD.bazel
+++ b/benchmarks/datasets/google_message1/proto3/BUILD.bazel
@@ -46,7 +46,7 @@ java_proto_library(
pkg_files(
name = "dist_files",
- srcs = glob(["*.proto"]),
+ srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)
diff --git a/benchmarks/datasets/google_message2/BUILD.bazel b/benchmarks/datasets/google_message2/BUILD.bazel
index a3208d08c..f3d66a25c 100644
--- a/benchmarks/datasets/google_message2/BUILD.bazel
+++ b/benchmarks/datasets/google_message2/BUILD.bazel
@@ -46,7 +46,7 @@ java_proto_library(
pkg_files(
name = "dist_files",
- srcs = glob(["*.proto"]),
+ srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)
diff --git a/benchmarks/datasets/google_message3/BUILD.bazel b/benchmarks/datasets/google_message3/BUILD.bazel
index 130c8749b..a729e50fb 100644
--- a/benchmarks/datasets/google_message3/BUILD.bazel
+++ b/benchmarks/datasets/google_message3/BUILD.bazel
@@ -52,7 +52,7 @@ java_proto_library(
pkg_files(
name = "dist_files",
- srcs = glob(["*.proto"]),
+ srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)
diff --git a/benchmarks/datasets/google_message4/BUILD.bazel b/benchmarks/datasets/google_message4/BUILD.bazel
index 9c7190d93..33de09378 100644
--- a/benchmarks/datasets/google_message4/BUILD.bazel
+++ b/benchmarks/datasets/google_message4/BUILD.bazel
@@ -47,7 +47,7 @@ java_proto_library(
pkg_files(
name = "dist_files",
- srcs = glob(["*.proto"]),
+ srcs = glob(["*"]),
strip_prefix = strip_prefix.from_root(""),
visibility = ["//benchmarks:__pkg__"],
)
diff --git a/build_defs/BUILD.bazel b/build_defs/BUILD.bazel
new file mode 100644
index 000000000..29a1f1256
--- /dev/null
+++ b/build_defs/BUILD.bazel
@@ -0,0 +1,159 @@
+# Internal Starlark definitions for Protobuf.
+
+load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
+load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
+load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
+load(":compiler_config_setting.bzl", "create_compiler_config_setting")
+
+package(
+ default_visibility = [
+ # Public, but Protobuf only visibility.
+ "//:__subpackages__",
+ ],
+)
+
+create_compiler_config_setting(
+ name = "config_msvc",
+ value = "msvc-cl",
+)
+
+# Android NDK builds can specify different crosstool_top flags to choose which
+# STL they use for C++. We need these multiple variants to catch all of those
+# versions of crosstool_top and reliably detect Android.
+#
+# For more info on the various crosstool_tops used by NDK Bazel builds, see:
+# https://docs.bazel.build/versions/master/android-ndk.html#configuring-the-stl
+
+config_setting(
+ name = "config_android",
+ values = {
+ "crosstool_top": "//external:android/crosstool",
+ },
+)
+
+config_setting(
+ name = "config_android-stlport",
+ values = {
+ "crosstool_top": "@androidndk//:toolchain-stlport",
+ },
+)
+
+config_setting(
+ name = "config_android-libcpp",
+ values = {
+ "crosstool_top": "@androidndk//:toolchain-libcpp",
+ },
+)
+
+config_setting(
+ name = "config_android-gnu-libstdcpp",
+ values = {
+ "crosstool_top": "@androidndk//:toolchain-gnu-libstdcpp",
+ },
+)
+
+config_setting(
+ name = "config_android-default",
+ values = {
+ "crosstool_top": "@androidndk//:default_crosstool",
+ },
+)
+
+# Internal testing:
+
+starlark_cc_proto_library(
+ name = "any_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:any_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "api_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:api_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "compiler_plugin_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:compiler_plugin_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "descriptor_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:descriptor_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "duration_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:duration_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "empty_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:empty_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "field_mask_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:field_mask_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "source_context_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:source_context_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "struct_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:struct_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "timestamp_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:timestamp_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "type_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:type_proto"],
+)
+
+starlark_cc_proto_library(
+ name = "wrappers_cc_proto",
+ visibility = ["//visibility:private"],
+ deps = ["//:wrappers_proto"],
+)
+
+cc_proto_blacklist_test(
+ name = "cc_proto_blacklist_test",
+ deps = [
+ ":any_cc_proto",
+ ":api_cc_proto",
+ ":compiler_plugin_cc_proto",
+ ":descriptor_cc_proto",
+ ":duration_cc_proto",
+ ":empty_cc_proto",
+ ":field_mask_cc_proto",
+ ":source_context_cc_proto",
+ ":struct_cc_proto",
+ ":timestamp_cc_proto",
+ ":type_cc_proto",
+ ":wrappers_cc_proto",
+ ],
+)
+
+pkg_files(
+ name = "dist_files",
+ srcs = glob(["*"]),
+ strip_prefix = strip_prefix.from_root(""),
+ visibility = ["//pkg:__pkg__"],
+)
diff --git a/cc_proto_blacklist_test.bzl b/build_defs/cc_proto_blacklist_test.bzl
similarity index 92%
rename from cc_proto_blacklist_test.bzl
rename to build_defs/cc_proto_blacklist_test.bzl
index df54293cb..260abdef4 100644
--- a/cc_proto_blacklist_test.bzl
+++ b/build_defs/cc_proto_blacklist_test.bzl
@@ -14,14 +14,14 @@ def _cc_proto_blacklist_test_impl(ctx):
env = unittest.begin(ctx)
for dep in ctx.attr.deps:
- files = len(dep.files.to_list())
+ files = dep.files.to_list()
asserts.equals(
env,
- 0,
+ [],
files,
"Expected that target '{}' does not provide files, got {}".format(
dep.label,
- files,
+ len(files),
),
)
diff --git a/compiler_config_setting.bzl b/build_defs/compiler_config_setting.bzl
similarity index 100%
rename from compiler_config_setting.bzl
rename to build_defs/compiler_config_setting.bzl
diff --git a/build_defs/cpp_opts.bzl b/build_defs/cpp_opts.bzl
new file mode 100644
index 000000000..f868c4ae5
--- /dev/null
+++ b/build_defs/cpp_opts.bzl
@@ -0,0 +1,40 @@
+# C++ compile/link options for Protobuf.
+
+COPTS = select({
+ "//build_defs:config_msvc": [
+ "/wd4065", # switch statement contains 'default' but no 'case' labels
+ "/wd4244", # 'conversion' conversion from 'type1' to 'type2', possible loss of data
+ "/wd4251", # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
+ "/wd4267", # 'var' : conversion from 'size_t' to 'type', possible loss of data
+ "/wd4305", # 'identifier' : truncation from 'type1' to 'type2'
+ "/wd4307", # 'operator' : integral constant overflow
+ "/wd4309", # 'conversion' : truncation of constant value
+ "/wd4334", # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
+ "/wd4355", # 'this' : used in base member initializer list
+ "/wd4506", # no definition for inline function 'function'
+ "/wd4800", # 'type' : forcing value to bool 'true' or 'false' (performance warning)
+ "/wd4996", # The compiler encountered a deprecated declaration.
+ ],
+ "//conditions:default": [
+ "-DHAVE_ZLIB",
+ "-Woverloaded-virtual",
+ "-Wno-sign-compare",
+ ],
+})
+
+# Android and MSVC builds do not need to link in a separate pthread library.
+LINK_OPTS = select({
+ "//build_defs:config_android": [],
+ "//build_defs:config_android-stlport": [],
+ "//build_defs:config_android-libcpp": [],
+ "//build_defs:config_android-gnu-libstdcpp": [],
+ "//build_defs:config_android-default": [],
+ "//build_defs:config_msvc": [
+ # Suppress linker warnings about files with no symbols defined.
+ "-ignore:4221",
+ ],
+ "//conditions:default": [
+ "-lpthread",
+ "-lm",
+ ],
+})
diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake
index 10e7e5c00..8aff9d6a2 100644
--- a/cmake/abseil-cpp.cmake
+++ b/cmake/abseil-cpp.cmake
@@ -1,4 +1,7 @@
-if(protobuf_ABSL_PROVIDER STREQUAL "module")
+if(TARGET absl::strings)
+ # If absl is included already, skip including it.
+ # (https://github.com/grpc/grpc/issues/29608)
+elseif(protobuf_ABSL_PROVIDER STREQUAL "module")
if(NOT ABSL_ROOT_DIR)
set(ABSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp)
endif()
diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in
index 061b240ae..129282921 100644
--- a/cmake/extract_includes.bat.in
+++ b/cmake/extract_includes.bat.in
@@ -51,6 +51,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h" include\google\protobuf\duration.pb.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h" include\google\protobuf\dynamic_message.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h" include\google\protobuf\empty.pb.h
+copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\endian.h" include\google\protobuf\endian.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\explicitly_constructed.h" include\google\protobuf\explicitly_constructed.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h" include\google\protobuf\extension_set.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set_inl.h" include\google\protobuf\extension_set_inl.h
diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
index 04a4ba022..1e4444e20 100644
--- a/cmake/libprotobuf-lite.cmake
+++ b/cmake/libprotobuf-lite.cmake
@@ -115,7 +115,7 @@ if(protobuf_BUILD_SHARED_LIBS)
endif()
set_target_properties(libprotobuf-lite PROPERTIES
VERSION ${protobuf_VERSION}
- SOVERSION 31
+ SOVERSION 32
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
index 9f3bdb22f..e597959d2 100644
--- a/cmake/libprotobuf.cmake
+++ b/cmake/libprotobuf.cmake
@@ -131,7 +131,7 @@ if(protobuf_BUILD_SHARED_LIBS)
endif()
set_target_properties(libprotobuf PROPERTIES
VERSION ${protobuf_VERSION}
- SOVERSION 31
+ SOVERSION 32
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf ALIAS libprotobuf)
diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake
index 5883e612a..7506b0220 100644
--- a/cmake/libprotoc.cmake
+++ b/cmake/libprotoc.cmake
@@ -133,7 +133,7 @@ endif()
set_target_properties(libprotoc PROPERTIES
COMPILE_DEFINITIONS LIBPROTOC_EXPORTS
VERSION ${protobuf_VERSION}
- SOVERSION 31
+ SOVERSION 32
OUTPUT_NAME ${LIB_PREFIX}protoc
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotoc ALIAS libprotoc)
diff --git a/configure.ac b/configure.ac
index d5b1f707b..7cf520012 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# In the SVN trunk, the version should always be the next anticipated release
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
# the size of one file name in the dist tarfile over the 99-char limit.)
-AC_INIT([Protocol Buffers],[3.20.1],[protobuf@googlegroups.com],[protobuf])
+AC_INIT([Protocol Buffers],[3.21.0-rc-1],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])
diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel
new file mode 100644
index 000000000..fef036600
--- /dev/null
+++ b/conformance/BUILD.bazel
@@ -0,0 +1,183 @@
+# Conformance testing for Protobuf.
+
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
+load(
+ "@rules_pkg//:mappings.bzl",
+ "pkg_attributes",
+ "pkg_filegroup",
+ "pkg_files",
+ "strip_prefix",
+)
+
+exports_files([
+ "conformance_test_runner.sh",
+ "failure_list_java.txt",
+ "failure_list_java_lite.txt",
+ "text_format_failure_list_java.txt",
+ "text_format_failure_list_java_lite.txt",
+])
+
+cc_proto_library(
+ name = "test_messages_proto2_proto_cc",
+ deps = ["//:test_messages_proto2_proto"],
+)
+
+cc_proto_library(
+ name = "test_messages_proto3_proto_cc",
+ deps = ["//:test_messages_proto3_proto"],
+)
+
+proto_library(
+ name = "conformance_proto",
+ srcs = ["conformance.proto"],
+ visibility = ["//visibility:public"],
+)
+
+cc_proto_library(
+ name = "conformance_proto_cc",
+ deps = [":conformance_proto"],
+)
+
+java_proto_library(
+ name = "conformance_java_proto",
+ visibility = [
+ "//java:__subpackages__",
+ ],
+ deps = [":conformance_proto"],
+)
+
+java_lite_proto_library(
+ name = "conformance_java_proto_lite",
+ visibility = [
+ "//java:__subpackages__",
+ ],
+ deps = [":conformance_proto"],
+)
+
+cc_library(
+ name = "jsoncpp",
+ srcs = ["third_party/jsoncpp/jsoncpp.cpp"],
+ hdrs = ["third_party/jsoncpp/json.h"],
+ includes = ["."],
+)
+
+cc_library(
+ name = "conformance_test",
+ srcs = [
+ "conformance_test.cc",
+ "conformance_test_runner.cc",
+ ],
+ hdrs = [
+ "conformance_test.h",
+ ],
+ includes = ["."],
+ deps = [":conformance_proto_cc"],
+)
+
+cc_library(
+ name = "binary_json_conformance_suite",
+ srcs = ["binary_json_conformance_suite.cc"],
+ hdrs = ["binary_json_conformance_suite.h"],
+ deps = [
+ ":conformance_test",
+ ":jsoncpp",
+ ":test_messages_proto2_proto_cc",
+ ":test_messages_proto3_proto_cc",
+ ],
+)
+
+cc_library(
+ name = "text_format_conformance_suite",
+ srcs = ["text_format_conformance_suite.cc"],
+ hdrs = ["text_format_conformance_suite.h"],
+ deps = [
+ ":conformance_test",
+ ":test_messages_proto2_proto_cc",
+ ":test_messages_proto3_proto_cc",
+ ],
+)
+
+cc_binary(
+ name = "conformance_test_runner",
+ srcs = ["conformance_test_main.cc"],
+ visibility = ["//visibility:public"],
+ deps = [
+ ":binary_json_conformance_suite",
+ ":conformance_test",
+ ":text_format_conformance_suite",
+ ],
+)
+
+java_binary(
+ name = "conformance_java",
+ srcs = ["ConformanceJava.java"],
+ main_class = "ConformanceJava",
+ visibility = [
+ "//java:__subpackages__",
+ ],
+ deps = [
+ ":conformance_java_proto",
+ "//:protobuf_java",
+ "//:protobuf_java_util",
+ "//:test_messages_proto2_java_proto",
+ "//:test_messages_proto3_java_proto",
+ ],
+)
+
+java_binary(
+ name = "conformance_java_lite",
+ srcs = ["ConformanceJavaLite.java"],
+ main_class = "ConformanceJavaLite",
+ visibility = [
+ "//java:__subpackages__",
+ ],
+ deps = [
+ ":conformance_java_proto_lite",
+ "//:protobuf_java_util",
+ "//:protobuf_javalite",
+ "//:test_messages_proto2_java_proto_lite",
+ "//:test_messages_proto3_java_proto_lite",
+ ],
+)
+
+filegroup(
+ name = "all_files",
+ srcs = glob(["**/*"]),
+ visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"],
+)
+
+pkg_files(
+ name = "dist_files",
+ srcs = glob(
+ ["**/*"],
+ exclude = [
+ # Handled by dist_scripts:
+ "conformance_test_runner.sh",
+
+ # The following are not in autotools dist:
+ "autoload.php",
+ "conformance_nodejs.js",
+ "failure_list_jruby.txt",
+ "update_failure_list.py",
+ ],
+ ),
+ strip_prefix = strip_prefix.from_root(""),
+ visibility = ["//pkg:__pkg__"],
+)
+
+pkg_files(
+ name = "dist_scripts",
+ srcs = ["conformance_test_runner.sh"],
+ attributes = pkg_attributes(mode = "0555"),
+ strip_prefix = strip_prefix.from_root(""),
+ visibility = ["//pkg:__pkg__"],
+)
+
+pkg_filegroup(
+ name = "all_dist_files",
+ srcs = [
+ ":dist_files",
+ ":dist_scripts",
+ ],
+ visibility = ["//pkg:__pkg__"],
+)
diff --git a/conformance/conformance_test_runner.sh b/conformance/conformance_test_runner.sh
index e9b2e4fff..3149f82fb 100755
--- a/conformance/conformance_test_runner.sh
+++ b/conformance/conformance_test_runner.sh
@@ -40,7 +40,7 @@ while [[ -n "$@" ]]; do
esac
done
-conformance_test_runner=$(rlocation com_google_protobuf/conformance_test_runner)
+conformance_test_runner=$(rlocation com_google_protobuf/conformance/conformance_test_runner)
conformance_testee=$(rlocation $TESTEE)
args=(--enforce_recommended)
diff --git a/internal.bzl b/conformance/defs.bzl
similarity index 83%
rename from internal.bzl
rename to conformance/defs.bzl
index a281418c9..905953a11 100644
--- a/internal.bzl
+++ b/conformance/defs.bzl
@@ -12,9 +12,9 @@ def conformance_test(name, testee, failure_list = None, text_format_failure_list
native.sh_test(
name = name,
- srcs = ["//:conformance/conformance_test_runner.sh"],
+ srcs = ["//conformance:conformance_test_runner.sh"],
data = [testee] + failure_lists + [
- "//:conformance_test_runner",
+ "//conformance:conformance_test_runner",
],
args = args,
deps = [
@@ -22,8 +22,7 @@ def conformance_test(name, testee, failure_list = None, text_format_failure_list
],
)
-
def _strip_bazel(testee):
if testee.startswith("//"):
- testee = testee.replace("//", "com_google_protobuf")
+ testee = testee.replace("//", "com_google_protobuf/")
return testee.replace(":", "/")
diff --git a/csharp/BUILD.bazel b/csharp/BUILD.bazel
index 2c150841b..1b381b3a3 100644
--- a/csharp/BUILD.bazel
+++ b/csharp/BUILD.bazel
@@ -4,6 +4,25 @@
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
+filegroup(
+ name = "wkt_cs_srcs",
+ data = [
+ "src/Google.Protobuf.Conformance/Conformance.cs",
+ "src/Google.Protobuf/Reflection/Descriptor.cs",
+ "src/Google.Protobuf/WellKnownTypes/Any.cs",
+ "src/Google.Protobuf/WellKnownTypes/Api.cs",
+ "src/Google.Protobuf/WellKnownTypes/Duration.cs",
+ "src/Google.Protobuf/WellKnownTypes/Empty.cs",
+ "src/Google.Protobuf/WellKnownTypes/FieldMask.cs",
+ "src/Google.Protobuf/WellKnownTypes/SourceContext.cs",
+ "src/Google.Protobuf/WellKnownTypes/Struct.cs",
+ "src/Google.Protobuf/WellKnownTypes/Timestamp.cs",
+ "src/Google.Protobuf/WellKnownTypes/Type.cs",
+ "src/Google.Protobuf/WellKnownTypes/Wrappers.cs",
+ ],
+ visibility = ["//src/google/protobuf/compiler/csharp:__pkg__"],
+)
+
pkg_files(
name = "dist_files",
srcs = glob([
diff --git a/csharp/Google.Protobuf.Tools.nuspec b/csharp/Google.Protobuf.Tools.nuspec
index 1d34a5e2d..25c0609b4 100644
--- a/csharp/Google.Protobuf.Tools.nuspec
+++ b/csharp/Google.Protobuf.Tools.nuspec
@@ -5,7 +5,7 @@
Google Protocol Buffers tools
Tools for Protocol Buffers - Google's data interchange format.
See project site for more info.
- 3.20.1
+ 3.21.0-rc1
Google Inc.
protobuf-packages
https://github.com/protocolbuffers/protobuf/blob/main/LICENSE
diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs
index 484a2296a..1ff0f3b6c 100644
--- a/csharp/src/AddressBook/Addressbook.cs
+++ b/csharp/src/AddressBook/Addressbook.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: addressbook.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs b/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs
index 412440417..fe21d0c40 100644
--- a/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs
+++ b/csharp/src/Google.Protobuf.Benchmarks/BenchmarkMessage1Proto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: datasets/google_message1/proto3/benchmark_message1_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs b/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs
index faa37b050..a05802da5 100644
--- a/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs
+++ b/csharp/src/Google.Protobuf.Benchmarks/Benchmarks.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: benchmarks.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs
index df427e802..e2eb2e8b9 100644
--- a/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs
+++ b/csharp/src/Google.Protobuf.Benchmarks/WrapperBenchmarkMessages.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: wrapper_benchmark_messages.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
index 0a3d5c604..79977a0ca 100644
--- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: conformance.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs
index 4791b7325..57e59a9ac 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/MapUnittestProto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: map_unittest_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs
index 94f089c3f..35f2b8a15 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto2.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/test_messages_proto2.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs
index 5a2aa3bd5..520216fdf 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/TestMessagesProto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/test_messages_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs
index 706b7c473..c1f43ce0f 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/Unittest.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs
index 305dfe188..ea7a936af 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestCustomOptionsProto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_custom_options_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs
index 4f40564eb..de5f0c24d 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImport.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_import.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs
index a3ce7a225..d661c2d47 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportProto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_import_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs
index b1e0f30ad..f8a0e55fb 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublic.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_import_public.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs
index dde8b9bda..f664c7ba9 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestImportPublicProto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_import_public_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.cs
index 56fde4f00..e7e2b4275 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936A.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_issue6936_a.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs
index 1ac4a6729..21232fbd6 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936B.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_issue6936_b.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs
index d7789b87a..cb53b7a19 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssue6936C.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_issue6936_c.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs
index 344010551..3fe2dd68a 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestIssues.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_issues.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs
index 1af0d9e3f..ddb73d779 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_proto3.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
index a41b890fc..4502ffaa1 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestProto3Optional.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/unittest_proto3_optional.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs
index 7a8f72d4b..e1118c96c 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestSelfreferentialOptions.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: unittest_selfreferential_options.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs
index 58e866e76..3ec8d3556 100644
--- a/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs
+++ b/csharp/src/Google.Protobuf.Test.TestProtos/UnittestWellKnownTypes.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/unittest_well_known_types.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs b/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs
index f71744a87..c7fbd1373 100644
--- a/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs
+++ b/csharp/src/Google.Protobuf.Test/FieldMaskTreeTest.cs
@@ -432,5 +432,89 @@ namespace Google.Protobuf
Assert.IsNotNull(destination.Payload);
}
+ [Test]
+ public void MergeWrapperFieldsWithNonNullFieldsInSource()
+ {
+ // Instantiate a destination with wrapper-based field types.
+ var destination = new TestWellKnownTypes()
+ {
+ StringField = "Hello",
+ Int32Field = 12,
+ Int64Field = 24,
+ BoolField = true,
+ };
+
+ // Set up a targeted update.
+ var source = new TestWellKnownTypes()
+ {
+ StringField = "Hi",
+ Int64Field = 240
+ };
+
+ Merge(new FieldMaskTree().AddFieldPath("string_field").AddFieldPath("int64_field"),
+ source,
+ destination,
+ new FieldMask.MergeOptions(),
+ false);
+
+ // Make sure the targeted fields changed.
+ Assert.AreEqual("Hi", destination.StringField);
+ Assert.AreEqual(240, destination.Int64Field);
+
+ // Prove that non-targeted fields stay intact...
+ Assert.AreEqual(12, destination.Int32Field);
+ Assert.IsTrue(destination.BoolField);
+
+ // ...including default values which were not explicitly set in the destination object.
+ Assert.IsNull(destination.FloatField);
+ }
+
+ [Test]
+ [TestCase(false, "Hello", 24)]
+ [TestCase(true, null, null)]
+ public void MergeWrapperFieldsWithNullFieldsInSource(
+ bool replaceMessageFields,
+ string expectedStringValue,
+ long? expectedInt64Value)
+ {
+ // Instantiate a destination with wrapper-based field types.
+ var destination = new TestWellKnownTypes()
+ {
+ StringField = "Hello",
+ Int32Field = 12,
+ Int64Field = 24,
+ BoolField = true,
+ };
+
+ // Set up a targeted update with null valued fields.
+ var source = new TestWellKnownTypes()
+ {
+ StringField = null,
+ Int64Field = null
+ };
+
+ Merge(new FieldMaskTree().AddFieldPath("string_field").AddFieldPath("int64_field"),
+ source,
+ destination,
+ new FieldMask.MergeOptions()
+ {
+ ReplaceMessageFields = replaceMessageFields
+ },
+ false);
+
+ // Make sure the targeted fields changed according to our expectations, depending on the value of ReplaceMessageFields.
+ // When ReplaceMessageFields is false, the null values are not applied to the destination, because, although wrapped types
+ // are semantically primitives, FieldMaskTree.Merge still treats them as message types in order to maintain consistency with other Protobuf
+ // libraries such as Java and C++.
+ Assert.AreEqual(expectedStringValue, destination.StringField);
+ Assert.AreEqual(expectedInt64Value, destination.Int64Field);
+
+ // Prove that non-targeted fields stay intact...
+ Assert.AreEqual(12, destination.Int32Field);
+ Assert.IsTrue(destination.BoolField);
+
+ // ...including default values which were not explicitly set in the destination object.
+ Assert.IsNull(destination.FloatField);
+ }
}
}
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
index c05cb0853..771f1f41b 100644
--- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
+++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
@@ -30,8 +30,11 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
+using Google.Protobuf.Reflection;
using Google.Protobuf.TestProtos;
using NUnit.Framework;
+using System.Linq;
+using UnitTest.Issues.TestProtos;
namespace Google.Protobuf.WellKnownTypes
{
@@ -148,10 +151,34 @@ namespace Google.Protobuf.WellKnownTypes
Assert.False(any.Is(TestOneof.Descriptor));
}
+ [Test]
public void IsRightType()
{
var any = Any.Pack(SampleMessages.CreateFullTestAllTypes());
Assert.True(any.Is(TestAllTypes.Descriptor));
}
+
+ [Test]
+ public void Unpack_TypeRegistry()
+ {
+ var messages = new IMessage[]
+ {
+ SampleMessages.CreateFullTestAllTypes(),
+ new TestWellKnownTypes { BoolField = true },
+ new MoreString { Data = { "x" } },
+ new MoreBytes { Data = ByteString.CopyFromUtf8("xyz") },
+ new ReservedNames { Descriptor_ = 10 }
+ };
+ var anyMessages = messages.Select(Any.Pack);
+
+ // The type registry handles the first four of the packed messages, but not the final one.
+ var registry = TypeRegistry.FromFiles(
+ UnittestWellKnownTypesReflection.Descriptor,
+ UnittestProto3Reflection.Descriptor);
+ var unpacked = anyMessages.Select(any => any.Unpack(registry)).ToList();
+ var expected = (IMessage[]) messages.Clone();
+ expected[4] = null;
+ Assert.AreEqual(expected, unpacked);
+ }
}
}
diff --git a/csharp/src/Google.Protobuf/FieldMaskTree.cs b/csharp/src/Google.Protobuf/FieldMaskTree.cs
index 2297e7a11..63eb5f61c 100644
--- a/csharp/src/Google.Protobuf/FieldMaskTree.cs
+++ b/csharp/src/Google.Protobuf/FieldMaskTree.cs
@@ -333,15 +333,24 @@ namespace Google.Protobuf
{
if (sourceField != null)
{
- var sourceByteString = ((IMessage)sourceField).ToByteString();
- var destinationValue = (IMessage)field.Accessor.GetValue(destination);
- if (destinationValue != null)
+ // Well-known wrapper types are represented as nullable primitive types, so we do not "merge" them.
+ // Instead, any non-null value just overwrites the previous value directly.
+ if (field.MessageType.IsWrapperType)
{
- destinationValue.MergeFrom(sourceByteString);
+ field.Accessor.SetValue(destination, sourceField);
}
else
{
- field.Accessor.SetValue(destination, field.MessageType.Parser.ParseFrom(sourceByteString));
+ var sourceByteString = ((IMessage)sourceField).ToByteString();
+ var destinationValue = (IMessage)field.Accessor.GetValue(destination);
+ if (destinationValue != null)
+ {
+ destinationValue.MergeFrom(sourceByteString);
+ }
+ else
+ {
+ field.Accessor.SetValue(destination, field.MessageType.Parser.ParseFrom(sourceByteString));
+ }
}
}
}
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index 79af7f3d8..40986da94 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -4,7 +4,7 @@
C# runtime library for Protocol Buffers - Google's data interchange format.
Copyright 2015, Google Inc.
Google Protocol Buffers
- 3.20.1
+ 3.21.0-rc1
7.2
Google Inc.
diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
index 5967a4fef..1cb43c0ea 100644
--- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/descriptor.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
index 13066da3f..d0ce71b1d 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/any.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
index 5e7b6d5a1..cebbcd2fe 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
@@ -120,6 +120,26 @@ namespace Google.Protobuf.WellKnownTypes
return true;
}
+ ///
+ /// Attempts to unpack the content of this Any message into one of the message types
+ /// in the given type registry, based on the type URL.
+ ///
+ /// The type registry to consult for messages.
+ /// The unpacked message, or null if no matching message was found.
+ public IMessage Unpack(TypeRegistry registry)
+ {
+ string typeName = GetTypeName(TypeUrl);
+ MessageDescriptor descriptor = registry.Find(typeName);
+ if (descriptor == null)
+ {
+ return null;
+ }
+
+ var message = descriptor.Parser.CreateTemplate();
+ message.MergeFrom(Value);
+ return message;
+ }
+
///
/// Packs the specified message into an Any message using a type URL prefix of "type.googleapis.com".
///
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
index 58a658e07..c524031e3 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/api.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
index b46f4d293..576ef2e60 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/duration.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
index 08f4a849d..43d2b7490 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/empty.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
index e90c3d571..19e0e6e41 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/field_mask.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
index 58c23cea1..6edd4f139 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/source_context.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
index 123d80ac9..8c1eec53b 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/struct.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
index e981dc2a0..e6d57afd5 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/timestamp.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
index 120f31a90..3088e385d 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/type.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
index 29c04b36b..307a446f0 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
@@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/wrappers.proto
//
-#pragma warning disable 1591, 0612, 3021
+#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code
using pb = global::Google.Protobuf;
diff --git a/docs/options.md b/docs/options.md
index b48928841..bda41c211 100644
--- a/docs/options.md
+++ b/docs/options.md
@@ -320,3 +320,7 @@ with info about your project (name and website) so we can add an entry for you.
1. Protoc-gen-authz
* Website: https://github.com/Neakxs/protoc-gen-authz
* Extension: 1145
+
+1. Protonium
+ * Website: https://github.com/zyp/protonium
+ * Extension: 1146
diff --git a/java/README.md b/java/README.md
index c5c0bfab5..41cbc869e 100644
--- a/java/README.md
+++ b/java/README.md
@@ -23,7 +23,7 @@ If you are using Maven, use the following:
com.google.protobuf
protobuf-java
- 3.20.1
+ 3.21.0-rc-1
```
@@ -37,7 +37,7 @@ protobuf-java-util package:
com.google.protobuf
protobuf-java-util
- 3.20.1
+ 3.21.0-rc-1
```
@@ -45,7 +45,7 @@ protobuf-java-util package:
If you are using Gradle, add the following to your `build.gradle` file's dependencies:
```
- implementation 'com.google.protobuf:protobuf-java:3.20.1'
+ implementation 'com.google.protobuf:protobuf-java:3.21.0-rc-1'
```
Again, be sure to check that the version number matches (or is newer than) the version number of protoc that you are using.
diff --git a/java/bom/pom.xml b/java/bom/pom.xml
index 045dc285a..ce950a209 100644
--- a/java/bom/pom.xml
+++ b/java/bom/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-bom
- 3.20.1
+ 3.21.0-rc-1
pom
Protocol Buffers [BOM]
diff --git a/java/core/BUILD.bazel b/java/core/BUILD.bazel
index e36a38e7f..5a5eed972 100644
--- a/java/core/BUILD.bazel
+++ b/java/core/BUILD.bazel
@@ -3,7 +3,8 @@ load("@rules_java//java:defs.bzl", "java_library", "java_lite_proto_library", "j
load("@rules_jvm_external//:defs.bzl", "java_export")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
-load("//:internal.bzl", "conformance_test")
+load("//conformance:defs.bzl", "conformance_test")
+load("//:protobuf.bzl", "internal_gen_well_known_protos_java")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//java/internal:testing.bzl", "junit_tests")
@@ -102,11 +103,28 @@ LITE_SRCS = [
"src/main/java/com/google/protobuf/Writer.java",
]
+internal_gen_well_known_protos_java(
+ name = "gen_well_known_protos_javalite",
+ javalite = True,
+ deps = [
+ "//:any_proto",
+ "//:api_proto",
+ "//:duration_proto",
+ "//:empty_proto",
+ "//:field_mask_proto",
+ "//:source_context_proto",
+ "//:struct_proto",
+ "//:timestamp_proto",
+ "//:type_proto",
+ "//:wrappers_proto",
+ ],
+)
+
# Should be used as `//java/lite`.
java_library(
name = "lite",
srcs = LITE_SRCS + [
- "//:gen_well_known_protos_javalite",
+ ":gen_well_known_protos_javalite",
],
visibility = [
"//java/lite:__pkg__",
@@ -130,6 +148,24 @@ java_library(
srcs = LITE_SRCS,
)
+internal_gen_well_known_protos_java(
+ name = "gen_well_known_protos_java",
+ 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",
+ ],
+)
+
java_library(
name = "core",
srcs = glob(
@@ -138,7 +174,7 @@ java_library(
],
exclude = LITE_SRCS,
) + [
- "//:gen_well_known_protos_java",
+ ":gen_well_known_protos_java",
],
visibility = ["//visibility:public"],
exports = [
@@ -155,7 +191,8 @@ java_export(
maven_coordinates = "com.google.protobuf:protobuf-java:%s" % PROTOBUF_JAVA_VERSION,
pom_template = "pom_template.xml",
resources = [
- "//:well_known_protos",
+ "//src/google/protobuf:descriptor_proto_srcs",
+ "//:well_known_type_protos",
],
tags = ["manual"],
runtime_deps = [":core"],
@@ -205,8 +242,9 @@ proto_library(
deps = [
"//:any_proto",
"//:descriptor_proto",
- "//:generic_test_protos",
+ "//:lite_test_protos",
"//:wrappers_proto",
+ "//src/google/protobuf:generic_test_protos",
],
)
@@ -215,7 +253,15 @@ java_proto_library(
visibility = [
"//java:__subpackages__",
],
- deps = ["//:generic_test_protos"],
+ deps = ["//src/google/protobuf:generic_test_protos"],
+)
+
+java_proto_library(
+ name = "lite_test_protos_java_proto",
+ visibility = [
+ "//java:__subpackages__",
+ ],
+ deps = ["//:lite_test_protos"],
)
java_proto_library(
@@ -234,6 +280,7 @@ java_library(
":core",
":generic_test_protos_java_proto",
":java_test_protos_java_proto",
+ ":lite_test_protos_java_proto",
"@maven//:com_google_guava_guava",
"@maven//:junit_junit",
],
@@ -258,9 +305,9 @@ build_test(
conformance_test(
name = "conformance_test",
- failure_list = "//:conformance/failure_list_java.txt",
- testee = "//:conformance_java",
- text_format_failure_list = "//:conformance/text_format_failure_list_java.txt",
+ failure_list = "//conformance:failure_list_java.txt",
+ testee = "//conformance:conformance_java",
+ text_format_failure_list = "//conformance:text_format_failure_list_java.txt",
)
junit_tests(
@@ -275,11 +322,12 @@ junit_tests(
"src/test/java/com/google/protobuf/TestUtilLite.java",
],
),
- data = ["//:testdata"],
+ data = ["//src/google/protobuf:testdata"],
deps = [
":core",
":generic_test_protos_java_proto",
":java_test_protos_java_proto",
+ ":lite_test_protos_java_proto",
":test_util",
"@maven//:com_google_guava_guava",
"@maven//:com_google_truth_truth",
@@ -309,9 +357,19 @@ junit_tests(
java_lite_proto_library(
name = "generic_test_protos_java_proto_lite",
visibility = [
+ "//java/kotlin-lite:__pkg__",
"//java/lite:__pkg__",
],
- deps = ["//:generic_test_protos"],
+ deps = ["//src/google/protobuf:generic_test_protos"],
+)
+
+java_lite_proto_library(
+ name = "lite_test_protos_java_proto_lite",
+ visibility = [
+ "//java/kotlin-lite:__pkg__",
+ "//java/lite:__pkg__",
+ ],
+ deps = ["//:lite_test_protos"],
)
java_lite_proto_library(
@@ -346,6 +404,7 @@ java_library(
":generic_test_protos_java_proto_lite",
":java_test_protos_java_proto_lite",
":lite_runtime_only",
+ ":lite_test_protos_java_proto_lite",
"@maven//:com_google_guava_guava",
"@maven//:junit_junit",
],
@@ -402,12 +461,13 @@ junit_tests(
["src/test/java/**/*.java"],
exclude = LITE_TEST_EXCLUSIONS,
),
- data = ["//:testdata"],
+ data = ["//src/google/protobuf:testdata"],
test_prefix = "Lite",
deps = [
":generic_test_protos_java_proto_lite",
":java_test_protos_java_proto_lite",
":lite",
+ ":lite_test_protos_java_proto_lite",
":test_util_lite",
"@maven//:com_google_truth_truth",
"@maven//:junit_junit",
diff --git a/java/core/pom.xml b/java/core/pom.xml
index bc0726c35..8a33a507a 100644
--- a/java/core/pom.xml
+++ b/java/core/pom.xml
@@ -4,7 +4,7 @@
com.google.protobuf
protobuf-parent
- 3.20.1
+ 3.21.0-rc-1
protobuf-java
diff --git a/java/core/src/main/java/com/google/protobuf/Descriptors.java b/java/core/src/main/java/com/google/protobuf/Descriptors.java
index a36195bbb..07d771582 100644
--- a/java/core/src/main/java/com/google/protobuf/Descriptors.java
+++ b/java/core/src/main/java/com/google/protobuf/Descriptors.java
@@ -461,21 +461,20 @@ public final class Descriptors {
}
/**
- * This method is to be called by generated code only. It is used to update the
+ * This method is to be called by generated code only. It updates the
* FileDescriptorProto associated with the descriptor by parsing it again with the given
* ExtensionRegistry. This is needed to recognize custom options.
*/
public static void internalUpdateFileDescriptor(
- final FileDescriptor descriptor, final ExtensionRegistry registry) {
+ FileDescriptor descriptor, ExtensionRegistry registry) {
ByteString bytes = descriptor.proto.toByteString();
- FileDescriptorProto proto;
try {
- proto = FileDescriptorProto.parseFrom(bytes, registry);
+ FileDescriptorProto proto = FileDescriptorProto.parseFrom(bytes, registry);
+ descriptor.setProto(proto);
} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException(
"Failed to parse protocol buffer descriptor for generated code.", e);
}
- descriptor.setProto(proto);
}
/**
diff --git a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
index 9db33456d..e212ab5fe 100644
--- a/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
+++ b/java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java
@@ -244,11 +244,16 @@ public abstract class GeneratedMessageLite<
*
* For use by generated code only.
*/
- protected abstract Object dynamicMethod(MethodToInvoke method, Object arg0, Object arg1);
+ protected abstract Object dynamicMethod(
+ MethodToInvoke method,
+ Object arg0,
+ Object arg1);
/** Same as {@link #dynamicMethod(MethodToInvoke, Object, Object)} with {@code null} padding. */
@CanIgnoreReturnValue
- protected Object dynamicMethod(MethodToInvoke method, Object arg0) {
+ protected Object dynamicMethod(
+ MethodToInvoke method,
+ Object arg0) {
return dynamicMethod(method, arg0, null);
}
@@ -1245,11 +1250,11 @@ public abstract class GeneratedMessageLite<
}
@SuppressWarnings("unchecked")
- Object fromFieldSetType(final Object value) {
+ Object fromFieldSetType(Object value) {
if (descriptor.isRepeated()) {
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
- final List result = new ArrayList<>();
- for (final Object element : (List) value) {
+ List