Sync from Piper @482325250

PROTOBUF_SYNC_PIPER
pull/10796/head
Mike Kruskal 2022-10-19 16:10:10 -07:00
commit 407aa2d931
335 changed files with 5412 additions and 7343 deletions

View File

@ -13,4 +13,4 @@ jobs:
with:
check_filenames: true
skip: ./.git,./conformance/third_party,*.snk,*.pb,*.pb.cc,*.pb.h,./src/google/protobuf/testdata,./objectivec/Tests,./python/compatibility_tests/v2.5.0/tests/google/protobuf/internal,./.github/workflows/codespell.yml
ignore_words_list: "alow,alse,ba,chec,cleare,copyable,cloneable,dedup,dur,errorprone,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur,falsy"
ignore_words_list: "alow,alse,ba,chec,cleare,copyable,cloneable,dedup,dur,errorprone,falsy,files',fo,fundementals,hel,importd,inout,leapyear,nd,nin,ois,ons,parseable,process',ro,te,testof,ue,unparseable,wasn,wee,gae,keyserver,objext,od,optin,streem,sur,falsy"

3
.gitmodules vendored
View File

@ -9,3 +9,6 @@
[submodule "third_party/jsoncpp"]
path = third_party/jsoncpp
url = https://github.com/open-source-parsers/jsoncpp.git
[submodule "third_party/utf8_range"]
path = third_party/utf8_range
url = https://github.com/protocolbuffers/utf8_range.git

View File

@ -67,6 +67,20 @@
Compiler
* Print full path name of source .proto file on error
2022-10-18 version 21.8 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
Other
* Fix for grpc.tools #17995 & protobuf #7474 (handle UTF-8 paths in argumentfile) (#10721)
C++
* 21.x No longer define no_threadlocal on OpenBSD (#10743)
Java
* Mark default instance as immutable first to avoid race during static initialization of default instances (#10771)
Ruby
* Auto capitalize enums name in Ruby (#10454) (#10763)
2022-09-29 version 21.7 (C++/Java/Python/PHP/Objective-C/C#/Ruby)
Java
* Refactoring java full runtime to reuse sub-message builders and prepare to

View File

@ -330,6 +330,7 @@ set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package")
include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake)
if (protobuf_BUILD_PROTOBUF_BINARIES)
include(${protobuf_SOURCE_DIR}/cmake/utf8_range.cmake)
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
if (NOT DEFINED protobuf_LIB_PROTOBUF_LITE)
set(protobuf_LIB_PROTOBUF_LITE libprotobuf-lite)

View File

@ -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.21.7'
s.version = '3.21.8'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/protocolbuffers/protobuf'
s.license = 'BSD-3-Clause'

View File

@ -80,6 +80,9 @@ upb_deps()
load("@upb//bazel:system_python.bzl", "system_python")
system_python(name = "local_config_python")
load("@utf8_range//:workspace_deps.bzl", "utf8_range_deps")
utf8_range_deps()
bind(
name = "python_headers",
actual = "@local_config_python//:python_headers",

View File

@ -14,16 +14,16 @@ COPTS = select({
"/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.
"/std:c++14", # Use C++14
],
"//conditions:default": [
"-DHAVE_ZLIB",
"-Woverloaded-virtual",
"-Wno-sign-compare",
"-Werror",
"-std=c++14", # Protobuf requires C++14.
],
}) + [
"-std=c++14", # Protobuf requires C++14.
]
})
# Android and MSVC builds do not need to link in a separate pthread library.
LINK_OPTS = select({

View File

@ -1,4 +1,14 @@
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/jsoncpp/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/jsoncpp directory that's needed to "
"build conformance tests. If you use git, make sure you have cloned "
"submodules:\n"
" git submodule update --init --recursive\n"
"If instead you want to skip them, run cmake with:\n"
" cmake -Dprotobuf_BUILD_CONFORMANCE=OFF\n")
endif()
add_custom_command(
OUTPUT
${protobuf_SOURCE_DIR}/conformance/conformance.pb.h
@ -33,8 +43,6 @@ add_executable(conformance_test_runner
${protobuf_SOURCE_DIR}/conformance/conformance_test_main.cc
${protobuf_SOURCE_DIR}/conformance/text_format_conformance_suite.cc
${protobuf_SOURCE_DIR}/conformance/text_format_conformance_suite.h
${protobuf_SOURCE_DIR}/conformance/third_party/jsoncpp/json.h
${protobuf_SOURCE_DIR}/conformance/third_party/jsoncpp/jsoncpp.cpp
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.h
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto2.pb.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/test_messages_proto3.pb.h
@ -74,3 +82,8 @@ add_test(NAME conformance_cpp_test
--output_dir ${protobuf_TEST_XML_OUTDIR}
${CMAKE_CURRENT_BINARY_DIR}/conformance_cpp
DEPENDS conformance_test_runner conformance_cpp)
set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Disable tests")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp third_party/jsoncpp)
target_include_directories(conformance_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp/include)
target_link_libraries(conformance_test_runner jsoncpp_lib)

View File

@ -34,3 +34,6 @@ set_target_properties(libprotobuf-lite PROPERTIES
OUTPUT_NAME ${LIB_PREFIX}protobuf-lite
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
target_include_directories(libprotobuf-lite PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
target_link_libraries(libprotobuf-lite PRIVATE utf8_validity)

View File

@ -37,3 +37,6 @@ set_target_properties(libprotobuf PROPERTIES
OUTPUT_NAME ${LIB_PREFIX}protobuf
DEBUG_POSTFIX "${protobuf_DEBUG_POSTFIX}")
add_library(protobuf::libprotobuf ALIAS libprotobuf)
target_include_directories(libprotobuf PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
target_link_libraries(libprotobuf PRIVATE utf8_validity)

12
cmake/utf8_range.cmake Normal file
View File

@ -0,0 +1,12 @@
set(utf8_range_ENABLE_TESTS OFF)
if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt")
message(FATAL_ERROR
"Cannot find third_party/utf8_range directory that's needed to "
"build conformance tests. If you use git, make sure you have cloned "
"submodules:\n"
" git submodule update --init --recursive\n")
endif()
set(utf8_range_ENABLE_INSTALL ${protobuf_INSTALL})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range third_party/utf8_range)

View File

@ -5,7 +5,6 @@ load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_li
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load(
"@rules_pkg//:mappings.bzl",
"pkg_attributes",
"pkg_filegroup",
"pkg_files",
"strip_prefix",
@ -126,13 +125,6 @@ internal_ruby_proto_library(
],
)
cc_library(
name = "jsoncpp",
srcs = ["third_party/jsoncpp/jsoncpp.cpp"],
hdrs = ["third_party/jsoncpp/json.h"],
includes = ["."],
)
cc_library(
name = "conformance_test",
srcs = [
@ -156,10 +148,10 @@ cc_library(
hdrs = ["binary_json_conformance_suite.h"],
deps = [
":conformance_test",
":jsoncpp",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
"@com_google_absl//absl/status",
"@jsoncpp",
],
)
@ -368,19 +360,10 @@ pkg_files(
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__"],
)

View File

@ -36,7 +36,7 @@
#include "google/protobuf/util/type_resolver_util.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "third_party/jsoncpp/json.h"
#include "json/json.h"
#include "conformance/conformance.pb.h"
#include "conformance_test.h"
#include "google/protobuf/test_messages_proto2.pb.h"

View File

@ -32,7 +32,7 @@
#define CONFORMANCE_BINARY_JSON_CONFORMANCE_SUITE_H
#include "google/protobuf/descriptor.h"
#include "third_party/jsoncpp/json.h"
#include "json/json.h"
#include "conformance_test.h"
namespace google {

View File

@ -56,8 +56,7 @@ static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes
return nil; // EOF.
}
if (dataLen != numBytes) {
Die(@"Failed to read the request length (%d), only got: %@",
numBytes, data);
Die(@"Failed to read the request length (%d), only got: %@", numBytes, data);
}
return data;
}
@ -76,7 +75,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
Class msgClass = nil;
if ([request.messageType isEqual:@"protobuf_test_messages.proto3.TestAllTypesProto3"]) {
msgClass = [Proto3TestAllTypesProto3 class];
} else if ([request.messageType isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) {
} else if ([request.messageType
isEqual:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) {
msgClass = [Proto2TestAllTypesProto2 class];
} else {
response.runtimeError =
@ -87,8 +87,7 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
NSError *error = nil;
testMessage = [msgClass parseFromData:request.protobufPayload error:&error];
if (!testMessage) {
response.parseError =
[NSString stringWithFormat:@"Parse error: %@", error];
response.parseError = [NSString stringWithFormat:@"Parse error: %@", error];
}
break;
}
@ -98,9 +97,8 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
break;
case ConformanceRequest_Payload_OneOfCase_JspbPayload:
response.skipped =
@"ConformanceRequest had a jspb_payload ConformanceRequest.payload;"
" those aren't supposed to happen with opensource.";
response.skipped = @"ConformanceRequest had a jspb_payload ConformanceRequest.payload;"
" those aren't supposed to happen with opensource.";
break;
case ConformanceRequest_Payload_OneOfCase_TextPayload:
@ -120,7 +118,7 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
response.protobufPayload = testMessage.data;
if (!response.protobufPayload) {
response.serializeError =
[NSString stringWithFormat:@"Failed to make data from: %@", testMessage];
[NSString stringWithFormat:@"Failed to make data from: %@", testMessage];
}
break;
@ -131,7 +129,7 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
case ConformanceWireFormat_Jspb:
response.skipped =
@"ConformanceRequest had a requested_output_format of JSPB WireFormat; that"
" isn't supposed to happen with opensource.";
" isn't supposed to happen with opensource.";
break;
case ConformanceWireFormat_TextFormat:
@ -173,8 +171,7 @@ static BOOL DoTestIo(NSFileHandle *input, NSFileHandle *output) {
}
NSError *error = nil;
ConformanceRequest *request = [ConformanceRequest parseFromData:data
error:&error];
ConformanceRequest *request = [ConformanceRequest parseFromData:data error:&error];
if (!request) {
Die(@"Failed to parse the message data: %@", error);
}

View File

@ -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.21.7</version>
<version>3.21.8</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/main/LICENSE</licenseUrl>

View File

@ -6,9 +6,5 @@ cd $(dirname $(readlink $BASH_SOURCE))
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
set DOTNET_CLI_TELEMETRY_OPTOUT=true
# Work around https://github.com/dotnet/core/issues/5881
dotnet nuget locals all --clear
# Builds Google.Protobuf NuGet packages
dotnet restore src/Google.Protobuf.sln
dotnet pack -c Release src/Google.Protobuf.sln -p:ContinuousIntegrationBuild=true
dotnet pack --no-restore -c Release src/Google.Protobuf.sln -p:ContinuousIntegrationBuild=true

View File

@ -218,8 +218,9 @@ namespace ProtobufTestMessages.Proto2 {
"GAIgASgJEhAKCHJlcXVpcmVzGAMgAygJKkYKEUZvcmVpZ25FbnVtUHJvdG8y",
"Eg8KC0ZPUkVJR05fRk9PEAASDwoLRk9SRUlHTl9CQVIQARIPCgtGT1JFSUdO",
"X0JBWhACOkoKD2V4dGVuc2lvbl9pbnQzMhIxLnByb3RvYnVmX3Rlc3RfbWVz",
"c2FnZXMucHJvdG8yLlRlc3RBbGxUeXBlc1Byb3RvMhh4IAEoBUIvCihjb20u",
"Z29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8ySAH4AQE="));
"c2FnZXMucHJvdG8yLlRlc3RBbGxUeXBlc1Byb3RvMhh4IAEoBUI4Cihjb20u",
"Z29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8ySAH4AQGiAgZQ",
"cm90bzI="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto2.ForeignEnumProto2), }, new pb::Extension[] { TestMessagesProto2Extensions.ExtensionInt32 }, new pbr::GeneratedClrTypeInfo[] {

View File

@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- If you update this, update the .csproj in the Docker file as well -->
<PropertyGroup>
<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.21.7</VersionPrefix>
<VersionPrefix>3.21.8</VersionPrefix>
<LangVersion>10.0</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.1;netstandard2.0;net45;net50</TargetFrameworks>

View File

@ -412,8 +412,13 @@ public abstract class GeneratedMessageLite<
protected static <T extends GeneratedMessageLite<?, ?>> void registerDefaultInstance(
Class<T> clazz, T defaultInstance) {
// Default instances must be immutable.
// Marking immutable here to avoid extra bytecode in every generated message class.
// Only calling "markImmutable" rather than "makeImmutable" because for Default Instances:
// 1. All sub-messages are initialized to null / default instances and thus immutable
// 2. All lists are initialized to default instance empty lists which are also immutable.
defaultInstance.markImmutable();
defaultInstanceMap.put(clazz, defaultInstance);
defaultInstance.makeImmutable();
}
protected static Object newMessageInfo(

View File

@ -202,6 +202,9 @@ public class SingleFieldBuilder<
builder = null;
}
onChanged();
// After clearing, parent is dirty, but this field builder is now clean and any changes should
// trickle up.
isClean = true;
return this;
}

View File

@ -202,6 +202,9 @@ public class SingleFieldBuilderV3<
builder = null;
}
onChanged();
// After clearing, parent is dirty, but this field builder is now clean and any changes should
// trickle up.
isClean = true;
return this;
}

View File

@ -33,6 +33,7 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import protobuf_unittest.Engine;
import protobuf_unittest.TimingBelt;
import protobuf_unittest.Vehicle;
import protobuf_unittest.Wheel;
import java.util.ArrayList;
@ -48,6 +49,27 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class NestedBuildersTest {
@Test
public void test3LayerPropagationWithIntermediateClear() {
Vehicle.Builder vehicleBuilder = Vehicle.newBuilder();
vehicleBuilder.getEngineBuilder().getTimingBeltBuilder();
// This step detaches the TimingBelt.Builder (though it leaves a SingleFieldBuilder in place)
vehicleBuilder.getEngineBuilder().clear();
// These steps build the middle and top level messages, it used to leave the vestigial
// TimingBelt.Builder in a state where further changes didn't propagate anymore
Object unused = vehicleBuilder.getEngineBuilder().build();
unused = vehicleBuilder.build();
TimingBelt expected = TimingBelt.newBuilder().setNumberOfTeeth(124).build();
vehicleBuilder.getEngineBuilder().setTimingBelt(expected);
// Testing that b/254158939 is fixed. It used to be that the setTimingBelt call above didn't
// propagate a change notification and the call below would return a stale version of the timing
// belt.
assertThat(vehicleBuilder.getEngine().getTimingBelt()).isEqualTo(expected);
}
@Test
public void testMessagesAndBuilders() {
Vehicle.Builder vehicleBuilder = Vehicle.newBuilder();

View File

@ -30,8 +30,8 @@
syntax = "proto2";
package map_for_proto2_lite_test;
option java_outer_classname = "MapForProto2TestProto";
option optimize_for = LITE_RUNTIME;
option java_package = "map_lite_test";

View File

@ -45,6 +45,11 @@ message Vehicle {
message Engine {
optional int32 cylinder = 1;
optional int32 liters = 2;
optional TimingBelt timing_belt = 3;
}
message TimingBelt {
optional int32 number_of_teeth = 1;
}
message Wheel {

View File

@ -16,7 +16,7 @@
</description>
<properties>
<kotlin.version>1.5.0</kotlin.version>
<kotlin.version>1.6.0</kotlin.version>
</properties>
<dependencies>

View File

@ -17,6 +17,6 @@
</description>
<properties>
<kotlin.version>1.5.0</kotlin.version>
<kotlin.version>1.6.0</kotlin.version>
</properties>
</project>

View File

@ -37,22 +37,19 @@ import com.google.protobuf.GeneratedMessageLite
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, *>,
MOrBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>,
T : Any
> MOrBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
T : Any> MOrBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
/** Sets the current value of the proto extension in this builder. */
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, B>,
B : GeneratedMessageLite.ExtendableBuilder<M, B>,
T : Any
> B.set(extension: ExtensionLite<M, T>, value: T) {
T : Any> B.set(extension: ExtensionLite<M, T>, value: T) {
setExtension(extension, value)
}
/** Returns true if the specified extension is set. */
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, *>,
MorBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>
> MorBT.contains(
MorBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>> MorBT.contains(
extension: ExtensionLite<M, *>
): Boolean = hasExtension(extension)

View File

@ -48,31 +48,27 @@ class ExtendableMessageLiteExtensionsTest {
@Test
fun getOnBuilder() {
val builder = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
val builder = ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6)
assertThat(builder[TestProto.int32Extension]).isEqualTo(6)
}
@Test
fun getOnMessage() {
val message = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
.build()
val message =
ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6).build()
assertThat(message[TestProto.int32Extension]).isEqualTo(6)
}
@Test
fun containsPositiveOnMessage() {
val message = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
.build()
val message =
ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6).build()
assertThat(TestProto.int32Extension in message).isTrue()
}
@Test
fun containsPositiveOnBuilder() {
val builder = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
val builder = ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6)
assertThat(TestProto.int32Extension in builder).isTrue()
}

View File

@ -16,7 +16,7 @@
</description>
<properties>
<kotlin.version>1.5.0</kotlin.version>
<kotlin.version>1.6.0</kotlin.version>
</properties>
<dependencies>

View File

@ -17,7 +17,7 @@
</description>
<properties>
<kotlin.version>1.5.0</kotlin.version>
<kotlin.version>1.6.0</kotlin.version>
</properties>
</project>

View File

@ -35,13 +35,13 @@ package com.google.protobuf.kotlin
* extension methods.
*
* <p>This class is used by Kotlin protocol buffer extensions, and its constructor is public only
* because generated message code is in a different compilation unit. Others should not use this
* because generated message code is in a different compilation unit. Others should not use this
* class directly in any way.
*/
@Suppress("unused") // the unused type parameter
class DslList<E, P : DslProxy> @OnlyForUseByGeneratedProtoCode constructor(
private val delegate: List<E>
) : List<E> by delegate {
class DslList<E, P : DslProxy>
@OnlyForUseByGeneratedProtoCode
constructor(private val delegate: List<E>) : List<E> by delegate {
override fun iterator(): Iterator<E> = UnmodifiableIterator(delegate.iterator())
override fun listIterator(): ListIterator<E> = UnmodifiableListIterator(delegate.listIterator())

View File

@ -35,13 +35,13 @@ package com.google.protobuf.kotlin
* extension methods.
*
* <p>This class is used by Kotlin protocol buffer extensions, and its constructor is public only
* because generated message code is in a different compilation unit. Others should not use this
* because generated message code is in a different compilation unit. Others should not use this
* class directly in any way.
*/
@Suppress("unused") // the unused type parameter
class DslMap<K, V, P : DslProxy> @OnlyForUseByGeneratedProtoCode constructor(
private val delegate: Map<K, V>
) : Map<K, V> by delegate {
class DslMap<K, V, P : DslProxy>
@OnlyForUseByGeneratedProtoCode
constructor(private val delegate: Map<K, V>) : Map<K, V> by delegate {
// We allocate the wrappers on calls to get, not with lazy {...}, because lazy allocates
// a few objects up front, and any kind of query operation on this object should be rare.

View File

@ -31,9 +31,9 @@
package com.google.protobuf.kotlin
/**
* A type meaningful only for its existence, never intended to be instantiated. For example,
* a `DslList<Int, FooProxy>` can be given different extension methods than a
* `DslList<Int, BarProxy>`.
* A type meaningful only for its existence, never intended to be instantiated. For example, a
* `DslList<Int, FooProxy>` can be given different extension methods than a `DslList<Int,
* BarProxy>`.
*/
abstract class DslProxy @OnlyForUseByGeneratedProtoCode protected constructor() {
init {

View File

@ -33,12 +33,11 @@ package com.google.protobuf.kotlin
import com.google.protobuf.ExtensionLite
import com.google.protobuf.GeneratedMessageV3
/** Sets the current value of the proto extension in this builder.*/
/** Sets the current value of the proto extension in this builder. */
operator fun <
M : GeneratedMessageV3.ExtendableMessage<M>,
B : GeneratedMessageV3.ExtendableBuilder<M, B>,
T : Any
> B.set(extension: ExtensionLite<M, T>, value: T) {
T : Any> B.set(extension: ExtensionLite<M, T>, value: T) {
setExtension(extension, value)
}
@ -46,11 +45,11 @@ operator fun <
operator fun <
M : GeneratedMessageV3.ExtendableMessage<M>,
MorBT : GeneratedMessageV3.ExtendableMessageOrBuilder<M>,
T : Any
> MorBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
T : Any> MorBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
/** Returns true if the specified extension is set on this builder. */
operator fun <
M : GeneratedMessageV3.ExtendableMessage<M>,
MorBT : GeneratedMessageV3.ExtendableMessageOrBuilder<M>
> MorBT.contains(extension: ExtensionLite<M, *>): Boolean = hasExtension(extension)
MorBT : GeneratedMessageV3.ExtendableMessageOrBuilder<M>> MorBT.contains(
extension: ExtensionLite<M, *>
): Boolean = hasExtension(extension)

View File

@ -32,8 +32,8 @@ package com.google.protobuf.kotlin
/**
* Opt-in annotation to make it difficult to accidentally use APIs only intended for use by proto
* generated code. See https://kotlinlang.org/docs/reference/opt-in-requirements.html for details
* on how this API works.
* generated code. See https://kotlinlang.org/docs/reference/opt-in-requirements.html for details on
* how this API works.
*/
@RequiresOptIn(
message =

View File

@ -30,9 +30,7 @@
package com.google.protobuf.kotlin
/**
* Indicates an API that is part of a DSL to generate protocol buffer messages.
*/
/** Indicates an API that is part of a DSL to generate protocol buffer messages. */
@DslMarker
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)

View File

@ -34,29 +34,24 @@ package com.google.protobuf.kotlin
internal class UnmodifiableIterator<E>(delegate: Iterator<E>) : Iterator<E> by delegate
/** Wraps a [ListIterator] and makes it unmodifiable even from Java. */
internal class UnmodifiableListIterator<E>(
delegate: ListIterator<E>
) : ListIterator<E> by delegate
internal class UnmodifiableListIterator<E>(delegate: ListIterator<E>) : ListIterator<E> by delegate
/** Wraps a [Collection] and makes it unmodifiable even from Java. */
internal open class UnmodifiableCollection<E>(
private val delegate: Collection<E>
) : Collection<E> by delegate {
internal open class UnmodifiableCollection<E>(private val delegate: Collection<E>) :
Collection<E> by delegate {
override fun iterator(): Iterator<E> = UnmodifiableIterator(delegate.iterator())
}
/** Wraps a [Set] and makes it unmodifiable even from Java. */
internal class UnmodifiableSet<E>(
delegate: Collection<E>
) : UnmodifiableCollection<E>(delegate), Set<E>
internal class UnmodifiableSet<E>(delegate: Collection<E>) :
UnmodifiableCollection<E>(delegate), Set<E>
/** Wraps a [Map.Entry] and makes it unmodifiable even from Java. */
internal class UnmodifiableMapEntry<K, V>(delegate: Map.Entry<K, V>) : Map.Entry<K, V> by delegate
/** Wraps a [Set] of map entries and makes it unmodifiable even from Java. */
internal class UnmodifiableMapEntries<K, V>(
private val delegate: Set<Map.Entry<K, V>>
) : UnmodifiableCollection<Map.Entry<K, V>>(delegate), Set<Map.Entry<K, V>> {
internal class UnmodifiableMapEntries<K, V>(private val delegate: Set<Map.Entry<K, V>>) :
UnmodifiableCollection<Map.Entry<K, V>>(delegate), Set<Map.Entry<K, V>> {
// Is this overkill? Probably.

View File

@ -67,9 +67,7 @@ class DslListTest {
fun dslListIsNotEvenSecretlyMutable() {
val dslList = DslList<Int, DummyProxy>(mutableListOf(1, 2, 3))
val dslListAsJavaUtil = dslList as java.util.List<Int>
assertFailsWith<UnsupportedOperationException> {
dslListAsJavaUtil.add(4)
}
assertFailsWith<UnsupportedOperationException> { dslListAsJavaUtil.add(4) }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -79,9 +77,7 @@ class DslListTest {
val iterator = dslList.iterator() as java.util.Iterator<Int>
iterator.next()
assertFailsWith<UnsupportedOperationException> {
iterator.remove()
}
assertFailsWith<UnsupportedOperationException> { iterator.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -91,9 +87,7 @@ class DslListTest {
val iterator = dslList.listIterator() as java.util.ListIterator<Int>
iterator.next()
assertFailsWith<UnsupportedOperationException> {
iterator.remove()
}
assertFailsWith<UnsupportedOperationException> { iterator.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -103,9 +97,7 @@ class DslListTest {
val iterator = dslList.listIterator(1) as java.util.ListIterator<Int>
iterator.next()
assertFailsWith<UnsupportedOperationException> {
iterator.remove()
}
assertFailsWith<UnsupportedOperationException> { iterator.remove() }
}
@Test

View File

@ -44,8 +44,7 @@ class DslMapTest {
@Test
fun matchesMap() {
assertThat(DslMap<Int, Int, DummyProxy>(mapOf(1 to -1, 2 to -2)))
.containsExactly(1, -1, 2, -2)
assertThat(DslMap<Int, Int, DummyProxy>(mapOf(1 to -1, 2 to -2))).containsExactly(1, -1, 2, -2)
}
@Test
@ -91,9 +90,7 @@ class DslMapTest {
fun dslMapIsNotEvenSecretlyMutable() {
val dslMap = DslMap<Int, Int, DummyProxy>(mutableMapOf(1 to -1))
val dslMapAsJavaUtilMap = dslMap as java.util.Map<Int, Int>
assertFailsWith<UnsupportedOperationException> {
dslMapAsJavaUtilMap.put(2, -2)
}
assertFailsWith<UnsupportedOperationException> { dslMapAsJavaUtilMap.put(2, -2) }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -101,9 +98,7 @@ class DslMapTest {
fun dslMapKeysAreNotEvenSecretlyMutable() {
val dslMap = DslMap<Int, Int, DummyProxy>(mutableMapOf(1 to -1))
val dslMapKeysAsJavaUtilSet = dslMap.keys as java.util.Set<Int>
assertFailsWith<UnsupportedOperationException> {
dslMapKeysAsJavaUtilSet.remove(1)
}
assertFailsWith<UnsupportedOperationException> { dslMapKeysAsJavaUtilSet.remove(1) }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -113,9 +108,7 @@ class DslMapTest {
val dslMapKeysAsJavaUtilSet = dslMap.keys as java.util.Set<Int>
val itr = dslMapKeysAsJavaUtilSet.iterator()
itr.next()
assertFailsWith<UnsupportedOperationException> {
itr.remove()
}
assertFailsWith<UnsupportedOperationException> { itr.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -123,9 +116,7 @@ class DslMapTest {
fun dslMapValuesAreNotEvenSecretlyMutable() {
val dslMap = DslMap<Int, Int, DummyProxy>(mutableMapOf(1 to -1))
val dslMapValuesAsJavaUtilCollection = dslMap.values as java.util.Collection<Int>
assertFailsWith<UnsupportedOperationException> {
dslMapValuesAsJavaUtilCollection.remove(1)
}
assertFailsWith<UnsupportedOperationException> { dslMapValuesAsJavaUtilCollection.remove(1) }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -135,9 +126,7 @@ class DslMapTest {
val dslMapValuesAsJavaUtilCollection = dslMap.values as java.util.Collection<Int>
val itr = dslMapValuesAsJavaUtilCollection.iterator()
itr.next()
assertFailsWith<UnsupportedOperationException> {
itr.remove()
}
assertFailsWith<UnsupportedOperationException> { itr.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -146,9 +135,7 @@ class DslMapTest {
val dslMap = DslMap<Int, Int, DummyProxy>(mutableMapOf(1 to -1))
val dslMapEntriesAsJavaUtilSet = dslMap.entries as java.util.Set<Map.Entry<Int, Int>>
val entry = dslMap.entries.single()
assertFailsWith<UnsupportedOperationException> {
dslMapEntriesAsJavaUtilSet.remove(entry)
}
assertFailsWith<UnsupportedOperationException> { dslMapEntriesAsJavaUtilSet.remove(entry) }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -158,9 +145,7 @@ class DslMapTest {
val dslMapEntriesAsJavaUtilSet = dslMap.entries as java.util.Set<Map.Entry<Int, Int>>
val itr = dslMapEntriesAsJavaUtilSet.iterator()
itr.next()
assertFailsWith<UnsupportedOperationException> {
itr.remove()
}
assertFailsWith<UnsupportedOperationException> { itr.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@ -168,9 +153,7 @@ class DslMapTest {
fun dslMapEntryObjectsAreNotEvenSecretlyMutable() {
val dslMap = DslMap<Int, Int, DummyProxy>(mutableMapOf(1 to -1))
val dslMapEntryAsJavaUtilMapEntry = dslMap.entries.single() as java.util.Map.Entry<Int, Int>
assertFailsWith<UnsupportedOperationException> {
dslMapEntryAsJavaUtilMapEntry.value = 2
}
assertFailsWith<UnsupportedOperationException> { dslMapEntryAsJavaUtilMapEntry.value = 2 }
}
@Test

View File

@ -48,31 +48,27 @@ class ExtendableMessageExtensionsTest {
@Test
fun getOnBuilder() {
val builder = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
val builder = ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6)
assertThat(builder[TestProto.int32Extension]).isEqualTo(6)
}
@Test
fun getOnMessage() {
val message = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
.build()
val message =
ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6).build()
assertThat(message[TestProto.int32Extension]).isEqualTo(6)
}
@Test
fun containsPositiveOnMessage() {
val message = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
.build()
val message =
ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6).build()
assertThat(TestProto.int32Extension in message).isTrue()
}
@Test
fun containsPositiveOnBuilder() {
val builder = ExampleExtensibleMessage.newBuilder()
.setExtension(TestProto.int32Extension, 6)
val builder = ExampleExtensibleMessage.newBuilder().setExtension(TestProto.int32Extension, 6)
assertThat(TestProto.int32Extension in builder).isTrue()
}

View File

@ -48,90 +48,92 @@ class ExtensionListTest {
@Test
fun matchesList() {
assertThat(
ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, listOf(1, 2, 3)
ExtensionList<Int, ExampleExtensibleMessage>(TestProto.repeatedExtension, listOf(1, 2, 3))
)
).containsExactly(1, 2, 3).inOrder()
.containsExactly(1, 2, 3)
.inOrder()
}
@Test
fun reflectsChangesInList() {
val mutableList = mutableListOf(1, 2, 3)
val extensionList = ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, mutableList
)
val extensionList =
ExtensionList<Int, ExampleExtensibleMessage>(TestProto.repeatedExtension, mutableList)
mutableList.add(4)
assertThat(extensionList).containsExactly(1, 2, 3, 4).inOrder()
}
@Test
fun extensionListIsNotMutable() {
val extensionList = ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, mutableListOf(1, 2, 3)
)
val extensionList =
ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension,
mutableListOf(1, 2, 3)
)
assertThat(extensionList is MutableList<*>).isFalse()
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@Test
fun extensionListIsNotEvenSecretlyMutable() {
val extensionList = ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, mutableListOf(1, 2, 3)
)
val extensionList =
ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension,
mutableListOf(1, 2, 3)
)
val extensionListAsJavaUtil = extensionList as java.util.List<Int>
assertFailsWith<UnsupportedOperationException> {
extensionListAsJavaUtil.add(4)
}
assertFailsWith<UnsupportedOperationException> { extensionListAsJavaUtil.add(4) }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@Test
fun extensionList_IteratorIsNotEvenSecretlyMutable() {
val extensionList = ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, mutableListOf(1, 2, 3)
)
val extensionList =
ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension,
mutableListOf(1, 2, 3)
)
val iterator = extensionList.iterator() as java.util.Iterator<Int>
iterator.next()
assertFailsWith<UnsupportedOperationException> {
iterator.remove()
}
assertFailsWith<UnsupportedOperationException> { iterator.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@Test
fun extensionList_ListIteratorIsNotEvenSecretlyMutable() {
val extensionList = ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, mutableListOf(1, 2, 3)
)
val extensionList =
ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension,
mutableListOf(1, 2, 3)
)
val iterator = extensionList.listIterator() as java.util.ListIterator<Int>
iterator.next()
assertFailsWith<UnsupportedOperationException> {
iterator.remove()
}
assertFailsWith<UnsupportedOperationException> { iterator.remove() }
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN", "UNCHECKED_CAST")
@Test
fun extensionList_ListIteratorIndexIsNotEvenSecretlyMutable() {
val extensionList = ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension, mutableListOf(1, 2, 3)
)
val extensionList =
ExtensionList<Int, ExampleExtensibleMessage>(
TestProto.repeatedExtension,
mutableListOf(1, 2, 3)
)
val iterator = extensionList.listIterator(1) as java.util.ListIterator<Int>
iterator.next()
assertFailsWith<UnsupportedOperationException> {
iterator.remove()
}
assertFailsWith<UnsupportedOperationException> { iterator.remove() }
}
@Test
fun expectedToString() {
assertThat(
ExtensionList<Int, ExampleExtensibleMessage>(TestProto.repeatedExtension, listOf(1, 2))
.toString()
).isEqualTo("[1, 2]")
ExtensionList<Int, ExampleExtensibleMessage>(TestProto.repeatedExtension, listOf(1, 2))
.toString()
)
.isEqualTo("[1, 2]")
}
@Test

46
kokoro/common/bazel_flags.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# Helper for setting up common bazel flags in Kokoro.
#
# This script prints extra flags to a bazel invocation when it is run from
# Kokoro. When the special environment variables are not present (e.g., if you
# run Kokoro build scripts locally), this script only flips some debug settings.
#
# Example of running directly:
# bazel test $(path/to/bazel_flags.sh) //...
function bazel_flags::gen_invocation_id() {
# Create a new invocation ID and store in the artifacts dir.
local _invocation_id=$(uuidgen | tr A-Z a-z)
# Put the new invocation ID at the start of the output IDs file. Some
# Google-internal tools only look at the first entry, so this ensures the most
# recent entry is first.
local _ids_file=${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids
local _temp_ids=$(mktemp)
echo ${_invocation_id} > ${_temp_ids}
[[ -e ${_ids_file} ]] && cat ${_ids_file} >> ${_temp_ids}
mv -f ${_temp_ids} ${_ids_file}
echo -n ${_invocation_id}
}
# Prints flags to use on Kokoro.
function bazel_flags::kokoro_flags() {
[[ -n ${KOKORO_JOB_NAME:-} ]] || return
local -a _flags
_flags+=(
--invocation_id=$(bazel_flags::gen_invocation_id)
--remote_cache=https://storage.googleapis.com/protobuf-bazel-cache/${KOKORO_JOB_NAME}
)
if [[ -n ${KOKORO_BAZEL_AUTH_CREDENTIAL:-} ]]; then
_flags+=( --google_credentials=${KOKORO_BAZEL_AUTH_CREDENTIAL} )
else
_flags+=( --google_default_credentials=true )
fi
echo "${_flags[@]}"
}
echo "$(bazel_flags::kokoro_flags) --keep_going --test_output=errors"

View File

@ -1,71 +0,0 @@
#!/bin/bash
# Wrapper for invoking bazel on Kokoro.
#
# This script adds extra flags to a bazel invocation when it is run from Kokoro.
# When the special environment variables are not present (e.g., if you run
# Kokoro build scripts locally), this script is equivalent to the "bazel"
# command.
#
# Example of running directly:
# path/to/bazel_wrapper.sh build //...
#
# Example of `source`ing:
# source path/to/bazel_wrapper.sh
# bazel_wrapper build //...
function bazel_wrapper::gen_invocation_id() {
# Create a new invocation ID and store in the artifacts dir.
local _invocation_id=$(uuidgen | tr A-Z a-z)
# Put the new invocation ID at the start of the output IDs file. Some
# Google-internal tools only look at the first entry, so this ensures the most
# recent entry is first.
local _ids_file=${KOKORO_ARTIFACTS_DIR}/bazel_invocation_ids
local _temp_ids=$(mktemp)
echo ${_invocation_id} > ${_temp_ids}
[[ -e ${_ids_file} ]] && cat ${_ids_file} >> ${_temp_ids}
mv -f ${_temp_ids} ${_ids_file}
echo -n ${_invocation_id}
}
# Prints flags to use on Kokoro.
function bazel_wrapper::kokoro_flags() {
[[ -n ${KOKORO_BES_PROJECT_ID:-} ]] || return
local -a _flags
_flags+=(
--bes_backend=${KOKORO_BES_BACKEND_ADDRESS:-buildeventservice.googleapis.com}
--bes_results_url=https://source.cloud.google.com/results/invocations/
--invocation_id=$(bazel_wrapper::gen_invocation_id)
--project_id=${KOKORO_BES_PROJECT_ID} # --bes_instance_name in Bazel 5+
--remote_cache=https://storage.googleapis.com/protobuf-bazel-cache
)
if [[ -n ${KOKORO_BAZEL_AUTH_CREDENTIAL:-} ]]; then
_flags+=( --google_credentials=${KOKORO_BAZEL_AUTH_CREDENTIAL} )
else
_flags+=( --google_default_credentials=true )
fi
echo "${_flags[@]}"
}
# Runs bazel with Kokoro flags, if appropriate.
function bazel_wrapper() {
local -a _flags
# We might need to add flags. They need to come after any startup flags and
# the command, but before any terminating "--", so copy them into the _flags
# variable.
until (( ${#@} == 0 )) || [[ $1 == "--" ]]; do
_flags+=( "${1}" ); shift
done
# Set the `BAZEL` env variable to override the actual bazel binary to use:
${BAZEL:=bazel} "${_flags[@]}" $(bazel_wrapper::kokoro_flags) "${@}"
}
# If this script was called directly, run bazel. Otherwise (i.e., this script
# was `source`d), the sourcing script will call bazel_wrapper themselves.
(( ${#BASH_SOURCE[@]} == 1 )) && bazel_wrapper "${@}"

View File

@ -39,8 +39,7 @@ function run {
-v $GIT_REPO_ROOT:/workspace \
$CONTAINER_IMAGE \
test \
--keep_going \
--test_output=streamed \
$(${GIT_REPO_ROOT}/kokoro/common/bazel_flags.sh) \
${ENVS[@]} \
$PLATFORM_CONFIG \
$BAZEL_CONFIG \

View File

@ -14,4 +14,4 @@ source kokoro/macos/prepare_build_macos_rc
#
# Run build
#
bazel test //src/... -k --test_output=streamed
bazel test $(kokoro/common/bazel_flags.sh) //src/...

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/cpp/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/objectivec_ios_debug/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/objectivec_ios_release/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/objectivec_osx/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/php74/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/php80/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -9,4 +9,5 @@ cd $(dirname $0)/../../..
KOKORO_INSTALL_VENV=yes
source kokoro/macos/prepare_build_macos_rc
bazel test //python/... @upb//python/... -k --macos_minimum_os=10.9 --test_output=streamed
bazel test //python/... @upb//python/... $(kokoro/common/bazel_flags.sh) \
--macos_minimum_os=10.9

View File

@ -9,3 +9,25 @@ action {
regex: "**/*"
}
}
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -9,4 +9,5 @@ cd $(dirname $0)/../../..
KOKORO_INSTALL_VENV=yes
source kokoro/macos/prepare_build_macos_rc
bazel test //python/... -k --macos_minimum_os=10.9 --test_output=streamed --define=use_fast_cpp_protos=true
bazel test //python/... $(kokoro/common/bazel_flags.sh) \
--macos_minimum_os=10.9 --define=use_fast_cpp_protos=true

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/python_cpp/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby25/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby26/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby27/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby30/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/macos/ruby31/build.sh"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -11,4 +11,6 @@ composer test_c
popd
git clean -fXd
bazel test //php:conformance_test_c --action_env=PATH --test_env=PATH --test_output=streamed
bazel test $(kokoro/common/bazel_flags.sh) \
--action_env=PATH --test_env=PATH \
//php:conformance_test_c

View File

@ -10,6 +10,9 @@ bazel build //:protoc
cp bazel-bin/protoc .
export PROTOC=$PWD/protoc
# Pull in dependencies.
git submodule update --init --recursive
umask 0022
pushd ruby
gem install bundler -v 2.1.4

View File

@ -6,6 +6,9 @@ set -ex
bazel build //:protoc
export PROTOC=$PWD/bazel-bin/protoc
# Pull in dependencies.
git submodule update --init --recursive
umask 0022
pushd ruby
bundle update && bundle exec rake gem:native

View File

@ -13,9 +13,17 @@ bazel version
choco install bazel -y -i --version 5.1.0
bazel version
@rem Set invocation ID so that bazel run is known to kokoro
uuidgen > %KOKORO_ARTIFACTS_DIR%\bazel_invocation_ids
SET /p BAZEL_INTERNAL_INVOCATION_ID=<%KOKORO_ARTIFACTS_DIR%\bazel_invocation_ids
@rem Make paths as short as possible to avoid long path issues.
set BAZEL_STARTUP=--output_user_root=C:/tmp --windows_enable_symlinks
set BAZEL_FLAGS=--enable_runfiles --keep_going --test_output=streamed --verbose_failures
set BAZEL_FLAGS=--enable_runfiles --keep_going --test_output=errors ^
--verbose_failures ^
--invocation_id=%BAZEL_INTERNAL_INVOCATION_ID% ^
--google_credentials=%KOKORO_BAZEL_AUTH_CREDENTIAL% ^
--remote_cache=https://storage.googleapis.com/protobuf-bazel-cache/%KOKORO_JOB_NAME%
@rem Build libraries first.
bazel %BAZEL_STARTUP% build //:protoc //:protobuf //:protobuf_lite %BAZEL_FLAGS% || goto :error

View File

@ -3,3 +3,25 @@
# Location of the build script in repository
build_file: "protobuf/kokoro/windows/bazel/build.bat"
timeout_mins: 1440
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}
}
bazel_setting {
project_id: "protobuf-build"
bes_backend_address: "buildeventservice.googleapis.com"
foundry_backend_address: "remotebuildexecution.googleapis.com"
upsalite_frontend_address: "https://source.cloud.google.com"
local_execution: true
# Need to be same as the fetch_keystore entry in the previous step.
auth_credential: {
keystore_config_id: 77103
keyname: "kokoro_gcp_service"
}
}

View File

@ -8,7 +8,8 @@ set -eu
# Some base locations.
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/../.."
readonly BazelFlags="-k --announce_rc --test_output=errors --macos_minimum_os=10.9"
readonly BazelFlags="--announce_rc --macos_minimum_os=10.9 \
$(${ScriptDir}/../../kokoro/common/bazel_flags.sh)"
# Invoke with BAZEL=bazelisk to use that instead.
readonly BazelBin="${BAZEL:=bazel}"

View File

@ -99,7 +99,6 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
* name "y.z".
*
*
* JSON
*
* The JSON representation of an `Any` value uses the regular

View File

@ -32,6 +32,7 @@
#import <objc/message.h>
#import <objc/runtime.h>
#import <os/lock.h>
#import <stdatomic.h>
#import "GPBArray_PackagePrivate.h"
@ -70,8 +71,7 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
@package
GPBUnknownFieldSet *unknownFields_;
NSMutableDictionary *extensionMap_;
// Readonly access to autocreatedExtensionMap_ is protected via
// readOnlySemaphore_.
// Readonly access to autocreatedExtensionMap_ is protected via readOnlyLock_.
NSMutableDictionary *autocreatedExtensionMap_;
// If the object was autocreated, we remember the creator so that if we get
@ -80,19 +80,21 @@ static NSString *const kGPBDataCoderKey = @"GPBData";
GPBFieldDescriptor *autocreatorField_;
GPBExtensionDescriptor *autocreatorExtension_;
// Message can only be mutated from one thread. But some *readonly* operations
// modify internal state because they autocreate things. The
// autocreatedExtensionMap_ is one such structure. Access during readonly
// operations is protected via this semaphore.
// NOTE: OSSpinLock may seem like a good fit here but Apple engineers have
// pointed out that they are vulnerable to live locking on iOS in cases of
// priority inversion:
// Messages can only be mutated from one thread. But some *readonly* operations modify internal
// state because they autocreate things. The autocreatedExtensionMap_ is one such structure.
// Access during readonly operations is protected via this lock.
//
// Long ago, this was an OSSpinLock, but then it came to light that there were issues for that on
// iOS:
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
// Use of readOnlySemaphore_ must be prefaced by a call to
// GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
// readOnlySemaphore_ to be only created when actually needed.
_Atomic(dispatch_semaphore_t) readOnlySemaphore_;
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// all the support we need. For more information in the concurrency/locking space see:
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html
// https://developer.apple.com/videos/play/wwdc2017/706/
os_unfair_lock readOnlyLock_;
}
@end
@ -746,33 +748,6 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
self->autocreatorExtension_ = nil;
}
// Call this before using the readOnlySemaphore_. This ensures it is created only once.
void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
// Create the semaphore on demand (rather than init) as developers might not cause them
// to be needed, and the heap usage can add up. The atomic swap is used to avoid needing
// another lock around creating it.
if (self->readOnlySemaphore_ == nil) {
dispatch_semaphore_t worker = dispatch_semaphore_create(1);
dispatch_semaphore_t expected = nil;
if (!atomic_compare_exchange_strong(&self->readOnlySemaphore_, &expected, worker)) {
dispatch_release(worker);
}
#if defined(__clang_analyzer__)
// The static analyzer thinks worker is leaked (doesn't seem to know about
// atomic_compare_exchange_strong); so just for the analyzer, let it think
// worker is also released in this case.
else {
dispatch_release(worker);
}
#endif
}
#pragma clang diagnostic pop
}
static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if (!self->unknownFields_) {
self->unknownFields_ = [[GPBUnknownFieldSet alloc] init];
@ -845,6 +820,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
if ((self = [super init])) {
messageStorage_ =
(GPBMessage_StoragePtr)(((uint8_t *)self) + class_getInstanceSize([self class]));
readOnlyLock_ = OS_UNFAIR_LOCK_INIT;
}
return self;
@ -915,9 +891,6 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
- (void)dealloc {
[self internalClear:NO];
NSCAssert(!autocreator_, @"Autocreator was not cleared before dealloc.");
if (readOnlySemaphore_) {
dispatch_release(readOnlySemaphore_);
}
[super dealloc];
}
@ -1741,8 +1714,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
}
// Check for an autocreated value.
GPBPrepareReadOnlySemaphore(self);
dispatch_semaphore_wait(readOnlySemaphore_, DISPATCH_TIME_FOREVER);
os_unfair_lock_lock(&readOnlyLock_);
value = [autocreatedExtensionMap_ objectForKey:extension];
if (!value) {
// Auto create the message extensions to match normal fields.
@ -1759,7 +1731,7 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[value release];
}
dispatch_semaphore_signal(readOnlySemaphore_);
os_unfair_lock_unlock(&readOnlyLock_);
return value;
}

View File

@ -31,6 +31,7 @@
#import "GPBRootObject_PackagePrivate.h"
#import <objc/runtime.h>
#import <os/lock.h>
#import <CoreFoundation/CoreFoundation.h>
@ -96,19 +97,23 @@ static CFHashCode GPBRootExtensionKeyHash(const void *value) {
return jenkins_one_at_a_time_hash(key);
}
// NOTE: OSSpinLock may seem like a good fit here but Apple engineers have
// pointed out that they are vulnerable to live locking on iOS in cases of
// priority inversion:
// Long ago, this was an OSSpinLock, but then it came to light that there were issues for that on
// iOS:
// http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html
static dispatch_semaphore_t gExtensionSingletonDictionarySemaphore;
// It was changed to a dispatch_semaphore_t, but that has potential for priority inversion issues.
// The minOS versions are now high enough that os_unfair_lock can be used, and should provide
// all the support we need. For more information in the concurrency/locking space see:
// https://gist.github.com/tclementdev/6af616354912b0347cdf6db159c37057
// https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html
// https://developer.apple.com/videos/play/wwdc2017/706/
static os_unfair_lock gExtensionSingletonDictionaryLock = OS_UNFAIR_LOCK_INIT;
static CFMutableDictionaryRef gExtensionSingletonDictionary = NULL;
static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL;
+ (void)initialize {
// Ensure the global is started up.
if (!gExtensionSingletonDictionary) {
gExtensionSingletonDictionarySemaphore = dispatch_semaphore_create(1);
CFDictionaryKeyCallBacks keyCallBacks = {
// See description above for reason for using custom dictionary.
0,
@ -139,9 +144,9 @@ static GPBExtensionRegistry *gDefaultExtensionRegistry = NULL;
+ (void)globallyRegisterExtension:(GPBExtensionDescriptor *)field {
const char *key = [field singletonNameC];
dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore, DISPATCH_TIME_FOREVER);
os_unfair_lock_lock(&gExtensionSingletonDictionaryLock);
CFDictionarySetValue(gExtensionSingletonDictionary, key, field);
dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore);
os_unfair_lock_unlock(&gExtensionSingletonDictionaryLock);
}
static id ExtensionForName(id self, SEL _cmd) {
@ -173,20 +178,20 @@ static id ExtensionForName(id self, SEL _cmd) {
key[classNameLen + 1 + selNameLen] = '\0';
// NOTE: Even though this method is called from another C function,
// gExtensionSingletonDictionarySemaphore and gExtensionSingletonDictionary
// gExtensionSingletonDictionaryLock and gExtensionSingletonDictionary
// will always be initialized. This is because this call flow is just to
// lookup the Extension, meaning the code is calling an Extension class
// message on a Message or Root class. This guarantees that the class was
// initialized and Message classes ensure their Root was also initialized.
NSAssert(gExtensionSingletonDictionary, @"Startup order broken!");
dispatch_semaphore_wait(gExtensionSingletonDictionarySemaphore, DISPATCH_TIME_FOREVER);
os_unfair_lock_lock(&gExtensionSingletonDictionaryLock);
id extension = (id)CFDictionaryGetValue(gExtensionSingletonDictionary, key);
// We can't remove the key from the dictionary here (as an optimization),
// two threads could have gone into +resolveClassMethod: for the same method,
// and ended up here; there's no way to ensure both return YES without letting
// both try to wire in the method.
dispatch_semaphore_signal(gExtensionSingletonDictionarySemaphore);
os_unfair_lock_unlock(&gExtensionSingletonDictionaryLock);
return extension;
}

View File

@ -95,7 +95,6 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
* .setNanos((int) ((millis % 1000) * 1000000)).build();
*
*
* Example 5: Compute Timestamp from Java `Instant.now()`.
*
* Instant now = Instant.now();
@ -104,7 +103,6 @@ typedef GPB_ENUM(GPBTimestamp_FieldNumber) {
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
* .setNanos(now.getNano()).build();
*
*
* Example 6: Compute Timestamp from current time in Python.
*
* timestamp = Timestamp()

View File

@ -34,7 +34,7 @@ inline_sh_binary(
name = "build_extension",
cmd = """
mkdir -p php/ext/google/protobuf/third_party/utf8_range
cp third_party/utf8_range/* php/ext/google/protobuf/third_party/utf8_range
cp external/utf8_range/* php/ext/google/protobuf/third_party/utf8_range
pushd php/ext/google/protobuf
phpize
@ -48,7 +48,7 @@ genrule(
name = "extension",
srcs = [
":source_files",
"//third_party/utf8_range:all_files",
"@utf8_range//:utf8_range_srcs",
],
tools = [":build_extension"],
outs = ["protobuf.so"],

View File

@ -10,11 +10,11 @@
<email>protobuf-packages@google.com</email>
<active>yes</active>
</lead>
<date>2022-09-29</date>
<time>10:21:44</time>
<date>2022-10-13</date>
<time>11:40:58</time>
<version>
<release>3.21.7</release>
<api>3.21.7</api>
<release>3.21.8</release>
<api>3.21.8</api>
</version>
<stability>
<release>stable</release>
@ -1434,5 +1434,20 @@ G A release.
<notes>
</notes>
</release>
<release>
<version>
<release>3.21.8</release>
<api>3.21.8</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2022-10-13</date>
<time>11:40:58</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</license>
<notes>
</notes>
</release>
</changelog>
</package>

View File

@ -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.21.7"
#define PHP_PROTOBUF_VERSION "3.21.8"
// ptr -> PHP object cache. This is a weak map that caches lazily-created
// wrapper objects around upb types:

View File

@ -4,12 +4,15 @@ set -ex
cd $(dirname $0)/..
# Pull in dependencies.
git submodule update --init --recursive
# utf8_range has to live in the base third_party directory.
# We copy it into the ext/google/protobuf directory for the build
# (and for the release to PECL).
rm -rf ext/google/protobuf/third_party
mkdir -p ext/google/protobuf/third_party/utf8_range
cp ../third_party/utf8_range/* ext/google/protobuf/third_party/utf8_range
cp -r ../third_party/utf8_range/* ext/google/protobuf/third_party/utf8_range
echo "Copied utf8_range from ../third_party -> ext/google/protobuf/third_party"

View File

@ -54,6 +54,23 @@ def protobuf_deps():
urls = ["https://github.com/madler/zlib/archive/v1.2.12.tar.gz"],
)
if not native.existing_rule("jsoncpp"):
http_archive(
name = "jsoncpp",
build_file = "@com_google_protobuf//:third_party/jsoncpp.BUILD",
sha256 = "e34a628a8142643b976c7233ef381457efad79468c67cb1ae0b83a33d7493999",
strip_prefix = "jsoncpp-1.9.4",
urls = ["https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.4.tar.gz"],
)
if not native.existing_rule("utf8_range"):
_github_archive(
name = "utf8_range",
repo = "https://github.com/protocolbuffers/utf8_range",
commit = "a67b76f9f40107f2c78a5aa860bb6ce37ed83d85",
sha256 = "de5f99318f3b5073dd99f3d4ca31e00e90a86cc400fb375e2147ae1fd41711ed",
)
if not native.existing_rule("rules_cc"):
_github_archive(
name = "rules_cc",

View File

@ -39,7 +39,7 @@ import "google/protobuf/any.proto";
message TestAny {
optional google.protobuf.Any value = 1;
optional int32 int_value = 2;
map<string,int32> map_value = 3;
map<string, int32> map_value = 3;
extensions 10 to max;
}

View File

@ -1127,33 +1127,49 @@ TEST1_FILE = ProtoFile(
TEST2_FILE = ProtoFile(
'google/protobuf/internal/descriptor_pool_test2.proto',
'google.protobuf.python.internal',
{
'DescriptorPoolTest3': MessageType({
'NestedEnum': EnumType([('NU', 13), ('XI', 14)]),
'NestedMessage': MessageType({
'NestedEnum': EnumType([('OMICRON', 15), ('PI', 16)]),
'DeepNestedMessage': MessageType({
'NestedEnum': EnumType([('RHO', 17), ('SIGMA', 18)]),
'google.protobuf.python.internal', {
'DescriptorPoolTest3':
MessageType(
{
'NestedEnum':
EnumType([('NU', 13), ('XI', 14)]),
'NestedMessage':
MessageType(
{
'NestedEnum':
EnumType([('OMICRON', 15), ('PI', 16)]),
'DeepNestedMessage':
MessageType(
{
'NestedEnum':
EnumType([('RHO', 17),
('SIGMA', 18)]),
}, [
('nested_enum',
EnumField(1, 'NestedEnum', 'RHO')),
('nested_field',
StringField(2, 'sigma')),
]),
}, [
('nested_enum', EnumField(
1, 'NestedEnum', 'PI')),
('nested_field', StringField(2, 'nu')),
('deep_nested_message',
MessageField(3, 'DeepNestedMessage')),
])
}, [
('nested_enum', EnumField(1, 'NestedEnum', 'RHO')),
('nested_field', StringField(2, 'sigma')),
('nested_enum', EnumField(1, 'NestedEnum', 'XI')),
('nested_message', MessageField(2, 'NestedMessage')),
],
extensions=[
('descriptor_pool_test',
ExtensionField(1001, 'DescriptorPoolTest1')),
]),
}, [
('nested_enum', EnumField(1, 'NestedEnum', 'PI')),
('nested_field', StringField(2, 'nu')),
('deep_nested_message', MessageField(3, 'DeepNestedMessage')),
])
}, [
('nested_enum', EnumField(1, 'NestedEnum', 'XI')),
('nested_message', MessageField(2, 'NestedMessage')),
], extensions=[
('descriptor_pool_test',
ExtensionField(1001, 'DescriptorPoolTest1')),
]),
},
dependencies=['google/protobuf/internal/descriptor_pool_test1.proto',
'google/protobuf/internal/more_messages.proto'],
dependencies=[
'google/protobuf/internal/more_messages.proto',
'google/protobuf/internal/descriptor_pool_test1.proto',
],
public_dependencies=['google/protobuf/internal/more_messages.proto'])

View File

@ -32,7 +32,6 @@ syntax = "proto2";
package google.protobuf.python.internal;
message DescriptorPoolTest1 {
extensions 1000 to max;

View File

@ -32,12 +32,11 @@ syntax = "proto2";
package google.protobuf.python.internal;
import "google/protobuf/internal/descriptor_pool_test1.proto";
import public "google/protobuf/internal/more_messages.proto";
import "google/protobuf/internal/descriptor_pool_test1.proto";
message DescriptorPoolTest3 {
extend DescriptorPoolTest1 {
optional DescriptorPoolTest3 descriptor_pool_test = 1001;
}
@ -70,4 +69,3 @@ message DescriptorPoolTest3 {
optional NestedMessage nested_message = 2;
}

View File

@ -823,6 +823,16 @@ class DescriptorCopyToProtoTest(unittest.TestCase):
deprecated: true
>
>
field {
name: "deprecated_message"
number: 3
label: LABEL_OPTIONAL
type: TYPE_MESSAGE
type_name: ".protobuf_unittest.TestAllTypes.NestedMessage"
options {
deprecated: true
}
}
field {
name: "deprecated_int32_in_oneof"
number: 2

View File

@ -36,7 +36,6 @@ package google.protobuf.python.internal;
import "google/protobuf/internal/factory_test1.proto";
enum Factory2Enum {
FACTORY_2_VALUE_0 = 0;
FACTORY_2_VALUE_1 = 1;
@ -73,7 +72,6 @@ message Factory2Message {
optional Factory2Enum enum_with_default = 20 [default = FACTORY_2_VALUE_1];
optional bytes bytes_with_default = 21 [default = "a\373\000c"];
extend Factory1Message {
optional string one_more_field = 1001;
}
@ -100,5 +98,6 @@ extend Factory1Message {
message MessageWithOption {
option no_standard_descriptor_accessor = true;
optional int32 field1 = 1;
}

View File

@ -30,10 +30,10 @@
syntax = "proto2";
import "google/protobuf/descriptor.proto";
package google.protobuf.python.internal;
import "google/protobuf/descriptor.proto";
message FooOptions {
optional string foo_name = 1;
}

View File

@ -31,12 +31,13 @@
// This file contains messages that extend MessageSet.
syntax = "proto2";
package google.protobuf.internal;
package google.protobuf.internal;
// A message with message_set_wire_format.
message TestMessageSet {
option message_set_wire_format = true;
extensions 4 to max;
}

View File

@ -43,7 +43,9 @@ message TestEnumValues {
}
message TestMissingEnumValues {
enum NestedEnum { TWO = 2; }
enum NestedEnum {
TWO = 2;
}
optional NestedEnum optional_nested_enum = 1;
repeated NestedEnum repeated_nested_enum = 2;
repeated NestedEnum packed_nested_enum = 3 [packed = true];

View File

@ -36,10 +36,10 @@
syntax = "proto2";
import "google/protobuf/internal/more_extensions.proto";
package google.protobuf.internal;
import "google/protobuf/internal/more_extensions.proto";
message DynamicMessageType {
optional int32 a = 1;
}

View File

@ -1,3 +1,5 @@
// NOLINT(no_package_specified): Test proto with no package
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/

View File

@ -39,35 +39,36 @@ message TestPackedTypes {
BAZ = 2;
}
repeated int32 repeated_int32 = 1;
repeated int64 repeated_int64 = 2;
repeated uint32 repeated_uint32 = 3;
repeated uint64 repeated_uint64 = 4;
repeated sint32 repeated_sint32 = 5;
repeated sint64 repeated_sint64 = 6;
repeated fixed32 repeated_fixed32 = 7;
repeated fixed64 repeated_fixed64 = 8;
repeated sfixed32 repeated_sfixed32 = 9;
repeated int32 repeated_int32 = 1;
repeated int64 repeated_int64 = 2;
repeated uint32 repeated_uint32 = 3;
repeated uint64 repeated_uint64 = 4;
repeated sint32 repeated_sint32 = 5;
repeated sint64 repeated_sint64 = 6;
repeated fixed32 repeated_fixed32 = 7;
repeated fixed64 repeated_fixed64 = 8;
repeated sfixed32 repeated_sfixed32 = 9;
repeated sfixed64 repeated_sfixed64 = 10;
repeated float repeated_float = 11;
repeated double repeated_double = 12;
repeated bool repeated_bool = 13;
repeated float repeated_float = 11;
repeated double repeated_double = 12;
repeated bool repeated_bool = 13;
repeated NestedEnum repeated_nested_enum = 14;
}
message TestUnpackedTypes {
repeated int32 repeated_int32 = 1 [packed = false];
repeated int64 repeated_int64 = 2 [packed = false];
repeated uint32 repeated_uint32 = 3 [packed = false];
repeated uint64 repeated_uint64 = 4 [packed = false];
repeated sint32 repeated_sint32 = 5 [packed = false];
repeated sint64 repeated_sint64 = 6 [packed = false];
repeated fixed32 repeated_fixed32 = 7 [packed = false];
repeated fixed64 repeated_fixed64 = 8 [packed = false];
repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
repeated int32 repeated_int32 = 1 [packed = false];
repeated int64 repeated_int64 = 2 [packed = false];
repeated uint32 repeated_uint32 = 3 [packed = false];
repeated uint64 repeated_uint64 = 4 [packed = false];
repeated sint32 repeated_sint32 = 5 [packed = false];
repeated sint64 repeated_sint64 = 6 [packed = false];
repeated fixed32 repeated_fixed32 = 7 [packed = false];
repeated fixed64 repeated_fixed64 = 8 [packed = false];
repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
repeated float repeated_float = 11 [packed = false];
repeated double repeated_double = 12 [packed = false];
repeated bool repeated_bool = 13 [packed = false];
repeated TestPackedTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
repeated float repeated_float = 11 [packed = false];
repeated double repeated_double = 12 [packed = false];
repeated bool repeated_bool = 13 [packed = false];
repeated TestPackedTypes.NestedEnum repeated_nested_enum = 14
[packed = false];
}

View File

@ -70,7 +70,7 @@
#include "google/protobuf/pyext/unknown_field_set.h"
#include "google/protobuf/pyext/unknown_fields.h"
#include "google/protobuf/util/message_differencer.h"
#include "google/protobuf/stubs/strutil.h"
#include "strings/util.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/strtod.h"

View File

@ -71,7 +71,7 @@ filegroup(
name = "protobuf",
srcs = [
":srcs",
"//third_party/utf8_range:all_files",
"@utf8_range//:utf8_range_srcs",
] + select({
":java_ruby": [":protobuf_java"],
"@bazel_tools//src/conditions:darwin": [":protobuf_c_mac"],

View File

@ -84,12 +84,16 @@ if RUBY_PLATFORM == "java"
else
unless ENV['IN_DOCKER'] == 'true'
# We need utf8_range in-tree.
if ENV['BAZEL'] == 'true'
utf8_root = '../external/utf8_range'
else
utf8_root = '../third_party/utf8_range'
end
FileUtils.mkdir_p("ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp("../third_party/utf8_range/utf8_range.h", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp("../third_party/utf8_range/naive.c", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp("../third_party/utf8_range/range2-neon.c", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp("../third_party/utf8_range/range2-sse.c", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp("../third_party/utf8_range/LICENSE", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp(utf8_root+"/utf8_range.h", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp(utf8_root+"/naive.c", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp(utf8_root+"/range2-neon.c", "ext/google/protobuf_c/third_party/utf8_range")
FileUtils.cp(utf8_root+"/range2-sse.c", "ext/google/protobuf_c/third_party/utf8_range")
end
Rake::ExtensionTask.new("protobuf_c", spec) do |ext|

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "google-protobuf"
s.version = "3.21.7"
s.version = "3.21.8"
git_tag = "v#{s.version.to_s.sub('.rc.', '-rc')}" # Converts X.Y.Z.rc.N to vX.Y.Z-rcN, used for the git tag
s.licenses = ["BSD-3-Clause"]
s.summary = "Protocol Buffers"

View File

@ -23,7 +23,7 @@ def internal_ruby_extension(
":srcs",
":test_ruby_protos",
":tests",
"//third_party/utf8_range:all_files",
"@utf8_range//:utf8_range_srcs",
],
tags = ["manual"],
outs = [extension],

View File

@ -9,7 +9,7 @@
<groupId>com.google.protobuf.jruby</groupId>
<artifactId>protobuf-jruby</artifactId>
<version>3.21.7</version>
<version>3.21.8</version>
<name>Protocol Buffer JRuby native extension</name>
<description>
Protocol Buffers are a way of encoding structured data in an efficient yet
@ -76,7 +76,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.21.7</version>
<version>3.21.8</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>

View File

@ -5,8 +5,8 @@ set -ex
test_version() {
version=$1
bazel_args=" \
-k --test_output=streamed \
bazel_args="\
$(../kokoro/common/bazel_flags.sh) \
--action_env=PATH \
--action_env=GEM_PATH \
--action_env=GEM_HOME \

View File

@ -72,10 +72,7 @@ set(libprotobuf_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/service.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.cc
@ -173,7 +170,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/service.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/logging.h
@ -181,7 +177,6 @@ set(libprotobuf_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/platform_macros.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/port.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/status_macros.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h
${protobuf_SOURCE_DIR}/src/google/protobuf/text_format.h
${protobuf_SOURCE_DIR}/src/google/protobuf/unknown_field_set.h
${protobuf_SOURCE_DIR}/src/google/protobuf/util/delimited_message_util.h
@ -220,10 +215,7 @@ set(libprotobuf_lite_srcs
${protobuf_SOURCE_DIR}/src/google/protobuf/parse_context.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc
)
@ -264,7 +256,6 @@ set(libprotobuf_lite_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/port.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/repeated_ptr_field.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/callback.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/logging.h
@ -272,7 +263,6 @@ set(libprotobuf_lite_hdrs
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/platform_macros.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/port.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/status_macros.h
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h
${protobuf_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h
)
@ -725,8 +715,5 @@ set(util_test_protos_files
# //src/google/protobuf/stubs:test_srcs
set(stubs_test_files
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/bytestream_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/common_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid_unittest.cc
${protobuf_SOURCE_DIR}/src/google/protobuf/stubs/strutil_unittest.cc
)

View File

@ -316,6 +316,7 @@ cc_library(
"@com_google_absl//absl/strings:internal",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@utf8_range//:utf8_validity",
],
)
@ -385,6 +386,7 @@ cc_library(
"@com_google_absl//absl/strings:internal",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@utf8_range//:utf8_validity",
],
)

Some files were not shown because too many files have changed in this diff Show More