Sync from Piper @449836334
PROTOBUF_SYNC_PIPER
This commit is contained in:
commit
3740e6fa68
1558
BUILD.bazel
1558
BUILD.bazel
File diff suppressed because it is too large
Load Diff
70
CHANGES.txt
70
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
|
||||
|
17
Makefile.am
17
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 \
|
||||
|
@ -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'
|
||||
|
@ -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'
|
||||
|
@ -75,7 +75,6 @@ pkg_files(
|
||||
],
|
||||
exclude = [
|
||||
"__init__.py", # not in autotools dist
|
||||
"BUILD.bazel",
|
||||
"go/*",
|
||||
],
|
||||
),
|
||||
|
@ -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__"],
|
||||
)
|
||||
|
@ -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__"],
|
||||
)
|
||||
|
@ -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__"],
|
||||
)
|
||||
|
@ -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__"],
|
||||
)
|
||||
|
@ -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__"],
|
||||
)
|
||||
|
@ -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__"],
|
||||
)
|
||||
|
159
build_defs/BUILD.bazel
Normal file
159
build_defs/BUILD.bazel
Normal file
@ -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__"],
|
||||
)
|
@ -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),
|
||||
),
|
||||
)
|
||||
|
40
build_defs/cpp_opts.bzl
Normal file
40
build_defs/cpp_opts.bzl
Normal file
@ -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",
|
||||
],
|
||||
})
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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])
|
||||
|
||||
|
183
conformance/BUILD.bazel
Normal file
183
conformance/BUILD.bazel
Normal file
@ -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__"],
|
||||
)
|
@ -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)
|
||||
|
||||
|
@ -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(":", "/")
|
@ -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([
|
||||
|
@ -5,7 +5,7 @@
|
||||
<title>Google Protocol Buffers tools</title>
|
||||
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
|
||||
<description>See project site for more info.</description>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc1</version>
|
||||
<authors>Google Inc.</authors>
|
||||
<owners>protobuf-packages</owners>
|
||||
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: addressbook.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: datasets/google_message1/proto3/benchmark_message1_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: benchmarks.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: wrapper_benchmark_messages.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: conformance.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: map_unittest_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/test_messages_proto2.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/test_messages_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_custom_options_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_import.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_import_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_import_public.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_import_public_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_issue6936_a.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_issue6936_b.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_issue6936_c.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_issues.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_proto3.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/unittest_proto3_optional.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: unittest_selfreferential_options.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/unittest_well_known_types.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
|
||||
<Copyright>Copyright 2015, Google Inc.</Copyright>
|
||||
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
|
||||
<VersionPrefix>3.20.1</VersionPrefix>
|
||||
<VersionPrefix>3.21.0-rc1</VersionPrefix>
|
||||
<!-- C# 7.2 is required for Span/BufferWriter/ReadOnlySequence -->
|
||||
<LangVersion>7.2</LangVersion>
|
||||
<Authors>Google Inc.</Authors>
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/descriptor.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/any.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -120,6 +120,26 @@ namespace Google.Protobuf.WellKnownTypes
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="registry">The type registry to consult for messages.</param>
|
||||
/// <returns>The unpacked message, or <c>null</c> if no matching message was found.</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Packs the specified message into an Any message using a type URL prefix of "type.googleapis.com".
|
||||
/// </summary>
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/api.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/duration.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/empty.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/field_mask.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/source_context.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/struct.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/timestamp.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/type.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: google/protobuf/wrappers.proto
|
||||
// </auto-generated>
|
||||
#pragma warning disable 1591, 0612, 3021
|
||||
#pragma warning disable 1591, 0612, 3021, 8981
|
||||
#region Designer generated code
|
||||
|
||||
using pb = global::Google.Protobuf;
|
||||
|
@ -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
|
||||
|
@ -23,7 +23,7 @@ If you are using Maven, use the following:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@ -37,7 +37,7 @@ protobuf-java-util package:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
@ -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.
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-bom</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [BOM]</name>
|
||||
|
@ -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",
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,11 +244,16 @@ public abstract class GeneratedMessageLite<
|
||||
*
|
||||
* <p>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<Object> result = new ArrayList<>();
|
||||
for (Object element : (List) value) {
|
||||
result.add(singularFromFieldSetType(element));
|
||||
}
|
||||
return result;
|
||||
@ -1261,7 +1266,7 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
}
|
||||
|
||||
Object singularFromFieldSetType(final Object value) {
|
||||
Object singularFromFieldSetType(Object value) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
return descriptor.enumTypeMap.findValueByNumber((Integer) value);
|
||||
} else {
|
||||
@ -1269,12 +1274,11 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Object toFieldSetType(final Object value) {
|
||||
Object toFieldSetType(Object value) {
|
||||
if (descriptor.isRepeated()) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
final List result = new ArrayList<>();
|
||||
for (final Object element : (List) value) {
|
||||
List<Object> result = new ArrayList<>();
|
||||
for (Object element : (List) value) {
|
||||
result.add(singularToFieldSetType(element));
|
||||
}
|
||||
return result;
|
||||
@ -1286,7 +1290,7 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
}
|
||||
|
||||
Object singularToFieldSetType(final Object value) {
|
||||
Object singularToFieldSetType(Object value) {
|
||||
if (descriptor.getLiteJavaType() == WireFormat.JavaType.ENUM) {
|
||||
return ((Internal.EnumLite) value).getNumber();
|
||||
} else {
|
||||
|
@ -116,8 +116,8 @@ public final class TextFormat {
|
||||
|
||||
/**
|
||||
* Generates a human readable form of this message, useful for debugging and other purposes, with
|
||||
* no newline characters. This is just a trivial wrapper around
|
||||
* {@link TextFormat.Printer#shortDebugString(MessageOrBuilder)}.
|
||||
* no newline characters. This is just a trivial wrapper around {@link
|
||||
* TextFormat.Printer#shortDebugString(MessageOrBuilder)}.
|
||||
*/
|
||||
public static String shortDebugString(final MessageOrBuilder message) {
|
||||
return printer().shortDebugString(message);
|
||||
@ -459,9 +459,7 @@ public final class TextFormat {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An adapter class that can take a {@link MapEntry} and returns its key and entry.
|
||||
*/
|
||||
/** An adapter class that can take a {@link MapEntry} and returns its key and entry. */
|
||||
private static class MapEntryAdapter implements Comparable<MapEntryAdapter> {
|
||||
private Object entry;
|
||||
|
||||
@ -953,6 +951,7 @@ public final class TextFormat {
|
||||
* the next token is parsed.
|
||||
*/
|
||||
private boolean containsSilentMarkerAfterCurrentToken = false;
|
||||
|
||||
private boolean containsSilentMarkerAfterPrevToken = false;
|
||||
|
||||
/** Construct a tokenizer that parses tokens from the given text. */
|
||||
@ -1378,7 +1377,6 @@ public final class TextFormat {
|
||||
private ParseException floatParseException(final NumberFormatException e) {
|
||||
return parseException("Couldn't parse number: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Thrown when parsing an invalid text format message. */
|
||||
@ -1551,7 +1549,7 @@ public final class TextFormat {
|
||||
* the current token is part of the field value, so the silent marker is indicated by
|
||||
* containsSilentMarkerAfterPrevToken.
|
||||
*/
|
||||
private void detectSilentMarker(Tokenizer tokenizer) {
|
||||
private void detectSilentMarker(Tokenizer tokenizer, String fieldName) {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1628,8 +1626,8 @@ public final class TextFormat {
|
||||
* unknown field is encountered. If this is set, the parser will only log a warning. Allow
|
||||
* unknown fields will also allow unknown extensions.
|
||||
*
|
||||
* <p>Use of this parameter is discouraged which may hide some errors (e.g.
|
||||
* spelling error on field name).
|
||||
* <p>Use of this parameter is discouraged which may hide some errors (e.g. spelling error on
|
||||
* field name).
|
||||
*/
|
||||
public Builder setAllowUnknownFields(boolean allowUnknownFields) {
|
||||
this.allowUnknownFields = allowUnknownFields;
|
||||
@ -1637,10 +1635,9 @@ public final class TextFormat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether this parser will allow unknown extensions. By default, an
|
||||
* exception is thrown if unknown extension is encountered. If this is set true,
|
||||
* the parser will only log a warning. Allow unknown extensions does not mean
|
||||
* allow normal unknown fields.
|
||||
* Set whether this parser will allow unknown extensions. By default, an exception is thrown
|
||||
* if unknown extension is encountered. If this is set true, the parser will only log a
|
||||
* warning. Allow unknown extensions does not mean allow normal unknown fields.
|
||||
*/
|
||||
public Builder setAllowUnknownExtensions(boolean allowUnknownExtensions) {
|
||||
this.allowUnknownExtensions = allowUnknownExtensions;
|
||||
@ -1725,7 +1722,8 @@ public final class TextFormat {
|
||||
|
||||
static final class UnknownField {
|
||||
static enum Type {
|
||||
FIELD, EXTENSION;
|
||||
FIELD,
|
||||
EXTENSION;
|
||||
}
|
||||
|
||||
final String message;
|
||||
@ -1786,7 +1784,6 @@ public final class TextFormat {
|
||||
throws ParseException {
|
||||
final Tokenizer tokenizer = new Tokenizer(input);
|
||||
MessageReflection.BuilderAdapter target = new MessageReflection.BuilderAdapter(builder);
|
||||
|
||||
List<UnknownField> unknownFields = new ArrayList<UnknownField>();
|
||||
|
||||
while (!tokenizer.atEnd()) {
|
||||
@ -1803,12 +1800,7 @@ public final class TextFormat {
|
||||
final MessageReflection.MergeTarget target,
|
||||
List<UnknownField> unknownFields)
|
||||
throws ParseException {
|
||||
mergeField(
|
||||
tokenizer,
|
||||
extensionRegistry,
|
||||
target,
|
||||
parseInfoTreeBuilder,
|
||||
unknownFields);
|
||||
mergeField(tokenizer, extensionRegistry, target, parseInfoTreeBuilder, unknownFields);
|
||||
}
|
||||
|
||||
/** Parse a single field from {@code tokenizer} and merge it into {@code target}. */
|
||||
@ -1820,26 +1812,28 @@ public final class TextFormat {
|
||||
List<UnknownField> unknownFields)
|
||||
throws ParseException {
|
||||
FieldDescriptor field = null;
|
||||
String name;
|
||||
int startLine = tokenizer.getLine();
|
||||
int startColumn = tokenizer.getColumn();
|
||||
final Descriptor type = target.getDescriptorForType();
|
||||
ExtensionRegistry.ExtensionInfo extension = null;
|
||||
|
||||
if ("google.protobuf.Any".equals(type.getFullName()) && tokenizer.tryConsume("[")) {
|
||||
mergeAnyFieldValue(tokenizer, extensionRegistry, target, parseTreeBuilder, unknownFields,
|
||||
type);
|
||||
mergeAnyFieldValue(
|
||||
tokenizer, extensionRegistry, target, parseTreeBuilder, unknownFields, type);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tokenizer.tryConsume("[")) {
|
||||
// An extension.
|
||||
final StringBuilder name = new StringBuilder(tokenizer.consumeIdentifier());
|
||||
StringBuilder nameBuilder = new StringBuilder(tokenizer.consumeIdentifier());
|
||||
while (tokenizer.tryConsume(".")) {
|
||||
name.append('.');
|
||||
name.append(tokenizer.consumeIdentifier());
|
||||
nameBuilder.append('.');
|
||||
nameBuilder.append(tokenizer.consumeIdentifier());
|
||||
}
|
||||
name = nameBuilder.toString();
|
||||
|
||||
extension = target.findExtensionByName(extensionRegistry, name.toString());
|
||||
extension = target.findExtensionByName(extensionRegistry, name);
|
||||
|
||||
if (extension == null) {
|
||||
String message =
|
||||
@ -1866,7 +1860,7 @@ public final class TextFormat {
|
||||
|
||||
tokenizer.consume("]");
|
||||
} else {
|
||||
final String name = tokenizer.consumeIdentifier();
|
||||
name = tokenizer.consumeIdentifier();
|
||||
field = type.findFieldByName(name);
|
||||
|
||||
// Group names are expected to be capitalized as they appear in the
|
||||
@ -1890,13 +1884,14 @@ public final class TextFormat {
|
||||
}
|
||||
|
||||
if (field == null) {
|
||||
String message = (tokenizer.getPreviousLine() + 1)
|
||||
+ ":"
|
||||
+ (tokenizer.getPreviousColumn() + 1)
|
||||
+ ":\t"
|
||||
+ type.getFullName()
|
||||
+ "."
|
||||
+ name;
|
||||
String message =
|
||||
(tokenizer.getPreviousLine() + 1)
|
||||
+ ":"
|
||||
+ (tokenizer.getPreviousColumn() + 1)
|
||||
+ ":\t"
|
||||
+ type.getFullName()
|
||||
+ "."
|
||||
+ name;
|
||||
unknownFields.add(new UnknownField(message, UnknownField.Type.FIELD));
|
||||
}
|
||||
}
|
||||
@ -1909,7 +1904,7 @@ public final class TextFormat {
|
||||
// start with "{" or "<" which indicates the beginning of a message body.
|
||||
// If there is no ":" or there is a "{" or "<" after ":", this field has
|
||||
// to be a message or the input is ill-formed.
|
||||
detectSilentMarker(tokenizer);
|
||||
detectSilentMarker(tokenizer, name);
|
||||
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("{") && !tokenizer.lookingAt("<")) {
|
||||
skipFieldValue(tokenizer);
|
||||
} else {
|
||||
@ -1920,7 +1915,7 @@ public final class TextFormat {
|
||||
|
||||
// Handle potential ':'.
|
||||
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
|
||||
detectSilentMarker(tokenizer);
|
||||
detectSilentMarker(tokenizer, field.getFullName());
|
||||
tokenizer.tryConsume(":"); // optional
|
||||
if (parseTreeBuilder != null) {
|
||||
TextFormatParseInfoTree.Builder childParseTreeBuilder =
|
||||
@ -1944,7 +1939,7 @@ public final class TextFormat {
|
||||
unknownFields);
|
||||
}
|
||||
} else {
|
||||
detectSilentMarker(tokenizer);
|
||||
detectSilentMarker(tokenizer, field.getFullName());
|
||||
tokenizer.consume(":"); // required
|
||||
consumeFieldValues(
|
||||
tokenizer,
|
||||
@ -1967,6 +1962,29 @@ public final class TextFormat {
|
||||
}
|
||||
}
|
||||
|
||||
private String consumeFullTypeName(Tokenizer tokenizer) throws ParseException {
|
||||
// If there is not a leading `[`, this is just a type name.
|
||||
if (!tokenizer.tryConsume("[")) {
|
||||
return tokenizer.consumeIdentifier();
|
||||
}
|
||||
|
||||
// Otherwise, this is an extension or google.protobuf.Any type URL: we consume proto path
|
||||
// elements until we've addressed the type.
|
||||
String name = tokenizer.consumeIdentifier();
|
||||
while (tokenizer.tryConsume(".")) {
|
||||
name += "." + tokenizer.consumeIdentifier();
|
||||
}
|
||||
if (tokenizer.tryConsume("/")) {
|
||||
name += "/" + tokenizer.consumeIdentifier();
|
||||
while (tokenizer.tryConsume(".")) {
|
||||
name += "." + tokenizer.consumeIdentifier();
|
||||
}
|
||||
}
|
||||
tokenizer.consume("]");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a one or more field values from {@code tokenizer} and merge it into {@code builder}.
|
||||
*/
|
||||
@ -2058,8 +2076,13 @@ public final class TextFormat {
|
||||
// (java_proto_library for any_java_proto depends on the protobuf_impl).
|
||||
Message anyBuilder = DynamicMessage.getDefaultInstance(field.getMessageType());
|
||||
MessageReflection.MergeTarget anyField = target.newMergeTargetForField(field, anyBuilder);
|
||||
mergeAnyFieldValue(tokenizer, extensionRegistry, anyField, parseTreeBuilder,
|
||||
unknownFields, field.getMessageType());
|
||||
mergeAnyFieldValue(
|
||||
tokenizer,
|
||||
extensionRegistry,
|
||||
anyField,
|
||||
parseTreeBuilder,
|
||||
unknownFields,
|
||||
field.getMessageType());
|
||||
value = anyField.finish();
|
||||
tokenizer.consume(endToken);
|
||||
} else {
|
||||
@ -2206,7 +2229,7 @@ public final class TextFormat {
|
||||
throw tokenizer.parseExceptionPreviousToken("Expected a valid type URL.");
|
||||
}
|
||||
}
|
||||
detectSilentMarker(tokenizer);
|
||||
detectSilentMarker(tokenizer, typeUrlBuilder.toString());
|
||||
tokenizer.tryConsume(":");
|
||||
final String anyEndToken;
|
||||
if (tokenizer.tryConsume("<")) {
|
||||
@ -2244,15 +2267,7 @@ public final class TextFormat {
|
||||
|
||||
/** Skips the next field including the field's name and value. */
|
||||
private void skipField(Tokenizer tokenizer) throws ParseException {
|
||||
if (tokenizer.tryConsume("[")) {
|
||||
// Extension name.
|
||||
do {
|
||||
tokenizer.consumeIdentifier();
|
||||
} while (tokenizer.tryConsume("."));
|
||||
tokenizer.consume("]");
|
||||
} else {
|
||||
tokenizer.consumeIdentifier();
|
||||
}
|
||||
String name = consumeFullTypeName(tokenizer);
|
||||
|
||||
// Try to guess the type of this field.
|
||||
// If this field is not a message, there should be a ":" between the
|
||||
@ -2260,7 +2275,7 @@ public final class TextFormat {
|
||||
// start with "{" or "<" which indicates the beginning of a message body.
|
||||
// If there is no ":" or there is a "{" or "<" after ":", this field has
|
||||
// to be a message or the input is ill-formed.
|
||||
detectSilentMarker(tokenizer);
|
||||
detectSilentMarker(tokenizer, name);
|
||||
if (tokenizer.tryConsume(":") && !tokenizer.lookingAt("<") && !tokenizer.lookingAt("{")) {
|
||||
skipFieldValue(tokenizer);
|
||||
} else {
|
||||
@ -2469,9 +2484,10 @@ public final class TextFormat {
|
||||
}
|
||||
Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint);
|
||||
if (unicodeBlock != null
|
||||
&& (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES)
|
||||
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES)
|
||||
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) {
|
||||
&& (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES)
|
||||
|| unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES)
|
||||
|| unicodeBlock.equals(
|
||||
Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) {
|
||||
throw new InvalidEscapeSequenceException(
|
||||
"Invalid escape sequence: '\\U"
|
||||
+ input.substring(i, i + 8).toStringUtf8()
|
||||
|
@ -67,9 +67,7 @@ import org.junit.function.ThrowingRunnable;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/**
|
||||
* Test case for {@link TextFormat}.
|
||||
*/
|
||||
/** Test case for {@link TextFormat}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class TextFormatTest {
|
||||
|
||||
@ -1450,6 +1448,18 @@ public class TextFormatTest {
|
||||
+ "unknown_field3: 3\n");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParseUnknownExtensionWithAnyMessage() throws Exception {
|
||||
assertParseSuccessWithUnknownExtensions(
|
||||
"[unknown_extension]: { "
|
||||
+ " any_value { "
|
||||
+ " [type.googleapis.com/protobuf_unittest.OneString] { "
|
||||
+ " data: 123 "
|
||||
+ " } "
|
||||
+ " } "
|
||||
+ "}");
|
||||
}
|
||||
|
||||
// See additional coverage in testOneofOverwriteForbidden and testMapOverwriteForbidden.
|
||||
@Test
|
||||
public void testParseNonRepeatedFields() throws Exception {
|
||||
|
@ -2,8 +2,8 @@ load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
|
||||
load("@rules_java//java:defs.bzl", "java_lite_proto_library")
|
||||
load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export")
|
||||
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
|
||||
load("//:protobuf.bzl", "internal_gen_kt_protos")
|
||||
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
|
||||
|
||||
java_lite_proto_library(
|
||||
name = "example_extensible_message_java_proto_lite",
|
||||
@ -16,10 +16,27 @@ kt_jvm_library(
|
||||
deps = ["//java/lite"],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_well_known_protos_kotlinlite",
|
||||
lite = True,
|
||||
deps = [
|
||||
"//:any_proto",
|
||||
"//:api_proto",
|
||||
"//:duration_proto",
|
||||
"//:empty_proto",
|
||||
"//:field_mask_proto",
|
||||
"//:source_context_proto",
|
||||
"//:struct_proto",
|
||||
"//:timestamp_proto",
|
||||
"//:type_proto",
|
||||
"//:wrappers_proto",
|
||||
],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
name = "well_known_protos_kotlin_lite",
|
||||
srcs = [
|
||||
"//:gen_well_known_protos_kotlinlite",
|
||||
":gen_well_known_protos_kotlinlite",
|
||||
],
|
||||
deps = [
|
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
@ -36,7 +53,7 @@ kt_jvm_export(
|
||||
],
|
||||
maven_coordinates = "com.google.protobuf:protobuf-kotlin-lite:%s" % PROTOBUF_JAVA_VERSION,
|
||||
pom_template = "//java/kotlin-lite:pom_template.xml",
|
||||
resources = ["//:well_known_protos"],
|
||||
resources = ["//:well_known_type_protos"],
|
||||
tags = ["manual"],
|
||||
runtime_deps = [
|
||||
":lite_extensions",
|
||||
@ -120,32 +137,46 @@ internal_gen_kt_protos(
|
||||
deps = ["//java/kotlin:multiple_files_proto3"],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_unittest_lite",
|
||||
lite = True,
|
||||
deps = ["//src/google/protobuf:lite_test_protos"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
name = "kotlin_unittest_lite",
|
||||
srcs = [
|
||||
":gen_evil_names_proto2_lite",
|
||||
"//:gen_kotlin_unittest_lite",
|
||||
":gen_kotlin_unittest_lite",
|
||||
],
|
||||
deps = [
|
||||
":evil_names_proto2_java_proto_lite",
|
||||
"//:java_lite_test_protos",
|
||||
"//java/core:generic_test_protos_java_proto_lite",
|
||||
"//java/core:lite_test_protos_java_proto_lite",
|
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
"//java/kotlin:shared_runtime",
|
||||
"//java/lite",
|
||||
],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_proto3_unittest_lite",
|
||||
lite = True,
|
||||
deps = ["//src/google/protobuf:kt_proto3_unittest_protos"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
name = "kotlin_proto3_unittest_lite",
|
||||
srcs = [
|
||||
":gen_evil_names_proto3_lite",
|
||||
":gen_kotlin_proto3_java_multiple_files_lite",
|
||||
"//:gen_kotlin_proto3_unittest_lite",
|
||||
":gen_kotlin_proto3_unittest_lite",
|
||||
],
|
||||
deps = [
|
||||
":evil_names_proto3_java_proto_lite",
|
||||
":multiple_files_proto3_java_proto_lite",
|
||||
"//:java_lite_test_protos",
|
||||
"//java/core:generic_test_protos_java_proto_lite",
|
||||
"//java/core:lite_test_protos_java_proto_lite",
|
||||
"//java/kotlin:only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
"//java/kotlin:shared_runtime",
|
||||
"//java/lite",
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-kotlin-lite</artifactId>
|
||||
|
@ -58,7 +58,10 @@ kt_jvm_export(
|
||||
],
|
||||
maven_coordinates = "com.google.protobuf:protobuf-kotlin:%s" % PROTOBUF_JAVA_VERSION,
|
||||
pom_template = "//java/kotlin:pom_template.xml",
|
||||
resources = ["//:well_known_protos"],
|
||||
resources = [
|
||||
"//src/google/protobuf:descriptor_proto_srcs",
|
||||
"//:well_known_type_protos",
|
||||
],
|
||||
tags = ["manual"],
|
||||
runtime_deps = [
|
||||
":bytestring_lib",
|
||||
@ -218,36 +221,49 @@ internal_gen_kt_protos(
|
||||
deps = [":multiple_files_proto3"],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_unittest",
|
||||
visibility = ["//java:__subpackages__"],
|
||||
deps = ["//src/google/protobuf:kt_unittest_protos"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
name = "kotlin_unittest",
|
||||
srcs = [
|
||||
":gen_evil_names_proto2",
|
||||
"//:gen_kotlin_unittest",
|
||||
":gen_kotlin_unittest",
|
||||
],
|
||||
deps = [
|
||||
":evil_names_proto2_java_proto",
|
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
":shared_runtime",
|
||||
":well_known_protos_kotlin",
|
||||
"//:java_test_protos",
|
||||
"//java/core",
|
||||
"//java/core:generic_test_protos_java_proto",
|
||||
"//java/core:lite_test_protos_java_proto",
|
||||
],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_kotlin_proto3_unittest",
|
||||
deps = ["//src/google/protobuf:kt_proto3_unittest_protos"],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
name = "kotlin_proto3_unittest",
|
||||
srcs = [
|
||||
":gen_evil_names_proto3",
|
||||
":gen_kotlin_proto3_java_multiple_files",
|
||||
"//:gen_kotlin_proto3_unittest",
|
||||
":gen_kotlin_proto3_unittest",
|
||||
],
|
||||
deps = [
|
||||
":evil_names_proto3_java_proto",
|
||||
":multiple_files_proto3_java_proto",
|
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
":shared_runtime",
|
||||
"//:java_test_protos",
|
||||
"//java/core",
|
||||
"//java/core:generic_test_protos_java_proto",
|
||||
"//java/core:lite_test_protos_java_proto",
|
||||
],
|
||||
)
|
||||
|
||||
@ -285,10 +301,31 @@ java_test(
|
||||
runtime_deps = [":proto3_test_library"],
|
||||
)
|
||||
|
||||
internal_gen_kt_protos(
|
||||
name = "gen_well_known_protos_kotlin",
|
||||
visibility = [
|
||||
"//java:__subpackages__",
|
||||
],
|
||||
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",
|
||||
],
|
||||
)
|
||||
|
||||
kt_jvm_library(
|
||||
name = "well_known_protos_kotlin",
|
||||
srcs = [
|
||||
"//:gen_well_known_protos_kotlin",
|
||||
":gen_well_known_protos_kotlin",
|
||||
],
|
||||
deps = [
|
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-kotlin</artifactId>
|
||||
|
@ -29,7 +29,7 @@ protobuf Java Lite runtime. If you are using Maven, include the following:
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-javalite</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
||||
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
|
||||
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
|
||||
load("//:internal.bzl", "conformance_test")
|
||||
load("//conformance:defs.bzl", "conformance_test")
|
||||
load("//java/internal:testing.bzl", "junit_tests")
|
||||
|
||||
exports_files(
|
||||
@ -59,9 +59,9 @@ build_test(
|
||||
|
||||
conformance_test(
|
||||
name = "conformance_test",
|
||||
failure_list = "//:conformance/failure_list_java_lite.txt",
|
||||
testee = "//:conformance_java_lite",
|
||||
text_format_failure_list = "//:conformance/text_format_failure_list_java_lite.txt",
|
||||
failure_list = "//conformance:failure_list_java_lite.txt",
|
||||
testee = "//conformance:conformance_java_lite",
|
||||
text_format_failure_list = "//conformance:text_format_failure_list_java_lite.txt",
|
||||
)
|
||||
|
||||
junit_tests(
|
||||
@ -72,6 +72,7 @@ junit_tests(
|
||||
":lite",
|
||||
"//java/core:generic_test_protos_java_proto_lite",
|
||||
"//java/core:java_test_protos_java_proto_lite",
|
||||
"//java/core:lite_test_protos_java_proto_lite",
|
||||
"//java/core:test_util_lite",
|
||||
"@maven//:com_google_truth_truth",
|
||||
"@maven//:junit_junit",
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-javalite</artifactId>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Protocol Buffers [Parent]</name>
|
||||
|
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-parent</artifactId>
|
||||
<version>3.20.1</version>
|
||||
<version>3.21.0-rc-1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#
|
||||
# Use the provided functions below as build/test fixtures, e.g.:
|
||||
#
|
||||
# source kokoro/capture_logs.sh
|
||||
# source kokoro/common/capture_logs.sh
|
||||
# caplog build/step1 <build command>
|
||||
# caplog tests/step2 <test command>
|
||||
#
|
55
kokoro/common/check_missing_dist_files.sh
Executable file
55
kokoro/common/check_missing_dist_files.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Script to compare a distribution archive for expected files based on git.
|
||||
#
|
||||
# Usage:
|
||||
# check_missing_dist_files.sh path/to/dist_archive.tar.gz
|
||||
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
# By default, look for a git repo based on this script's path.
|
||||
: ${SOURCE_DIR:=$(cd $(dirname $0)/../.. ; pwd)}
|
||||
|
||||
# Use a temporary directory for intermediate files.
|
||||
# Note that pipelines below use subshells to avoid multiple trap executions.
|
||||
_workdir=$(mktemp -d)
|
||||
function cleanup_workdir() { rm -r ${_workdir}; }
|
||||
trap cleanup_workdir EXIT
|
||||
|
||||
# List all the files in the archive.
|
||||
(
|
||||
tar -atf $1 | \
|
||||
cut -d/ -f2- | \
|
||||
sort
|
||||
) > ${_workdir}/archive.lst
|
||||
|
||||
# List all files in the git repo that should be in the archive.
|
||||
(
|
||||
git -C ${SOURCE_DIR} ls-files | \
|
||||
grep "^\(java\|python\|objectivec\|csharp\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\
|
||||
grep -v ".gitignore" | \
|
||||
grep -v "java/lite/proguard.pgcfg" | \
|
||||
grep -v "python/compatibility_tests" | \
|
||||
grep -v "python/docs" | \
|
||||
grep -v "python/.repo-metadata.json" | \
|
||||
grep -v "python/protobuf_distutils" | \
|
||||
grep -v "csharp/compatibility_tests" | \
|
||||
sort
|
||||
) > ${_workdir}/expected.lst
|
||||
|
||||
# Check for missing files.
|
||||
MISSING_FILES=( $(cd ${_workdir} && comm -13 archive.lst expected.lst) )
|
||||
if (( ${#MISSING_FILES[@]} == 0 )); then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
(
|
||||
set +x
|
||||
echo -e "\n\nMissing files from archive:"
|
||||
for (( i=0 ; i < ${#MISSING_FILES[@]} ; i++ )); do
|
||||
echo " ${MISSING_FILES[i]}"
|
||||
done
|
||||
echo -e "\nAdd them to the 'pkg_files' rule in corresponding BUILD.bazel.\n"
|
||||
) >&2
|
||||
exit 1
|
84
kokoro/common/cmake.sh
Executable file
84
kokoro/common/cmake.sh
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build tests under CMake.
|
||||
#
|
||||
# This script is used from macos and linux builds. It runs cmake and ctest in
|
||||
# the current directory. Any additional setup should be done before running this
|
||||
# script.
|
||||
#
|
||||
# This script uses `caplog` to save logfiles. See caplog.sh for details.
|
||||
|
||||
set -eu -o pipefail
|
||||
: ${SCRIPT_ROOT:=$(cd $(dirname $0)/../..; pwd)}
|
||||
|
||||
################################################################################
|
||||
# If you are using this script to run tests, you can set some environment
|
||||
# variables to control behavior:
|
||||
#
|
||||
# By default, find the sources based on this script's path.
|
||||
: ${SOURCE_DIR:=${SCRIPT_ROOT}}
|
||||
#
|
||||
# By default, put outputs under <git root>/cmake/build.
|
||||
: ${BUILD_DIR:=${SOURCE_DIR}/cmake/build}
|
||||
#
|
||||
# CMAKE_BUILD_TYPE is supported in cmake 3.22+. If set, we pass the value of this
|
||||
# variable explicitly for compatibility with older versions of cmake. See:
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html
|
||||
# (N.B.: not to be confused with CMAKE_CONFIG_TYPE.)
|
||||
if [[ -n ${CMAKE_BUILD_TYPE:-} ]]; then
|
||||
CMAKE_BUILD_TYPE_FLAG="-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
|
||||
else
|
||||
CMAKE_BUILD_TYPE_FLAG=
|
||||
fi
|
||||
#
|
||||
# For several other CMake options, see docs here:
|
||||
# https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html
|
||||
#
|
||||
# Some variables you may want to override (see cmake docs for details):
|
||||
# CMAKE_BUILD_PARALLEL_LEVEL
|
||||
# CMAKE_CONFIG_TYPE (N.B.: not to be confused with CMAKE_BUILD_TYPE)
|
||||
# CMAKE_GENERATOR
|
||||
# CTEST_PARALLEL_LEVEL
|
||||
################################################################################
|
||||
|
||||
echo "Building using..."
|
||||
echo " Sources: ${SOURCE_DIR}"
|
||||
echo " Build output: ${BUILD_DIR}"
|
||||
if [[ ${SOURCE_DIR} != ${SCRIPT_ROOT} ]]; then
|
||||
echo " Build scripts: ${SCRIPT_ROOT}"
|
||||
fi
|
||||
set -x
|
||||
source ${SCRIPT_ROOT}/kokoro/common/caplog.sh
|
||||
|
||||
#
|
||||
# Configure under $BUILD_DIR:
|
||||
#
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
(
|
||||
cd "${BUILD_DIR}"
|
||||
caplog 01_configure \
|
||||
cmake -S "${SOURCE_DIR}" \
|
||||
${CMAKE_BUILD_TYPE_FLAG} \
|
||||
${CAPLOG_CMAKE_ARGS:-}
|
||||
)
|
||||
if [[ -n ${CAPLOG_DIR:-} ]]; then
|
||||
# Save configuration logs.
|
||||
mkdir -p "${CAPLOG_DIR}/CMakeFiles"
|
||||
cp "${BUILD_DIR}"/CMakeFiles/CMake*.log "${CAPLOG_DIR}/CMakeFiles"
|
||||
fi
|
||||
|
||||
#
|
||||
# Build:
|
||||
#
|
||||
caplog 02_build \
|
||||
cmake --build "${BUILD_DIR}"
|
||||
|
||||
#
|
||||
# Run tests
|
||||
#
|
||||
(
|
||||
cd "${BUILD_DIR}"
|
||||
caplog 03_combined_testlog \
|
||||
ctest ${CAPLOG_CTEST_ARGS:-}
|
||||
)
|
@ -14,8 +14,8 @@ sudo apt-get -y install software-properties-common
|
||||
sudo add-apt-repository universe
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install unzip
|
||||
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.15.8/protoc-3.15.8-linux-x86_64.zip
|
||||
unzip protoc-3.15.8-linux-x86_64.zip bin/protoc
|
||||
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.0-rc1/protoc-21.0-rc-1-linux-x86_64.zip
|
||||
unzip protoc-21.0-rc-1-linux-x86_64.zip bin/protoc
|
||||
mv bin/protoc ../src/protoc
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
@ -30,7 +30,7 @@ make html
|
||||
cd ..
|
||||
deactivate
|
||||
|
||||
python3 -m pip install protobuf==3.15.8 gcp-docuploader
|
||||
python3 -m pip install protobuf==4.21.0rc1 gcp-docuploader
|
||||
|
||||
# install a json parser
|
||||
sudo apt-get -y install jq
|
||||
|
@ -7,16 +7,6 @@ set -ex
|
||||
use_bazel.sh 4.0.0
|
||||
bazel version
|
||||
|
||||
# Print bazel testlogs to stdout when tests failed.
|
||||
function print_test_logs {
|
||||
# TODO(yannic): Only print logs of failing tests.
|
||||
testlogs_dir=$(bazel info bazel-testlogs)
|
||||
testlogs=$(find "${testlogs_dir}" -name "*.log")
|
||||
for log in $testlogs; do
|
||||
cat "${log}"
|
||||
done
|
||||
}
|
||||
|
||||
# Change to repo root
|
||||
cd $(dirname $0)/../../..
|
||||
|
||||
@ -25,19 +15,13 @@ git submodule update --init --recursive
|
||||
# Disabled for now, re-enable if appropriate.
|
||||
# //:build_files_updated_unittest \
|
||||
|
||||
trap print_test_logs EXIT
|
||||
bazel test -k --copt=-Werror --host_copt=-Werror \
|
||||
bazel test \
|
||||
-k --copt=-Werror --host_copt=-Werror --test_output=errors \
|
||||
//build_defs:all \
|
||||
//java:tests \
|
||||
//:protoc \
|
||||
//:protobuf \
|
||||
//src/... \
|
||||
//:protobuf_python \
|
||||
//:protobuf_test \
|
||||
@com_google_protobuf//:cc_proto_blacklist_test
|
||||
trap - EXIT
|
||||
|
||||
pushd examples
|
||||
bazel build //...
|
||||
popd
|
||||
@com_google_protobuf_examples//...
|
||||
|
||||
# Verify that we can build successfully from generated tar files.
|
||||
./autogen.sh && ./configure && make -j$(nproc) dist
|
||||
|
89
kokoro/linux/bazel_distcheck/build.sh
Executable file
89
kokoro/linux/bazel_distcheck/build.sh
Executable file
@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build file to set up and run tests using bazel-build dist archive
|
||||
#
|
||||
# Note that the builds use WORKSPACE to fetch external sources, not
|
||||
# git submodules.
|
||||
|
||||
set -eux
|
||||
|
||||
BUILD_ONLY_TARGETS=(
|
||||
//pkg:all
|
||||
//:protoc
|
||||
//:protobuf
|
||||
//:protobuf_python
|
||||
)
|
||||
|
||||
TEST_TARGETS=(
|
||||
//build_defs:all
|
||||
//conformance:all
|
||||
//java:tests
|
||||
//python:all
|
||||
//src/...
|
||||
@com_google_protobuf_examples//...
|
||||
)
|
||||
|
||||
CONTAINER_NAME=gcr.io/protobuf-build/bazel/linux
|
||||
CONTAINER_VERSION=5.1.1-e41ccfa1648716433276ebe077c665796550fcbb
|
||||
|
||||
use_bazel.sh 5.0.0 || true
|
||||
bazel version
|
||||
|
||||
# Change to repo root
|
||||
cd $(dirname $0)/../../..
|
||||
|
||||
# Construct temp directory for running the dist build.
|
||||
# If you want to run locally and keep the build dir, create a directory
|
||||
# and pass it in the DIST_WORK_ROOT env var.
|
||||
if [[ -z ${DIST_WORK_ROOT:-} ]]; then
|
||||
: ${DIST_WORK_ROOT:=$(mktemp -d)}
|
||||
function dist_cleanup() {
|
||||
rm -rf ${DIST_WORK_ROOT}
|
||||
}
|
||||
trap dist_cleanup EXIT
|
||||
fi
|
||||
|
||||
# Let Bazel share the distdir.
|
||||
TMP_DISTDIR=${DIST_WORK_ROOT}/bazel-distdir
|
||||
mkdir -p ${TMP_DISTDIR}
|
||||
|
||||
# Build distribution archive
|
||||
date
|
||||
bazel fetch --distdir=${TMP_DISTDIR} //pkg:dist_all_tar
|
||||
bazel build --distdir=${TMP_DISTDIR} //pkg:dist_all_tar
|
||||
DIST_ARCHIVE=$(readlink $(bazel info bazel-bin)/pkg/dist_all_tar.tar.gz)
|
||||
bazel shutdown
|
||||
|
||||
# The `pkg_tar` rule emits a symlink based on the rule name. The actual
|
||||
# file is named with the current version.
|
||||
date
|
||||
echo "Resolved archive path: ${DIST_ARCHIVE}"
|
||||
|
||||
# Extract the dist archive.
|
||||
date
|
||||
DIST_WORKSPACE=${DIST_WORK_ROOT}/protobuf
|
||||
mkdir -p ${DIST_WORKSPACE}
|
||||
tar -C ${DIST_WORKSPACE} --strip-components=1 -axf ${DIST_ARCHIVE}
|
||||
|
||||
# Perform build steps in the extracted dist sources.
|
||||
|
||||
cd ${DIST_WORKSPACE}
|
||||
FAILED=false
|
||||
|
||||
until docker pull gcr.io/protobuf-build/bazel/linux:${CONTAINER_VERSION}; do
|
||||
sleep 10
|
||||
done
|
||||
|
||||
date
|
||||
docker run --rm \
|
||||
-v ${DIST_WORKSPACE}:/workspace \
|
||||
-v ${TMP_DISTDIR}:${TMP_DISTDIR} \
|
||||
${CONTAINER_NAME}:${CONTAINER_VERSION} \
|
||||
test --distdir=${TMP_DISTDIR} --test_output=errors -k \
|
||||
"${BUILD_ONLY_TARGETS[@]}" "${TEST_TARGETS[@]}" || FAILED=true
|
||||
|
||||
if ${FAILED}; then
|
||||
echo FAILED
|
||||
exit 1
|
||||
fi
|
||||
echo PASS
|
5
kokoro/linux/bazel_distcheck/continuous.cfg
Normal file
5
kokoro/linux/bazel_distcheck/continuous.cfg
Normal file
@ -0,0 +1,5 @@
|
||||
# Config file for running tests in Kokoro
|
||||
|
||||
# Location of the build script in repository
|
||||
build_file: "protobuf/kokoro/linux/bazel_distcheck/build.sh"
|
||||
timeout_mins: 15
|
5
kokoro/linux/bazel_distcheck/presubmit.cfg
Normal file
5
kokoro/linux/bazel_distcheck/presubmit.cfg
Normal file
@ -0,0 +1,5 @@
|
||||
# Config file for running tests in Kokoro
|
||||
|
||||
# Location of the build script in repository
|
||||
build_file: "protobuf/kokoro/linux/bazel_distcheck/build.sh"
|
||||
timeout_mins: 15
|
66
kokoro/linux/cmake_distcheck/build.sh
Executable file
66
kokoro/linux/cmake_distcheck/build.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Build file to set up and run tests based on distribution archive
|
||||
|
||||
set -eux
|
||||
|
||||
# Change to repo root
|
||||
cd $(dirname $0)/../../..
|
||||
|
||||
#
|
||||
# Update git submodules
|
||||
#
|
||||
git submodule update --init --recursive
|
||||
|
||||
#
|
||||
# Build distribution archive
|
||||
#
|
||||
# TODO: this should use Bazel-built dist archives.
|
||||
date ; ./autogen.sh
|
||||
date ; ./configure
|
||||
date ; make dist
|
||||
date
|
||||
|
||||
DIST_ARCHIVE=( $(ls protobuf-*.tar.gz) )
|
||||
if (( ${#DIST_ARCHIVE[@]} != 1 )); then
|
||||
echo >&2 "Distribution archive not found. ${#DIST_ARCHIVE[@]} matches:"
|
||||
echo >&2 "${DIST_ARCHIVE[@]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Check for all expected files
|
||||
#
|
||||
kokoro/common/check_missing_dist_files.sh ${DIST_ARCHIVE}
|
||||
|
||||
#
|
||||
# Extract to a temporary directory
|
||||
#
|
||||
if [[ -z ${DIST_WORK_ROOT:-} ]]; then
|
||||
# If you want to preserve the extracted sources, set the DIST_WORK_ROOT
|
||||
# environment variable to an existing directory that should be used.
|
||||
DIST_WORK_ROOT=$(mktemp -d)
|
||||
function cleanup_work_root() {
|
||||
echo "Cleaning up temporary directory ${DIST_WORK_ROOT}..."
|
||||
rm -rf ${DIST_WORK_ROOT}
|
||||
}
|
||||
trap cleanup_work_root EXIT
|
||||
fi
|
||||
|
||||
tar -C ${DIST_WORK_ROOT} --strip-components=1 -axf ${DIST_ARCHIVE}
|
||||
|
||||
#
|
||||
# Run tests using extracted sources
|
||||
#
|
||||
if SOURCE_DIR=${DIST_WORK_ROOT} \
|
||||
CMAKE_GENERATOR=Ninja \
|
||||
CTEST_PARALLEL_LEVEL=$(nproc) \
|
||||
kokoro/common/cmake.sh; then
|
||||
# TODO: remove this conditional.
|
||||
# The cmake build is expected to fail due to missing abseil sources.
|
||||
echo "$0: Expected failure, but build passed." >&2
|
||||
echo "Please update $(basename $0) to remove failure expectation." >&2
|
||||
echo "FAIL" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "PASS"
|
5
kokoro/linux/cmake_distcheck/continuous.cfg
Normal file
5
kokoro/linux/cmake_distcheck/continuous.cfg
Normal file
@ -0,0 +1,5 @@
|
||||
# Config file for running tests in Kokoro
|
||||
|
||||
# Location of the build script in repository
|
||||
build_file: "protobuf/kokoro/linux/cmake_distcheck/build.sh"
|
||||
timeout_mins: 1440
|
5
kokoro/linux/cmake_distcheck/presubmit.cfg
Normal file
5
kokoro/linux/cmake_distcheck/presubmit.cfg
Normal file
@ -0,0 +1,5 @@
|
||||
# Config file for running tests in Kokoro
|
||||
|
||||
# Location of the build script in repository
|
||||
build_file: "protobuf/kokoro/linux/cmake_distcheck/build.sh"
|
||||
timeout_mins: 1440
|
@ -9,47 +9,21 @@ if [[ -h /tmpfs ]] && [[ ${PWD} == /tmpfs/src ]]; then
|
||||
cd /Volumes/BuildData/tmpfs/src
|
||||
fi
|
||||
|
||||
# These vars can be changed when running manually, e.g.:
|
||||
#
|
||||
# % BUILD_CONFIG=RelWithDebInfo path/to/build.sh
|
||||
# Default environment variables used by cmake build:
|
||||
: ${CMAKE_CONFIG_TYPE:=Debug}
|
||||
export CMAKE_CONFIG_TYPE
|
||||
: ${CTEST_PARALLEL_LEVEL:=4}
|
||||
export CTEST_PARALLEL_LEVEL
|
||||
|
||||
# By default, build using Debug config.
|
||||
: ${BUILD_CONFIG:=Debug}
|
||||
|
||||
# By default, find the sources based on this script path.
|
||||
: ${SOURCE_DIR:=$(cd $(dirname $0)/../../..; pwd)}
|
||||
|
||||
# By default, put outputs under <git root>/cmake/build.
|
||||
: ${BUILD_DIR:=${SOURCE_DIR}/cmake/build}
|
||||
|
||||
source ${SOURCE_DIR}/kokoro/caplog.sh
|
||||
# Run from the project root directory.
|
||||
cd $(dirname $0)/../../..
|
||||
|
||||
#
|
||||
# Update submodules
|
||||
#
|
||||
git -C "${SOURCE_DIR}" submodule update --init --recursive
|
||||
git submodule update --init --recursive
|
||||
|
||||
#
|
||||
# Configure and build in a separate directory
|
||||
# Run build
|
||||
#
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
caplog 01_configure \
|
||||
cmake -S "${SOURCE_DIR}" -B "${BUILD_DIR}" ${CAPLOG_CMAKE_ARGS:-}
|
||||
|
||||
if [[ -n ${CAPLOG_DIR:-} ]]; then
|
||||
mkdir -p "${CAPLOG_DIR}/CMakeFiles"
|
||||
cp "${BUILD_DIR}"/CMakeFiles/CMake*.log "${CAPLOG_DIR}/CMakeFiles"
|
||||
fi
|
||||
|
||||
caplog 02_build \
|
||||
cmake --build "${BUILD_DIR}" --config "${BUILD_CONFIG}"
|
||||
|
||||
#
|
||||
# Run tests
|
||||
#
|
||||
(
|
||||
cd "${BUILD_DIR}"
|
||||
caplog 03_combined_testlog \
|
||||
ctest -C "${BUILD_CONFIG}" -j4 ${CAPLOG_CTEST_ARGS:-}
|
||||
)
|
||||
kokoro/common/cmake.sh
|
||||
|
@ -27,11 +27,10 @@ function pre_build {
|
||||
|
||||
# Build protoc and protobuf libraries
|
||||
use_bazel.sh 5.1.1
|
||||
bazel build //:protoc
|
||||
export PROTOC=$PWD/bazel-bin/protoc
|
||||
mkdir src/.libs
|
||||
ln -s $PWD/bazel-bin/libprotobuf.a src/.libs/libprotobuf.a
|
||||
ln -s $PWD/bazel-bin/libprotobuf_lite.a src/.libs/libprotobuf-lite.a
|
||||
bazel build -c opt //:protoc //pkg:protobuf //pkg:protobuf_lite
|
||||
local _bazel_bin=$(bazel info -c opt bazel-bin)
|
||||
export PROTOC=${_bazel_bin}/protoc
|
||||
export LIBPROTOBUF=${_bazel_bin}/pkg/libprotobuf.a
|
||||
|
||||
# Generate python dependencies.
|
||||
pushd python
|
||||
@ -53,7 +52,8 @@ function bdist_wheel_cmd {
|
||||
# Modify build version
|
||||
pwd
|
||||
ls
|
||||
python setup.py bdist_wheel --cpp_implementation --compile_static_extension
|
||||
python setup.py build_ext --cpp_implementation -O${LIBPROTOBUF}
|
||||
python setup.py bdist_wheel --cpp_implementation
|
||||
cp dist/*.whl $abs_wheelhouse
|
||||
}
|
||||
|
||||
|
@ -601,12 +601,11 @@ PHP_METHOD(Message, __construct) {
|
||||
//
|
||||
// However, if the user created their own class derived from Message, this
|
||||
// will trigger an infinite construction loop and blow the stack. We
|
||||
// temporarily clear create_object to break this loop (see check in
|
||||
// store this `ce` in a global variable to break the cycle (see the check in
|
||||
// NameMap_GetMessage()).
|
||||
PBPHP_ASSERT(ce->create_object == Message_create);
|
||||
ce->create_object = NULL;
|
||||
NameMap_EnterConstructor(ce);
|
||||
desc = Descriptor_GetFromClassEntry(ce);
|
||||
ce->create_object = Message_create;
|
||||
NameMap_ExitConstructor(ce);
|
||||
|
||||
if (!desc) {
|
||||
zend_throw_exception_ex(
|
||||
|
@ -10,11 +10,11 @@
|
||||
<email>protobuf-opensource@google.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2022-04-20</date>
|
||||
<time>22:01:25</time>
|
||||
<date>2022-05-10</date>
|
||||
<time>11:33:40</time>
|
||||
<version>
|
||||
<release>3.20.1</release>
|
||||
<api>3.20.1</api>
|
||||
<release>3.21.0RC1</release>
|
||||
<api>3.21.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
@ -1283,5 +1283,20 @@ G A release.
|
||||
<notes>
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>3.21.0RC1</release>
|
||||
<api>3.21.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2022-05-10</date>
|
||||
<time>11:33:40</time>
|
||||
<license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
|
||||
<notes>
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
|
@ -56,6 +56,9 @@ ZEND_BEGIN_MODULE_GLOBALS(protobuf)
|
||||
// Set by the user to make the descriptor pool persist between requests.
|
||||
zend_bool keep_descriptor_pool_after_request;
|
||||
|
||||
// Set by the user to make the descriptor pool persist between requests.
|
||||
zend_class_entry* constructing_class;
|
||||
|
||||
// A upb_DefPool that we are saving for the next request so that we don't have
|
||||
// to rebuild it from scratch. When keep_descriptor_pool_after_request==true,
|
||||
// we steal the upb_DefPool from the global DescriptorPool object just before
|
||||
@ -173,6 +176,7 @@ static PHP_RINIT_FUNCTION(protobuf) {
|
||||
|
||||
zend_hash_init(&PROTOBUF_G(object_cache), 64, NULL, NULL, 0);
|
||||
zend_hash_init(&PROTOBUF_G(descriptors), 64, NULL, ZVAL_PTR_DTOR, 0);
|
||||
PROTOBUF_G(constructing_class) = NULL;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -253,7 +257,7 @@ const upb_MessageDef *NameMap_GetMessage(zend_class_entry *ce) {
|
||||
const upb_MessageDef *ret =
|
||||
zend_hash_find_ptr(&PROTOBUF_G(name_msg_cache), ce->name);
|
||||
|
||||
if (!ret && ce->create_object) {
|
||||
if (!ret && ce->create_object && ce != PROTOBUF_G(constructing_class)) {
|
||||
#if PHP_VERSION_ID < 80000
|
||||
zval tmp;
|
||||
zval zv;
|
||||
@ -279,6 +283,16 @@ const upb_EnumDef *NameMap_GetEnum(zend_class_entry *ce) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void NameMap_EnterConstructor(zend_class_entry* ce) {
|
||||
assert(!PROTOBUF_G(constructing_class));
|
||||
PROTOBUF_G(constructing_class) = ce;
|
||||
}
|
||||
|
||||
void NameMap_ExitConstructor(zend_class_entry* ce) {
|
||||
assert(PROTOBUF_G(constructing_class) == ce);
|
||||
PROTOBUF_G(constructing_class) = NULL;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Module init.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -127,7 +127,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_setter, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, value)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define PHP_PROTOBUF_VERSION "3.20.1"
|
||||
#define PHP_PROTOBUF_VERSION "3.21.0RC1"
|
||||
|
||||
// ptr -> PHP object cache. This is a weak map that caches lazily-created
|
||||
// wrapper objects around upb types:
|
||||
@ -155,6 +155,8 @@ void NameMap_AddMessage(const upb_MessageDef *m);
|
||||
void NameMap_AddEnum(const upb_EnumDef *m);
|
||||
const upb_MessageDef *NameMap_GetMessage(zend_class_entry *ce);
|
||||
const upb_EnumDef *NameMap_GetEnum(zend_class_entry *ce);
|
||||
void NameMap_EnterConstructor(zend_class_entry* ce);
|
||||
void NameMap_ExitConstructor(zend_class_entry* ce);
|
||||
|
||||
// Add this descriptor object to the global list of descriptors that will be
|
||||
// kept alive for the duration of the request but destroyed when the request
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user