Sync from Piper @467099277 PROTOBUF_SYNC_PIPER
diff --git a/BUILD.bazel b/BUILD.bazel index 3734b49..3572636 100644 --- a/BUILD.bazel +++ b/BUILD.bazel
@@ -1,12 +1,11 @@ # Bazel (https://bazel.build/) BUILD file for Protobuf. -load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") -load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library") +load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library") load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS", "PROTOC_LINK_OPTS") -load(":protobuf.bzl", "internal_py_proto_library", "internal_php_proto_library", "internal_ruby_proto_library", "internal_objc_proto_library") +load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library") licenses(["notice"]) @@ -438,9 +437,9 @@ internal_objc_proto_library( name = "test_messages_proto2_objc_proto", + testonly = 1, srcs = ["//src/google/protobuf:test_messages_proto2.proto"], includes = ["src/google/protobuf"], - testonly = 1, visibility = [ "//conformance:__pkg__", "//objectivec:__subpackages__", @@ -449,10 +448,13 @@ internal_objc_proto_library( name = "test_messages_proto3_objc_proto", - srcs = ["//src/google/protobuf:test_messages_proto3.proto"], - proto_deps = [":well_known_protos"], - includes = ["src/google/protobuf", "src"], testonly = 1, + srcs = ["//src/google/protobuf:test_messages_proto3.proto"], + includes = [ + "src", + "src/google/protobuf", + ], + proto_deps = [":well_known_protos"], visibility = [ "//conformance:__pkg__", "//objectivec:__subpackages__", @@ -461,10 +463,10 @@ internal_php_proto_library( name = "test_messages_proto3_php_proto", + testonly = 1, srcs = ["//src/google/protobuf:test_messages_proto3.proto"], - proto_deps = [":well_known_protos"], - includes = ["src/google/protobuf", "src"], outs = [ + "GPBMetadata/TestMessagesProto3.php", "Protobuf_test_messages/Proto3/EnumOnlyProto3.php", "Protobuf_test_messages/Proto3/EnumOnlyProto3/PBBool.php", "Protobuf_test_messages/Proto3/ForeignEnum.php", @@ -474,9 +476,12 @@ "Protobuf_test_messages/Proto3/TestAllTypesProto3/AliasedEnum.php", "Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedEnum.php", "Protobuf_test_messages/Proto3/TestAllTypesProto3/NestedMessage.php", - "GPBMetadata/TestMessagesProto3.php", ], - testonly = 1, + includes = [ + "src", + "src/google/protobuf", + ], + proto_deps = [":well_known_protos"], visibility = [ "//conformance:__pkg__", "//php:__subpackages__", @@ -485,9 +490,9 @@ internal_ruby_proto_library( name = "test_messages_proto2_ruby_proto", + testonly = 1, srcs = ["//src/google/protobuf:test_messages_proto2.proto"], includes = ["src/google/protobuf"], - testonly = 1, visibility = [ "//conformance:__pkg__", "//ruby:__subpackages__", @@ -496,10 +501,13 @@ internal_ruby_proto_library( name = "test_messages_proto3_ruby_proto", - srcs = ["//src/google/protobuf:test_messages_proto3.proto"], - proto_deps = [":well_known_protos"], - includes = ["src/google/protobuf", "src"], testonly = 1, + srcs = ["//src/google/protobuf:test_messages_proto3.proto"], + includes = [ + "src", + "src/google/protobuf", + ], + proto_deps = [":well_known_protos"], visibility = [ "//conformance:__pkg__", "//ruby:__subpackages__",
diff --git a/WORKSPACE b/WORKSPACE index ebe5331..20e7415 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -9,11 +9,10 @@ http_archive( name = "com_google_googletest", - sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb", - strip_prefix = "googletest-release-1.10.0", + sha256 = "ea54c9845568cb31c03f2eddc7a40f7f83912d04ab977ff50ec33278119548dd", + strip_prefix = "googletest-4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774", urls = [ - "https://mirror.bazel.build/github.com/google/googletest/archive/release-1.10.0.tar.gz", - "https://github.com/google/googletest/archive/release-1.10.0.tar.gz", + "https://github.com/google/googletest/archive/4c9a3bb62bf3ba1f1010bf96f9c8ed767b363774.tar.gz", ], )
diff --git a/benchmarks/BUILD.bazel b/benchmarks/BUILD.bazel index 46c908b..60a9092 100644 --- a/benchmarks/BUILD.bazel +++ b/benchmarks/BUILD.bazel
@@ -2,7 +2,7 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_php_proto_library") +load("//:protobuf.bzl", "internal_php_proto_library", "internal_py_proto_library") ################################################################################ # Benchmark Protos
diff --git a/benchmarks/cpp/cpp_benchmark.cc b/benchmarks/cpp/cpp_benchmark.cc index 0cfb916..ffb3a3d 100644 --- a/benchmarks/cpp/cpp_benchmark.cc +++ b/benchmarks/cpp/cpp_benchmark.cc
@@ -30,6 +30,7 @@ #include <fstream> #include <iostream> + #include "benchmark/benchmark.h" #include "benchmarks.pb.h" #include "benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h" @@ -38,7 +39,6 @@ #include "benchmarks/datasets/google_message3/benchmark_message3.pb.h" #include "benchmarks/datasets/google_message4/benchmark_message4.pb.h" - #define PREFIX "dataset." #define SUFFIX ".pb"
diff --git a/benchmarks/datasets/BUILD.bazel b/benchmarks/datasets/BUILD.bazel index 4d4b195..d3d8cdf 100644 --- a/benchmarks/datasets/BUILD.bazel +++ b/benchmarks/datasets/BUILD.bazel
@@ -90,21 +90,18 @@ filegroup( name = "php_protos", - visibility = [ - "//benchmarks:__subpackages__", - ], srcs = [ "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_php_proto", "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_php_proto", "//benchmarks/datasets/google_message2:benchmark_message2_php_proto", ], + visibility = [ + "//benchmarks:__subpackages__", + ], ) filegroup( name = "csharp_protos", - visibility = [ - "//benchmarks:__subpackages__", - ], srcs = [ "//benchmarks/datasets/google_message1/proto2:benchmark_message1_proto2_csharp_proto", "//benchmarks/datasets/google_message1/proto3:benchmark_message1_proto3_csharp_proto", @@ -112,6 +109,9 @@ "//benchmarks/datasets/google_message3:benchmark_message3_csharp_proto", "//benchmarks/datasets/google_message4:benchmark_message4_csharp_proto", ], + visibility = [ + "//benchmarks:__subpackages__", + ], ) pkg_files(
diff --git a/benchmarks/datasets/google_message1/proto2/BUILD.bazel b/benchmarks/datasets/google_message1/proto2/BUILD.bazel index b7ee62c..0bde1e8 100644 --- a/benchmarks/datasets/google_message1/proto2/BUILD.bazel +++ b/benchmarks/datasets/google_message1/proto2/BUILD.bazel
@@ -2,8 +2,8 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_csharp_proto_library") -load("//benchmarks/util:compatibility.bzl", "proto3_from_proto2_data", "php_proto3_from_proto2_library") +load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_py_proto_library") +load("//benchmarks/util:compatibility.bzl", "php_proto3_from_proto2_library", "proto3_from_proto2_data") filegroup( name = "datasets",
diff --git a/benchmarks/datasets/google_message1/proto3/BUILD.bazel b/benchmarks/datasets/google_message1/proto3/BUILD.bazel index ae9b400..37cbf09 100644 --- a/benchmarks/datasets/google_message1/proto3/BUILD.bazel +++ b/benchmarks/datasets/google_message1/proto3/BUILD.bazel
@@ -2,7 +2,7 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_php_proto_library", "internal_csharp_proto_library") +load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_php_proto_library", "internal_py_proto_library") filegroup( name = "datasets",
diff --git a/benchmarks/datasets/google_message2/BUILD.bazel b/benchmarks/datasets/google_message2/BUILD.bazel index 654a3e2..d4e52d4 100644 --- a/benchmarks/datasets/google_message2/BUILD.bazel +++ b/benchmarks/datasets/google_message2/BUILD.bazel
@@ -2,8 +2,8 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_csharp_proto_library") -load("//benchmarks/util:compatibility.bzl", "proto3_from_proto2_data", "php_proto3_from_proto2_library") +load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_py_proto_library") +load("//benchmarks/util:compatibility.bzl", "php_proto3_from_proto2_library", "proto3_from_proto2_data") filegroup( name = "datasets",
diff --git a/benchmarks/datasets/google_message3/BUILD.bazel b/benchmarks/datasets/google_message3/BUILD.bazel index 68ad3f8..1f9d0c5 100644 --- a/benchmarks/datasets/google_message3/BUILD.bazel +++ b/benchmarks/datasets/google_message3/BUILD.bazel
@@ -2,7 +2,7 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_csharp_proto_library") +load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_py_proto_library") filegroup( name = "datasets",
diff --git a/benchmarks/datasets/google_message4/BUILD.bazel b/benchmarks/datasets/google_message4/BUILD.bazel index 079a9a2..a19ffbb 100644 --- a/benchmarks/datasets/google_message4/BUILD.bazel +++ b/benchmarks/datasets/google_message4/BUILD.bazel
@@ -2,7 +2,7 @@ load("@rules_java//java:defs.bzl", "java_proto_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_proto//proto:defs.bzl", "proto_library") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_csharp_proto_library") +load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_py_proto_library") filegroup( name = "datasets",
diff --git a/benchmarks/internal.bzl b/benchmarks/internal.bzl index c060353..485921f 100644 --- a/benchmarks/internal.bzl +++ b/benchmarks/internal.bzl
@@ -2,6 +2,7 @@ PLEASE DO NOT DEPEND ON THE CONTENTS OF THIS FILE, IT IS UNSTABLE. """ + load("//build_defs:internal_shell.bzl", "inline_sh_binary") def internal_benchmark_test( @@ -31,7 +32,8 @@ " ".join(env_vars), binary, " ".join(args), - " ".join(dataset_labels)), + " ".join(dataset_labels), + ), tags = ["benchmark"], testonly = 1, )
diff --git a/benchmarks/java/BUILD.bazel b/benchmarks/java/BUILD.bazel index f8976bf..1e11809 100644 --- a/benchmarks/java/BUILD.bazel +++ b/benchmarks/java/BUILD.bazel
@@ -1,4 +1,4 @@ -load("@rules_java//java:defs.bzl", "java_library", "java_binary") +load("@rules_java//java:defs.bzl", "java_binary", "java_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("//build_defs:internal_shell.bzl", "inline_sh_binary") load("//benchmarks:internal.bzl", "internal_benchmark_test") @@ -22,7 +22,6 @@ inline_sh_binary( name = "java_benchmark", srcs = ["//benchmarks/datasets"], - tools = [":java_benchmark_jar"], cmd = """ data_files="" conf=() @@ -35,7 +34,8 @@ done $(rootpath :java_benchmark_jar) com.google.protobuf.ProtoCaliperBenchmark \ -i runtime -DdataFile=$${data_files:0:-1} $${conf[*]} - """ + """, + tools = [":java_benchmark_jar"], ) # A pre-configured binary using the checked in datasets.
diff --git a/benchmarks/php/BUILD.bazel b/benchmarks/php/BUILD.bazel index a1a9319..a00f23b 100644 --- a/benchmarks/php/BUILD.bazel +++ b/benchmarks/php/BUILD.bazel
@@ -5,58 +5,58 @@ # The benchmark binary which can be run over any dataset. inline_sh_binary( name = "php_benchmark", + testonly = 1, srcs = [ "PhpBenchmark.php", "autoload.php", ], - deps = [ - "//benchmarks:benchmarks_php_proto", - "//benchmarks/datasets:php_protos", - "//php:source_files", - ], cmd = """ php -d include_path=benchmarks:php/src \\ -d auto_prepend_file=$(rootpath autoload.php) \\ $(rootpath PhpBenchmark.php) $$@ """, - testonly = 1, + deps = [ + "//benchmarks:benchmarks_php_proto", + "//benchmarks/datasets:php_protos", + "//php:source_files", + ], ) # A pre-configured binary using the checked in datasets. internal_benchmark_test( name = "php", + args = ["--behavior_prefix='php'"], binary = ":php_benchmark", datasets = ["//benchmarks/datasets:proto3_datasets"], env_vars = ["PROTOBUF_PHP_SRCDIR=php/src"], - args = ["--behavior_prefix='php'"], ) # The benchmark binary which can be run over any dataset. inline_sh_binary( name = "php_c_benchmark", + testonly = 1, srcs = [ "PhpBenchmark.php", "//php:extension", ], - deps = [ - "//benchmarks:benchmarks_php_proto", - "//benchmarks/datasets:php_protos", - ], cmd = """ php -d include_path=benchmarks:php/src \\ -dextension=$(rootpath //php:extension) \\ $(rootpath PhpBenchmark.php) $$@ """, - testonly = 1, + deps = [ + "//benchmarks:benchmarks_php_proto", + "//benchmarks/datasets:php_protos", + ], ) # A pre-configured binary using the checked in datasets. internal_benchmark_test( name = "php_c", + args = ["--behavior_prefix='php_c'"], binary = ":php_c_benchmark", datasets = ["//benchmarks/datasets:proto3_datasets"], env_vars = ["PROTOBUF_PHP_SRCDIR=php/src"], - args = ["--behavior_prefix='php_c'"], ) pkg_files(
diff --git a/benchmarks/python/BUILD.bazel b/benchmarks/python/BUILD.bazel index a8b1801..f1d85f1 100644 --- a/benchmarks/python/BUILD.bazel +++ b/benchmarks/python/BUILD.bazel
@@ -1,37 +1,37 @@ load("@rules_cc//cc:defs.bzl", "cc_binary") -load("@rules_python//python:defs.bzl", "py_library", "py_binary") +load("@rules_python//python:defs.bzl", "py_binary", "py_library") load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") load("//benchmarks:internal.bzl", "internal_benchmark_test") cc_binary( name = "libbenchmark_messages.so", srcs = ["python_benchmark_messages.cc"], - deps = [ - "@local_config_python//:python_headers", - "//external:python_headers", - "//benchmarks:benchmarks_cc_proto", - "//benchmarks/datasets:cc_protos", - ], linkshared = True, linkstatic = True, visibility = ["//visibility:private"], + deps = [ + "//benchmarks:benchmarks_cc_proto", + "//benchmarks/datasets:cc_protos", + "//external:python_headers", + "@local_config_python//:python_headers", + ], ) # The benchmark binary which can be run over any dataset. py_binary( name = "python_benchmark", srcs = ["py_benchmark.py"], - main = "py_benchmark.py", data = ["libbenchmark_messages.so"], + env = select({ + "//python:use_fast_cpp_protos": {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "cpp"}, + "//conditions:default": {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"}, + }), + main = "py_benchmark.py", deps = [ "//:protobuf_python", "//benchmarks:benchmarks_py_proto", "//benchmarks/datasets:py_protos", ], - env = select({ - "//python:use_fast_cpp_protos": {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "cpp"}, - "//conditions:default": {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"}, - }), ) # Pre-configured binaries using the checked in datasets. @@ -54,10 +54,10 @@ # Note: this requires --define=use_fast_cpp_protos=true internal_benchmark_test( name = "cpp_generated_code", + args = ["--cpp_generated"], binary = ":python_benchmark", datasets = ["//benchmarks/datasets"], env_vars = ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp"], - args = ["--cpp_generated"], ) pkg_files(
diff --git a/benchmarks/python/py_benchmark.py b/benchmarks/python/py_benchmark.py index 053c78c..76784f2 100644 --- a/benchmarks/python/py_benchmark.py +++ b/benchmarks/python/py_benchmark.py
@@ -6,6 +6,12 @@ import argparse import fnmatch import json +from benchmarks.datasets.google_message1.proto2 import benchmark_message1_proto2_pb2 +from benchmarks.datasets.google_message1.proto3 import benchmark_message1_proto3_pb2 +from benchmarks.datasets.google_message2 import benchmark_message2_pb2 +from benchmarks.datasets.google_message3 import benchmark_message3_pb2 +from benchmarks.datasets.google_message4 import benchmark_message4_pb2 +from benchmarks import benchmarks_pb2 parser = argparse.ArgumentParser(description="Python protobuf benchmark") parser.add_argument("data_files", metavar="dataFile", nargs="+", @@ -27,19 +33,11 @@ # for the descriptor can be found in the pool if args.cpp_generated != "no": sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(__file__) ) ) + "/.libs" ) - from benchmarks.python import libbenchmark_messages + from benchmarks.python import libbenchmark_messages # pylint: disable=unused-import,g-import-not-at-top sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(__file__) ) ) + "/tmp" ) # END CPP GENERATED MESSAGE -import benchmarks.datasets.google_message1.proto2.benchmark_message1_proto2_pb2 as benchmark_message1_proto2_pb2 -import benchmarks.datasets.google_message1.proto3.benchmark_message1_proto3_pb2 as benchmark_message1_proto3_pb2 -import benchmarks.datasets.google_message2.benchmark_message2_pb2 as benchmark_message2_pb2 -import benchmarks.datasets.google_message3.benchmark_message3_pb2 as benchmark_message3_pb2 -import benchmarks.datasets.google_message4.benchmark_message4_pb2 as benchmark_message4_pb2 -import benchmarks.benchmarks_pb2 as benchmarks_pb2 - - def run_one_test(filename): data = open(filename, "rb").read() benchmark_dataset = benchmarks_pb2.BenchmarkDataset() @@ -135,9 +133,9 @@ if t < 3 : reps = int(math.ceil(3 / t)) * self.full_iteration if reps != self.full_iteration: - t = timeit.timeit(stmt="%s(%s)" % (self.test_method, test_method_args), - setup=self.full_setup_code(setup_method_args), - number=reps); + t = timeit.timeit(stmt="%s(%s)" % (self.test_method, test_method_args), + setup=self.full_setup_code(setup_method_args), + number=reps); return self.total_bytes * 1.0 / 2 ** 20 / (1.0 * t / reps * self.full_iteration)
diff --git a/benchmarks/util/BUILD.bazel b/benchmarks/util/BUILD.bazel index 6b3aa2b..256862e 100644 --- a/benchmarks/util/BUILD.bazel +++ b/benchmarks/util/BUILD.bazel
@@ -7,15 +7,15 @@ cc_binary( name = "protoc-gen-proto2_to_proto3", srcs = [ - "schema_proto2_to_proto3_util.h", "protoc-gen-proto2_to_proto3.cc", - ], - deps = [ - "//:protobuf", - "//src/google/protobuf/compiler:code_generator", - "//benchmarks:benchmarks_cc_proto", + "schema_proto2_to_proto3_util.h", ], visibility = ["//benchmarks:__subpackages__"], + deps = [ + "//:protobuf", + "//benchmarks:benchmarks_cc_proto", + "//src/google/protobuf/compiler:code_generator", + ], ) cc_binary( @@ -26,8 +26,8 @@ ], deps = [ "//:protobuf", - "//benchmarks/datasets:cc_protos", "//benchmarks:benchmarks_cc_proto", + "//benchmarks/datasets:cc_protos", ], )
diff --git a/benchmarks/util/compatibility.bzl b/benchmarks/util/compatibility.bzl index 044ade6..840fd45 100644 --- a/benchmarks/util/compatibility.bzl +++ b/benchmarks/util/compatibility.bzl
@@ -6,9 +6,9 @@ load("//:protobuf.bzl", "internal_php_proto_library") def proto3_from_proto2_data( - name, - srcs, - **kwargs): + name, + srcs, + **kwargs): """Transforms proto2 binary data into a proto3-compatible format, Args: @@ -22,7 +22,7 @@ for src in srcs: outs.append("proto3/" + src) out_files.append("$(RULEDIR)/proto3/" + src) - src_files.append("$(rootpath %s)" % src); + src_files.append("$(rootpath %s)" % src) native.genrule( name = name + "_genrule", @@ -32,13 +32,15 @@ ], outs = outs, cmd = "$(execpath //benchmarks/util:proto3_data_stripper) %s %s" % ( - " ".join(src_files), " ".join(out_files)), + " ".join(src_files), + " ".join(out_files), + ), ) native.filegroup( name = name, srcs = outs, - **kwargs, + **kwargs ) def _proto3_from_proto2_library( @@ -56,7 +58,7 @@ src_files = [] for src in srcs: outs.append(src + "3") - src_files.append("$(rootpath %s)" % src); + src_files.append("$(rootpath %s)" % src) native.genrule( name = name, @@ -74,7 +76,7 @@ --proto2_to_proto3_out=$(GENDIR) \ %s """ % (" ".join(src_files)), - **kwargs, + **kwargs ) def php_proto3_from_proto2_library( @@ -99,5 +101,5 @@ name = name, srcs = [name + "_genrule"], outs = outs, - **kwargs, + **kwargs )
diff --git a/benchmarks/util/proto3_data_stripper.cc b/benchmarks/util/proto3_data_stripper.cc index 68f4905..c34745e 100644 --- a/benchmarks/util/proto3_data_stripper.cc +++ b/benchmarks/util/proto3_data_stripper.cc
@@ -1,3 +1,5 @@ +#include <fstream> + #include "benchmarks.pb.h" #include "benchmarks/datasets/google_message1/proto2/benchmark_message1_proto2.pb.h" #include "benchmarks/datasets/google_message1/proto3/benchmark_message1_proto3.pb.h" @@ -6,8 +8,6 @@ #include "benchmarks/datasets/google_message4/benchmark_message4.pb.h" #include "data_proto2_to_proto3_util.h" -#include <fstream> - using google::protobuf::util::Proto3DataStripper; std::string ReadFile(const std::string& name) {
diff --git a/benchmarks/util/protoc-gen-proto2_to_proto3.cc b/benchmarks/util/protoc-gen-proto2_to_proto3.cc index 3073e0f..cc550ce 100644 --- a/benchmarks/util/protoc-gen-proto2_to_proto3.cc +++ b/benchmarks/util/protoc-gen-proto2_to_proto3.cc
@@ -7,15 +7,15 @@ #include "google/protobuf/compiler/plugin.h" -using google::protobuf::FileDescriptorProto; -using google::protobuf::FileDescriptor; using google::protobuf::DescriptorPool; +using google::protobuf::FileDescriptor; +using google::protobuf::FileDescriptorProto; using google::protobuf::io::Printer; -using google::protobuf::util::SchemaGroupStripper; using google::protobuf::util::EnumScrubber; using google::protobuf::util::ExtensionStripper; using google::protobuf::util::FieldScrubber; using google::protobuf::util::ImportScrubber; +using google::protobuf::util::SchemaGroupStripper; namespace google { namespace protobuf { @@ -37,9 +37,8 @@ class Proto2ToProto3Generator final : public CodeGenerator { public: bool GenerateAll(const std::vector<const FileDescriptor*>& files, - const std::string& parameter, - GeneratorContext* context, - std::string* error) const { + const std::string& parameter, GeneratorContext* context, + std::string* error) const { for (int i = 0; i < files.size(); i++) { for (auto file : files) { if (CanGenerate(file)) { @@ -52,10 +51,8 @@ return true; } - bool Generate(const FileDescriptor* file, - const std::string& parameter, - GeneratorContext* context, - std::string* error) const { + bool Generate(const FileDescriptor* file, const std::string& parameter, + GeneratorContext* context, std::string* error) const { FileDescriptorProto new_file; file->CopyTo(&new_file); new_file.set_name(ImportScrubber::ScrubFilename(file->name())); @@ -71,7 +68,7 @@ std::string filename = file->name(); std::string basename = StripProtoExt(filename); - std::vector<std::pair<std::string,std::string>> option_pairs; + std::vector<std::pair<std::string, std::string>> option_pairs; ParseGeneratorParameter(parameter, &option_pairs); std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> output( @@ -82,14 +79,16 @@ return true; } + private: bool CanGenerate(const FileDescriptor* file) const { - if (GetPool()->FindFileByName(ImportScrubber::ScrubFilename(file->name())) != nullptr) { + if (GetPool()->FindFileByName( + ImportScrubber::ScrubFilename(file->name())) != nullptr) { return false; } for (int j = 0; j < file->dependency_count(); j++) { if (GetPool()->FindFileByName(ImportScrubber::ScrubFilename( - file->dependency(j)->name())) == nullptr) { + file->dependency(j)->name())) == nullptr) { return false; } }
diff --git a/benchmarks/util/result_parser.py b/benchmarks/util/result_parser.py index a35c1db..d61b3c0 100644 --- a/benchmarks/util/result_parser.py +++ b/benchmarks/util/result_parser.py
@@ -1,12 +1,14 @@ +"""Parses benchmark results into a standardized json output.""" + import argparse import json import re import os.path +from benchmarks import benchmarks_pb2 # BEGIN OPENSOURCE import sys sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)) # END OPENSOURCE -from benchmarks import benchmarks_pb2 __file_size_map = {}
diff --git a/benchmarks/util/schema_proto2_to_proto3_util.h b/benchmarks/util/schema_proto2_to_proto3_util.h index ea7b796..bd6ff26 100644 --- a/benchmarks/util/schema_proto2_to_proto3_util.h +++ b/benchmarks/util/schema_proto2_to_proto3_util.h
@@ -189,11 +189,11 @@ class ImportScrubber { public: - static std::string ScrubFilename(const std::string& filename) { + static std::string ScrubFilename(const std::string &filename) { return filename + "3"; } static void ScrubFile(FileDescriptorProto *file) { - for(std::string& import: *file->mutable_dependency()) { + for (std::string &import : *file->mutable_dependency()) { import += "3"; } }
diff --git a/build_defs/arch_tests.bzl b/build_defs/arch_tests.bzl index 7f8a6af..61fa00c 100644 --- a/build_defs/arch_tests.bzl +++ b/build_defs/arch_tests.bzl
@@ -9,9 +9,7 @@ bazel_binaries = [], system_binaries = [], **kwargs): - """ - Bazel rule to verify that a Bazel or system binary is built for the - aarch64 architecture. + """Bazel rule to verify that a Bazel or system binary is built for the aarch64 architecture. Args: name: the name of the test. @@ -19,7 +17,7 @@ file_platform: the expected output of `file`. bazel_binaries: a set of binary targets to inspect. system_binaries: a set of paths to system executables to inspect. - **kargs: other keyword arguments that are passed to the test. + **kwargs: other keyword arguments that are passed to the test. """ inline_sh_test( @@ -30,27 +28,29 @@ (file -L $$binary | grep -q "%s") \ || (echo "Test binary is not an %s binary: "; file -L $$binary; exit 1) done - """ % (" ".join(bazel_binaries), - " ".join(system_binaries), - file_platform, - platform), + """ % ( + " ".join(bazel_binaries), + " ".join(system_binaries), + file_platform, + platform, + ), target_compatible_with = select({ - "//build_defs:"+platform: [], - "//conditions:default": ["@platforms//:incompatible"], + "//build_defs:" + platform: [], + "//conditions:default": ["@platforms//:incompatible"], }), + **kwargs ) - def aarch64_test(**kwargs): - _arch_test_impl( - platform = "aarch64", - file_platform = "ELF 64-bit LSB executable, ARM aarch64", - **kwargs, - ) + _arch_test_impl( + platform = "aarch64", + file_platform = "ELF 64-bit LSB executable, ARM aarch64", + **kwargs + ) def x86_64_test(**kwargs): - _arch_test_impl( - platform = "x86_64", - file_platform = "ELF 64-bit LSB executable, ARM x86_64", - **kwargs, - ) + _arch_test_impl( + platform = "x86_64", + file_platform = "ELF 64-bit LSB executable, ARM x86_64", + **kwargs + )
diff --git a/build_defs/internal_shell.bzl b/build_defs/internal_shell.bzl index 0dda146..670c4d5 100644 --- a/build_defs/internal_shell.bzl +++ b/build_defs/internal_shell.bzl
@@ -1,3 +1,8 @@ +""" +Internal tools to migrate shell commands to Bazel as an intermediate step +to wider Bazelification. +""" + def inline_sh_binary( name, srcs = [], @@ -6,9 +11,11 @@ cmd = "", testonly = None, **kwargs): - """Bazel rule to wrap up an inline bash script in a binary. This is most - useful as a stop-gap solution for migrating off Autotools. These binaries - are likely to be non-hermetic, with implicit system dependencies. + """Bazel rule to wrap up an inline bash script in a binary. + + This is most useful as a stop-gap solution for migrating off Autotools. + These binaries are likely to be non-hermetic, with implicit system + dependencies. NOTE: the rule is only an internal workaround. The interface may change and the rule may be removed when everything is properly "Bazelified". @@ -19,12 +26,12 @@ tools: the executable tools used directly by the script. Any target used with rootpath/execpath/location must be declared here or in `srcs`. deps: a list of dependency labels that are required to run this binary. - **kargs: other keyword arguments that are passed to sh_binary. + cmd: the inline sh command to run. + **kwargs: other keyword arguments that are passed to sh_binary. testonly: common rule attribute (see: https://bazel.build/reference/be/common-definitions#common-attributes) """ - native.genrule( name = name + "_genrule", srcs = srcs, @@ -50,9 +57,10 @@ deps = [], cmd = "", **kwargs): - """Bazel rule to wrap up an inline bash script in a test. This is most - useful as a stop-gap solution for migrating off Autotools. These tests - are likely to be non-hermetic, with implicit system dependencies. + """Bazel rule to wrap up an inline bash script in a test. + + This is most useful as a stop-gap solution for migrating off Autotools. + These tests are likely to be non-hermetic, with implicit system dependencies. NOTE: the rule is only an internal workaround. The interface may change and the rule may be removed when everything is properly "Bazelified". @@ -63,11 +71,11 @@ tools: the executable tools used directly by the script. Any target used with rootpath/execpath/location must be declared here or in `srcs`. deps: a list of dependency labels that are required to run this binary. - **kargs: other keyword arguments that are passed to sh_binary. + cmd: the inline sh command to run. + **kwargs: other keyword arguments that are passed to sh_binary. https://bazel.build/reference/be/common-definitions#common-attributes) """ - native.genrule( name = name + "_genrule", srcs = srcs,
diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel index 0e7ad59..28b3628 100644 --- a/conformance/BUILD.bazel +++ b/conformance/BUILD.bazel
@@ -1,8 +1,7 @@ # Conformance testing for Protobuf. load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "objc_library") -load("@rules_python//python:defs.bzl", "py_library") -load("//:protobuf.bzl", "internal_py_proto_library", "internal_php_proto_library", "internal_csharp_proto_library", "internal_ruby_proto_library", "internal_objc_proto_library") +load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library") load("//build_defs:internal_shell.bzl", "inline_sh_binary") load( "@rules_pkg//:mappings.bzl", @@ -94,10 +93,10 @@ internal_py_proto_library( name = "conformance_py_proto", srcs = ["conformance.proto"], + srcs_version = "PY2AND3", visibility = [ "//python:__subpackages__", ], - srcs_version = "PY2AND3", ) internal_php_proto_library( @@ -183,21 +182,25 @@ cc_binary( name = "conformance_cpp", + testonly = 1, srcs = ["conformance_cpp.cc"], + visibility = ["//src:__subpackages__"], deps = [ ":conformance_cc_proto", "//:protobuf", "//:test_messages_proto2_cc_proto", "//:test_messages_proto3_cc_proto", ], - testonly = 1, - visibility = ["//src:__subpackages__"], ) java_binary( name = "conformance_java", + testonly = 1, srcs = ["ConformanceJava.java"], main_class = "ConformanceJava", + visibility = [ + "//java:__subpackages__", + ], deps = [ ":conformance_java_proto", "//:protobuf_java", @@ -205,14 +208,12 @@ "//:test_messages_proto2_java_proto", "//:test_messages_proto3_java_proto", ], - testonly = 1, - visibility = [ - "//java:__subpackages__", - ], ) java_binary( name = "conformance_java_lite", + testonly = 1, + srcs = ["ConformanceJavaLite.java"], main_class = "ConformanceJavaLite", visibility = [ "//java:__subpackages__", @@ -224,110 +225,111 @@ "//:test_messages_proto2_java_proto_lite", "//:test_messages_proto3_java_proto_lite", ], - testonly = 1, - srcs = ["ConformanceJavaLite.java"], ) py_binary( name = "conformance_python", + testonly = 1, srcs = ["conformance_python.py"], + imports = [ + "..", + "../python", + ], + srcs_version = "PY2AND3", + visibility = ["//python:__subpackages__"], deps = [ ":conformance_py_proto", "//:protobuf_python", "//python:test_messages_proto2_py_proto", "//python:test_messages_proto3_py_proto", ], - imports = [".", "../python"], - srcs_version = "PY2AND3", - testonly = 1, - visibility = ["//python:__subpackages__"], ) inline_sh_binary( name = "conformance_php", + testonly = 1, srcs = [ - "conformance_php.php", "autoload.php", - ], - deps = [ - ":conformance_php_proto", - "//php:source_files", - "//:test_messages_proto3_php_proto", + "conformance_php.php", ], cmd = """ php -d include_path=conformance:src/google/protobuf \\ -d auto_prepend_file=$(rootpath autoload.php) \\ $(rootpath conformance_php.php) """, - testonly = 1, visibility = ["//php:__subpackages__"], + deps = [ + ":conformance_php_proto", + "//:test_messages_proto3_php_proto", + "//php:source_files", + ], ) inline_sh_binary( name = "conformance_php_c", + testonly = 1, srcs = [ "conformance_php.php", "//php:extension", ], - deps = [ - ":conformance_php_proto", - "//:test_messages_proto3_php_proto", - ], cmd = """ php -dextension=$(rootpath //php:extension) \\ -d include_path=conformance:src/google/protobuf \\ $(rootpath conformance_php.php) """, - testonly = 1, visibility = ["//php:__subpackages__"], + deps = [ + ":conformance_php_proto", + "//:test_messages_proto3_php_proto", + ], ) inline_sh_binary( name = "conformance_csharp", + testonly = 1, srcs = ["//csharp/src/Google.Protobuf.Conformance:conformance_dll"], + cmd = "dotnet $(rootpath //csharp/src/Google.Protobuf.Conformance:conformance_dll)", + visibility = ["//csharp:__subpackages__"], deps = [ "//csharp/src/Google.Protobuf.Conformance:conformance_runfiles", ], - cmd = "dotnet $(rootpath //csharp/src/Google.Protobuf.Conformance:conformance_dll)", - testonly = 1, - visibility = ["//csharp:__subpackages__"], ) objc_library( name = "conformance_objc_lib", + testonly = 1, non_arc_srcs = ["conformance_objc.m"], + # See https://github.com/bazelbuild/bazel/issues/12897. + tags = ["manual"], deps = [ ":conformance_objc_proto", "//:test_messages_proto2_objc_proto", "//:test_messages_proto3_objc_proto", ], - testonly = 1, - # See https://github.com/bazelbuild/bazel/issues/12897. - tags = ["manual"], ) cc_binary( name = "conformance_objc", - deps = [":conformance_objc_lib"], testonly = 1, # See https://github.com/bazelbuild/bazel/issues/12897. tags = ["manual"], visibility = ["//objectivec:__subpackages__"], + deps = [":conformance_objc_lib"], ) inline_sh_binary( name = "conformance_ruby", + testonly = 1, srcs = ["conformance_ruby.rb"], + cmd = "RUBYLIB=ruby/lib:conformance:src $(rootpath conformance_ruby.rb)", + visibility = ["//ruby:__subpackages__"], deps = [ ":conformance_ruby_proto", - "//:well_known_ruby_protos", "//:test_messages_proto2_ruby_proto", "//:test_messages_proto3_ruby_proto", + "//:well_known_ruby_protos", "//ruby:protobuf", ], - cmd = "RUBYLIB=ruby/lib:conformance:src $(rootpath conformance_ruby.rb)", - testonly = 1, - visibility = ["//ruby:__subpackages__"], ) ################################################################################
diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc index cbfd8b5..85fa9d0 100644 --- a/conformance/conformance_cpp.cc +++ b/conformance/conformance_cpp.cc
@@ -45,6 +45,7 @@ #include <google/protobuf/stubs/status.h> #include <google/protobuf/stubs/statusor.h> #include "conformance/conformance.pb.h" +#include "conformance/conformance.pb.h" #include <google/protobuf/test_messages_proto2.pb.h> #include <google/protobuf/test_messages_proto3.pb.h> #include <google/protobuf/test_messages_proto3.pb.h>
diff --git a/conformance/conformance_python.py b/conformance/conformance_python.py index 37ee36e..cffadc9 100755 --- a/conformance/conformance_python.py +++ b/conformance/conformance_python.py
@@ -42,7 +42,7 @@ from google.protobuf import test_messages_proto3_pb2 from google.protobuf import test_messages_proto2_pb2 from google.protobuf import text_format -import conformance_pb2 +from conformance import conformance_pb2 sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0) sys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)
diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index 2c856f5..9b8b71f 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc
@@ -42,7 +42,7 @@ #include <google/protobuf/util/field_comparator.h> #include <google/protobuf/util/json_util.h> #include <google/protobuf/util/message_differencer.h> -#include "conformance.pb.h" +#include "conformance/conformance.pb.h" using conformance::ConformanceRequest; using conformance::ConformanceResponse;
diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h index 2861598..298e780 100644 --- a/conformance/conformance_test.h +++ b/conformance/conformance_test.h
@@ -45,7 +45,7 @@ #include <google/protobuf/descriptor.h> #include <google/protobuf/wire_format_lite.h> #include <google/protobuf/util/type_resolver.h> -#include "conformance.pb.h" +#include "conformance/conformance.pb.h" namespace conformance { class ConformanceRequest;
diff --git a/conformance/conformance_test_runner.cc b/conformance/conformance_test_runner.cc index 2aac35c..6dfb25b 100644 --- a/conformance/conformance_test_runner.cc +++ b/conformance/conformance_test_runner.cc
@@ -63,7 +63,7 @@ #include <vector> #include <google/protobuf/stubs/stringprintf.h> -#include "conformance.pb.h" +#include "conformance/conformance.pb.h" #include "conformance_test.h" using conformance::ConformanceResponse;
diff --git a/conformance/defs.bzl b/conformance/defs.bzl index e6eceb8..c7357e0 100644 --- a/conformance/defs.bzl +++ b/conformance/defs.bzl
@@ -39,7 +39,7 @@ "@bazel_tools//tools/bash/runfiles", ], tags = ["conformance"], - **kwargs, + **kwargs ) def _strip_bazel(testee):
diff --git a/examples/Makefile b/examples/Makefile index 2a64b64..ef7a4ef 100644 --- a/examples/Makefile +++ b/examples/Makefile
@@ -41,11 +41,11 @@ add_person_cpp: add_person.cc protoc_middleman pkg-config --cflags protobuf # fails if protobuf is not installed - c++ -std=c++11 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` + c++ -std=c++14 add_person.cc addressbook.pb.cc -o add_person_cpp `pkg-config --cflags --libs protobuf` list_people_cpp: list_people.cc protoc_middleman pkg-config --cflags protobuf # fails if protobuf is not installed - c++ -std=c++11 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf` + c++ -std=c++14 list_people.cc addressbook.pb.cc -o list_people_cpp `pkg-config --cflags --libs protobuf` add_person_dart: add_person.dart protoc_middleman_dart
diff --git a/generate_descriptor_proto.sh b/generate_descriptor_proto.sh index d1b13d1..91c1217 100755 --- a/generate_descriptor_proto.sh +++ b/generate_descriptor_proto.sh
@@ -62,7 +62,7 @@ PROTOC=$BOOTSTRAP_PROTOC BOOTSTRAP_PROTOC="" else - bazel build -j$(nproc) $@ //:protoc + bazel build $@ //:protoc if test $? -ne 0; then echo "Failed to build protoc." exit 1
diff --git a/java/internal/BUILD.bazel b/java/internal/BUILD.bazel index 598b8b5..ff111e7 100644 --- a/java/internal/BUILD.bazel +++ b/java/internal/BUILD.bazel
@@ -1,7 +1,7 @@ -package(default_visibility = ["//java:__subpackages__"]) - load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") +package(default_visibility = ["//java:__subpackages__"]) + pkg_files( name = "dist_files", srcs = [ @@ -15,8 +15,8 @@ java_test( name = "java_version", - test_class = "JavaVersionTest", srcs = ["JavaVersionTest.java"], + test_class = "JavaVersionTest", deps = [ "@maven//:com_google_truth_truth", "@maven//:junit_junit",
diff --git a/java/internal/JavaVersionTest.java b/java/internal/JavaVersionTest.java deleted file mode 100644 index eb004d5..0000000 --- a/java/internal/JavaVersionTest.java +++ /dev/null
@@ -1,22 +0,0 @@ -// Test that Kokoro is using the expected version of Java. -import static com.google.common.truth.Truth.assertWithMessage; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class JavaVersionTest { - @Test - public void testJavaVersion() throws Exception { - String exp = System.getenv("KOKORO_JAVA_VERSION"); - if(exp == null || exp.isEmpty()) { - System.err.println("No kokoro java version found, skipping check"); - return; - } - String version = System.getProperty("java.version"); - assertWithMessage("Expected Python " + exp + " but found Python " + version) - .that(version.startsWith(exp)) - .isTrue(); - } -}
diff --git a/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh b/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh index 2880507..7f07968 100755 --- a/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh +++ b/kokoro/linux/aarch64/protoc_crosscompile_aarch64.sh
@@ -4,5 +4,5 @@ set -ex -cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 . +cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 -Dprotobuf_BUILD_TESTS=OFF . make -j8
diff --git a/kokoro/linux/aarch64/python_crosscompile_aarch64.sh b/kokoro/linux/aarch64/python_crosscompile_aarch64.sh index 97d0a24..a04c7e4 100755 --- a/kokoro/linux/aarch64/python_crosscompile_aarch64.sh +++ b/kokoro/linux/aarch64/python_crosscompile_aarch64.sh
@@ -12,7 +12,7 @@ git submodule update --init --recursive # Build protoc and libprotobuf -cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 . +cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_WITH_ZLIB=0 -Dprotobuf_BUILD_TESTS=OFF . make -j8 # create a simple shell wrapper that runs crosscompiled protoc under qemu
diff --git a/kokoro/linux/aarch64/test_ruby_aarch64.sh b/kokoro/linux/aarch64/test_ruby_aarch64.sh index 91ee5f2..e256e4e 100755 --- a/kokoro/linux/aarch64/test_ruby_aarch64.sh +++ b/kokoro/linux/aarch64/test_ruby_aarch64.sh
@@ -24,4 +24,4 @@ # otherwise the UID would be homeless under the docker container and pip install wouldn't work. For simplicity, # we just run map the user's home to a throwaway temporary directory -docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work arm64v8/ruby:2.7.3-buster kokoro/linux/aarch64/ruby_build_and_run_tests_with_qemu_aarch64.sh \ No newline at end of file +docker run $DOCKER_TTY_ARGS --rm --user "$(id -u):$(id -g)" -e "HOME=/home/fake-user" -e "PROTOC=/work/protoc" -v "$(mktemp -d):/home/fake-user" -v "$(pwd)":/work -w /work arm64v8/ruby:2.7.3-buster kokoro/linux/aarch64/ruby_build_and_run_tests_with_qemu_aarch64.sh
diff --git a/kokoro/linux/ruby_aarch64/build.sh b/kokoro/linux/ruby_aarch64/build.sh new file mode 100755 index 0000000..6473e0d --- /dev/null +++ b/kokoro/linux/ruby_aarch64/build.sh
@@ -0,0 +1,16 @@ +#!/bin/bash +# +# This is the top-level script we give to Kokoro as the entry point for +# running the "continuous" and "presubmit" jobs. + +set -ex + +# Change to repo root +cd $(dirname $0)/../../.. + +# Initialize any submodules. +git submodule update --init --recursive + +kokoro/linux/aarch64/qemu_helpers/prepare_qemu.sh + +kokoro/linux/aarch64/test_ruby_aarch64.sh
diff --git a/kokoro/linux/ruby_aarch64/continuous.cfg b/kokoro/linux/ruby_aarch64/continuous.cfg index 044e826..ae82696 100644 --- a/kokoro/linux/ruby_aarch64/continuous.cfg +++ b/kokoro/linux/ruby_aarch64/continuous.cfg
@@ -1,26 +1,11 @@ # Config file for running tests in Kokoro # Location of the build script in repository -build_file: "protobuf/kokoro/linux/bazel.sh" +build_file: "protobuf/kokoro/linux/ruby_aarch64/build.sh" timeout_mins: 120 -env_vars { - key: "CONTAINER_IMAGE" - value: "gcr.io/protobuf-build/emulation/linux:aarch64-4e847d7a01c1792471b6dd985ab0bf2677332e6f" -} - -env_vars { - key: "BAZEL_TARGETS" - value: "//ruby/..." -} - -env_vars { - key: "BAZEL_EXTRA_FLAGS" - value: "--define=ruby_platform=c" -} - action { define_artifacts { - regex: "**/sponge_log.*" + regex: "**/sponge_log.xml" } }
diff --git a/kokoro/linux/ruby_aarch64/presubmit.cfg b/kokoro/linux/ruby_aarch64/presubmit.cfg index 044e826..ae82696 100644 --- a/kokoro/linux/ruby_aarch64/presubmit.cfg +++ b/kokoro/linux/ruby_aarch64/presubmit.cfg
@@ -1,26 +1,11 @@ # Config file for running tests in Kokoro # Location of the build script in repository -build_file: "protobuf/kokoro/linux/bazel.sh" +build_file: "protobuf/kokoro/linux/ruby_aarch64/build.sh" timeout_mins: 120 -env_vars { - key: "CONTAINER_IMAGE" - value: "gcr.io/protobuf-build/emulation/linux:aarch64-4e847d7a01c1792471b6dd985ab0bf2677332e6f" -} - -env_vars { - key: "BAZEL_TARGETS" - value: "//ruby/..." -} - -env_vars { - key: "BAZEL_EXTRA_FLAGS" - value: "--define=ruby_platform=c" -} - action { define_artifacts { - regex: "**/sponge_log.*" + regex: "**/sponge_log.xml" } }
diff --git a/php/generate_descriptor_protos.sh b/php/generate_descriptor_protos.sh index 2239312..1a600ab 100755 --- a/php/generate_descriptor_protos.sh +++ b/php/generate_descriptor_protos.sh
@@ -5,10 +5,10 @@ set -e -PROTOC=protoc +PROTOC=$(realpath protoc) if [ ! -f $PROTOC ]; then bazel build -c opt //:protoc - PROTOC=bazel-bin/protoc + PROTOC=$(realpath bazel-bin/protoc) fi if test ! -e src/google/protobuf/stubs/common.h; then @@ -19,16 +19,17 @@ exit 1 fi -$PROTOC --php_out=internal:php/src google/protobuf/descriptor.proto -$PROTOC --php_out=internal_generate_c_wkt:php/src \ - src/google/protobuf/any.proto \ - src/google/protobuf/api.proto \ - src/google/protobuf/duration.proto \ - src/google/protobuf/empty.proto \ - src/google/protobuf/field_mask.proto \ - src/google/protobuf/source_context.proto \ - src/google/protobuf/struct.proto \ - src/google/protobuf/type.proto \ - src/google/protobuf/timestamp.proto \ - src/google/protobuf/wrappers.proto +pushd src +$PROTOC --php_out=internal:../php/src google/protobuf/descriptor.proto +$PROTOC --php_out=internal_generate_c_wkt:../php/src \ + google/protobuf/any.proto \ + google/protobuf/api.proto \ + google/protobuf/duration.proto \ + google/protobuf/empty.proto \ + google/protobuf/field_mask.proto \ + google/protobuf/source_context.proto \ + google/protobuf/struct.proto \ + google/protobuf/type.proto \ + google/protobuf/timestamp.proto \ + google/protobuf/wrappers.proto popd
diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 6f35175..f9111ce 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel
@@ -381,9 +381,9 @@ "//src/google/protobuf/util:differencer", "//src/google/protobuf/util:field_mask_util", "//src/google/protobuf/util:json_util", - "//src/google/protobuf/util:zero_copy_sink", "//src/google/protobuf/util:time_util", "//src/google/protobuf/util:type_resolver_util", + "//src/google/protobuf/util:zero_copy_sink", "//src/google/protobuf/util/internal:datapiece", "//src/google/protobuf/util/internal:default_value", "//src/google/protobuf/util/internal:field_mask_utility", @@ -427,23 +427,23 @@ cc_dist_library( name = "compiler_annotation_test_util", - deps = ["//src/google/protobuf/compiler:annotation_test_util"], testonly = 1, tags = ["manual"], + deps = ["//src/google/protobuf/compiler:annotation_test_util"], ) cc_dist_library( name = "compiler_mock_code_generator", - deps = ["//src/google/protobuf/compiler:mock_code_generator"], testonly = 1, tags = ["manual"], + deps = ["//src/google/protobuf/compiler:mock_code_generator"], ) cc_dist_library( name = "testinglib", - deps = ["//src/google/protobuf/testing"], testonly = 1, tags = ["manual"], + deps = ["//src/google/protobuf/testing"], ) ################################################################################
diff --git a/python/BUILD.bazel b/python/BUILD.bazel index 75d3a5d..118bb4d 100644 --- a/python/BUILD.bazel +++ b/python/BUILD.bazel
@@ -7,7 +7,6 @@ # //:well_known_types_py_pb2 load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") -load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_python//python:defs.bzl", "py_library") load("//:protobuf.bzl", "internal_py_proto_library") load("//build_defs:cpp_opts.bzl", "COPTS") @@ -53,8 +52,8 @@ internal_copy_files( name = "copied_wkt_proto_files", srcs = [ - "//src/google/protobuf:descriptor_proto_srcs", "//:well_known_type_protos", + "//src/google/protobuf:descriptor_proto_srcs", ], strip_prefix = "src", ) @@ -216,28 +215,28 @@ internal_py_proto_library( name = "test_messages_proto2_py_proto", testonly = 1, - visibility = [ - "//conformance:__pkg__", - "//python:__subpackages__", - ], srcs = [":copied_test_messages_proto2_files"], include = ".", default_runtime = "//:protobuf_python", protoc = "//:protoc", + visibility = [ + "//conformance:__pkg__", + "//python:__subpackages__", + ], ) internal_py_proto_library( name = "test_messages_proto3_py_proto", testonly = 1, + srcs = [":copied_test_messages_proto3_files"], + include = ".", + default_runtime = "//:protobuf_python", + protoc = "//:protoc", visibility = [ "//conformance:__pkg__", "//python:__subpackages__", ], - srcs = [":copied_test_messages_proto3_files"], deps = [":well_known_types_py_pb2"], - include = ".", - default_runtime = "//:protobuf_python", - protoc = "//:protoc", ) py_library( @@ -400,27 +399,27 @@ conformance_test( name = "conformance_test", - failure_list = "//conformance:failure_list_python.txt", - testee = "//conformance:conformance_python", - text_format_failure_list = "//conformance:text_format_failure_list_python.txt", env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"}, + failure_list = "//conformance:failure_list_python.txt", target_compatible_with = select({ ":use_fast_cpp_protos": ["@platforms//:incompatible"], "//conditions:default": [], }), + testee = "//conformance:conformance_python", + text_format_failure_list = "//conformance:text_format_failure_list_python.txt", ) # Note: this requires --define=use_fast_cpp_protos=true conformance_test( name = "conformance_test_cpp", - failure_list = "//conformance:failure_list_python.txt", - testee = "//conformance:conformance_python", - text_format_failure_list = "//conformance:text_format_failure_list_python_cpp.txt", env = {"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "cpp"}, + failure_list = "//conformance:failure_list_python.txt", target_compatible_with = select({ ":use_fast_cpp_protos": [], "//conditions:default": ["@platforms//:incompatible"], }), + testee = "//conformance:conformance_python", + text_format_failure_list = "//conformance:text_format_failure_list_python_cpp.txt", ) ################################################################################
diff --git a/python/python_version.py b/python/python_version.py index 5c2b5a6..5bf8d21 100644 --- a/python/python_version.py +++ b/python/python_version.py
@@ -27,12 +27,12 @@ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - """Test that Kokoro is using the expected version of python.""" import os -import unittest import sys +import unittest + class PythonVersionTest(unittest.TestCase): @@ -40,11 +40,12 @@ """Test that we can import nested import public messages.""" exp = os.getenv('KOKORO_PYTHON_VERSION', '') - if exp == '': - print("No kokoro python version found, skipping check", file=sys.stderr) + if not exp: + print('No kokoro python version found, skipping check', file=sys.stderr) return - self.assertTrue(sys.version.startswith(exp), - "Expected Python %s but found Python %s" % (exp, sys.version)) + self.assertTrue( + sys.version.startswith(exp), + 'Expected Python %s but found Python %s' % (exp, sys.version)) if __name__ == '__main__':
diff --git a/python/setup.py b/python/setup.py index 283c99a..7564bc7 100755 --- a/python/setup.py +++ b/python/setup.py
@@ -306,7 +306,8 @@ else: library_dirs = ['..'] - TestConformanceCmd.target = '//python:conformance_test_cpp --define=use_fast_cpp_protos=true' + TestConformanceCmd.target = ('//python:conformance_test_cpp ' + '--define=use_fast_cpp_protos=true') extra_compile_args = []
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel index ac9b420..49f052d 100644 --- a/src/google/protobuf/BUILD.bazel +++ b/src/google/protobuf/BUILD.bazel
@@ -216,8 +216,8 @@ "field_mask.pb.cc", "generated_message_bases.cc", "generated_message_reflection.cc", - "generated_message_tctable_gen.cc", "generated_message_tctable_full.cc", + "generated_message_tctable_gen.cc", "map_field.cc", "message.cc", "reflection_ops.cc", @@ -458,13 +458,16 @@ ], ) -exports_files([ - "test_messages_proto2.proto", - "test_messages_proto3.proto", -], visibility = [ - "//:__pkg__", - "//python:__pkg__", -]) +exports_files( + [ + "test_messages_proto2.proto", + "test_messages_proto3.proto", + ], + visibility = [ + "//:__pkg__", + "//python:__pkg__", + ], +) proto_library( name = "test_messages_proto2_proto", @@ -480,6 +483,10 @@ name = "test_messages_proto3_proto", srcs = ["test_messages_proto3.proto"], strip_import_prefix = "/src", + visibility = [ + "//:__pkg__", + "//conformance:__pkg__", + ], deps = [ ":any_proto", ":duration_proto", @@ -488,10 +495,6 @@ ":timestamp_proto", ":wrappers_proto", ], - visibility = [ - "//:__pkg__", - "//conformance:__pkg__", - ], ) cc_proto_library(
diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel index e3cb41b..4a4c9aa 100644 --- a/src/google/protobuf/compiler/BUILD.bazel +++ b/src/google/protobuf/compiler/BUILD.bazel
@@ -6,7 +6,6 @@ load( "@rules_pkg//:mappings.bzl", "pkg_attributes", - "pkg_filegroup", "pkg_files", "strip_prefix", ) @@ -116,7 +115,6 @@ visibility = ["//visibility:public"], ) - # Test that the protoc binary is built for the correct architecture. aarch64_test( name = "protoc_aarch64_test",
diff --git a/src/google/protobuf/compiler/command_line_interface_unittest.cc b/src/google/protobuf/compiler/command_line_interface_unittest.cc index eb969f5..b2cf3d5 100644 --- a/src/google/protobuf/compiler/command_line_interface_unittest.cc +++ b/src/google/protobuf/compiler/command_line_interface_unittest.cc
@@ -359,7 +359,8 @@ if (plugin_path.empty() || !FileExists(plugin_path)) { GOOGLE_LOG(ERROR) - << "Plugin tests are likely to fail. Plugin executable not found at: " << plugin_path; + << "Plugin executable not found. Plugin tests are likely to fail." + << plugin_path; } else { args.push_back("--plugin=prefix-gen-plug=" + plugin_path); }
diff --git a/src/google/protobuf/stubs/common.cc b/src/google/protobuf/stubs/common.cc index 3fa3d04..feff7a1 100644 --- a/src/google/protobuf/stubs/common.cc +++ b/src/google/protobuf/stubs/common.cc
@@ -118,10 +118,9 @@ snprintf(buffer, sizeof(buffer), "%d.%d", minor, micro); // Guard against broken MSVC snprintf(). - buffer[sizeof(buffer)-1] = '\0'; + buffer[sizeof(buffer) - 1] = '\0'; return buffer; - } } // namespace internal
diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 6478768..892c66f 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h
@@ -106,10 +106,12 @@ const char* filename); // Converts a numeric version number to a string. -std::string PROTOBUF_EXPORT VersionString(int version); +std::string PROTOBUF_EXPORT +VersionString(int version); // NOLINT(runtime/string) // Prints the protoc compiler version (no major version) -std::string PROTOBUF_EXPORT ProtocVersionString(int version); +std::string PROTOBUF_EXPORT +ProtocVersionString(int version); // NOLINT(runtime/string) } // namespace internal
diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index 8f38f7c..f309770 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h
@@ -101,7 +101,11 @@ // identifies the encoding of this data, it is possible to skip // unrecognized fields for forwards compatibility. - enum WireType { + enum WireType +#ifndef SWIG + : int +#endif // !SWIG + { WIRETYPE_VARINT = 0, WIRETYPE_FIXED64 = 1, WIRETYPE_LENGTH_DELIMITED = 2,