Skip to content

Commit

Permalink
Upgrade grpc, googletest, rules_k8s and protobuf deps
Browse files Browse the repository at this point in the history
Summary:
This brings them up to newer versions and unblocks a bazel 6.0 upgrade.
Note that the proto-js compiler was removed from the base protobuf repo and so we have to manually pull it in now.

Test Plan: All existing tests should pass.

Reviewers: zasgar, michelle, jamesbartlett, #third_party_approvers

Reviewed By: zasgar, #third_party_approvers

Signed-off-by: Vihang Mehta <[email protected]>

Differential Revision: https://phab.corp.pixielabs.ai/D12639

GitOrigin-RevId: 707de2b3a8ccd20f9eccc815b01487158878eca6
  • Loading branch information
vihangm authored and copybaranaut committed Dec 22, 2022
1 parent 3f3aeef commit 00a76c5
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 62 deletions.
10 changes: 5 additions & 5 deletions bazel/external/grpc.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 4e29496147..77d32a56a9 100644
index 0112285fb9..07aad9eb80 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -98,6 +98,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File* file,
@@ -97,6 +97,7 @@ std::string GetHeaderPrologue(grpc_generator::File* file,
? kCppGeneratorMessageHeaderExt
: params.message_header_extension;

+ printer->Print(vars, "#pragma once\n");
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
"// If you make any local change, they will be lost.\n");
@@ -2151,6 +2152,7 @@ grpc::string GetMockPrologue(grpc_generator::File* file,
@@ -2153,6 +2154,7 @@ std::string GetMockPrologue(grpc_generator::File* file,
: params.message_header_extension;
vars["service_header_ext"] = kCppGeneratorServiceHeaderExt;

+ printer->Print(vars, "#pragma once\n");
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
Expand Down
6 changes: 3 additions & 3 deletions bazel/external/grpc_go_toolchain.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl
index 4d8afa3131..514189f9a5 100644
--- a/bazel/grpc_extra_deps.bzl
+++ b/bazel/grpc_extra_deps.bzl
@@ -53,5 +53,5 @@ def grpc_extra_deps(ignore_version_differences = False):
@@ -53,7 +53,7 @@ def grpc_extra_deps(ignore_version_differences = False):
api_dependencies()

go_rules_dependencies()
- go_register_toolchains(version = "1.18")
+ go_register_toolchains()
gazelle_dependencies()

# Pull-in the go 3rd party dependencies for protoc_gen_validate, which is
6 changes: 3 additions & 3 deletions bazel/external/grpc_test_visibility.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/BUILD b/BUILD
index 8a12aa15b7..cf0eda62f9 100644
index cb6cdc2891..c4d7f2ab8c 100644
--- a/BUILD
+++ b/BUILD
@@ -5088,7 +5088,7 @@ grpc_cc_library(
@@ -2073,7 +2073,7 @@ grpc_cc_library(
"include/grpcpp/test/mock_stream.h",
"include/grpcpp/test/server_context_test_spouse.h",
],
- visibility = ["@grpc:grpc++_test"],
+ visibility = ["//visibility:public"],
deps = [
"gpr_base",
"grpc++",
"grpc_base",
10 changes: 5 additions & 5 deletions bazel/external/protobuf_gogo_hack.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc
index 9ad7a33b2..8d85ad974 100644
--- a/src/google/protobuf/compiler/python/python_generator.cc
+++ b/src/google/protobuf/compiler/python/python_generator.cc
@@ -334,6 +334,12 @@ bool Generator::Generate(const FileDescriptor* file,
diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc
index d8d6d7492..211fef038 100644
--- a/src/google/protobuf/compiler/python/generator.cc
+++ b/src/google/protobuf/compiler/python/generator.cc
@@ -252,6 +252,12 @@ bool Generator::Generate(const FileDescriptor* file,
pure_python_workable_ = true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc
index d06fbcf5c..d6319c29d 100644
--- a/src/google/protobuf/compiler/js/js_generator.cc
+++ b/src/google/protobuf/compiler/js/js_generator.cc
@@ -3655,5 +3655,8 @@ void Generator::GenerateFile(const GeneratorOptions& options,
diff --git a/generator/js_generator.cc b/generator/js_generator.cc
index 97b5844..1351a54 100644
--- a/generator/js_generator.cc
+++ b/generator/js_generator.cc
@@ -3650,6 +3650,9 @@ void Generator::GenerateFile(const GeneratorOptions& options,

for (int i = 0; i < file->dependency_count(); i++) {
const std::string& name = file->dependency(i)->name();
+ if (ModuleAlias(name) == "github_com_gogo_protobuf_gogoproto_gogo_pb") {
Expand Down
12 changes: 6 additions & 6 deletions bazel/external/protobuf_text_format.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/src/google/protobuf/stubs/strutil.cc b/src/google/protobuf/stubs/strutil.cc
index 6bead9ad7..0ca8de0a3 100644
index 594c8eac6..c7ef9437b 100644
--- a/src/google/protobuf/stubs/strutil.cc
+++ b/src/google/protobuf/stubs/strutil.cc
@@ -592,7 +592,7 @@ void CEscapeAndAppend(StringPiece src, std::string *dest) {
Expand All @@ -12,7 +12,7 @@ index 6bead9ad7..0ca8de0a3 100644
CEscapeAndAppend(src, &dest);
return dest;
diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h
index 84fc2323b..ff61868ba 100644
index 9658abf90..9cf9cae83 100644
--- a/src/google/protobuf/stubs/strutil.h
+++ b/src/google/protobuf/stubs/strutil.h
@@ -328,7 +328,7 @@ PROTOBUF_EXPORT std::string UnescapeCEscapeString(const std::string& src);
Expand All @@ -25,10 +25,10 @@ index 84fc2323b..ff61868ba 100644
// ----------------------------------------------------------------------
// CEscapeAndAppend()
diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc
index 8b20d76df..d91b63270 100644
index 19110499d..0d116ee7e 100644
--- a/src/google/protobuf/text_format.cc
+++ b/src/google/protobuf/text_format.cc
@@ -83,6 +83,18 @@ inline bool IsOctNumber(const std::string& str) {
@@ -81,6 +81,18 @@ inline bool IsOctNumber(const std::string& str) {
(str[1] >= '0' && str[1] < '8'));
}

Expand All @@ -47,7 +47,7 @@ index 8b20d76df..d91b63270 100644
} // namespace

namespace internal {
@@ -2537,20 +2549,22 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
@@ -2555,20 +2567,22 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
? reflection->GetRepeatedStringReference(message, field, index,
&scratch)
: reflection->GetStringReference(message, field, &scratch);
Expand Down Expand Up @@ -81,7 +81,7 @@ index 8b20d76df..d91b63270 100644
}
break;
}
@@ -2690,7 +2704,14 @@ void TextFormat::Printer::PrintUnknownFields(
@@ -2708,7 +2722,14 @@ void TextFormat::Printer::PrintUnknownFields(
// This field is not parseable as a Message (or we ran out of
// recursion budget). So it is probably just a plain string.
generator->PrintMaybeWithMarker(": ", "\"");
Expand Down
8 changes: 4 additions & 4 deletions bazel/external/protobuf_warning.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index bfc6b0552..0adbe3551 100644
index 5e9a2c418..f95684bd1 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -1729,8 +1729,8 @@ CommandLineInterface::InterpretArgument(const std::string& name,
@@ -1730,8 +1730,8 @@ CommandLineInterface::InterpretArgument(const std::string& name,
if (access(disk_path.c_str(), F_OK) < 0) {
// Try the original path; it may have just happened to have a '=' in it.
if (access(parts[i].c_str(), F_OK) < 0) {
Expand All @@ -14,10 +14,10 @@ index bfc6b0552..0adbe3551 100644
virtual_path = "";
disk_path = parts[i];
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index c8ce218a9..f54791103 100644
index 5f3427dc7..ab049c7c6 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -7854,10 +7854,11 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
@@ -8161,10 +8161,11 @@ void DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,
if (is_error) {
AddError((*it)->name(), proto, DescriptorPool::ErrorCollector::IMPORT,
error_message);
Expand Down
28 changes: 14 additions & 14 deletions bazel/grpc_web.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _generate_grpc_web_srcs(
actions,
protoc,
protoc_gen_grpc_web,
protoc_gen_js,
mode,
well_known_proto_files,
well_known_proto_arguments,
Expand Down Expand Up @@ -112,6 +113,7 @@ def _generate_grpc_web_srcs(
out_dir = out_dir.replace(basepath, "")

args = proto_include_paths + [
"--plugin=protoc-gen-js={}".format(protoc_gen_js.path),
"--plugin=protoc-gen-grpc-web={}".format(protoc_gen_grpc_web.path),
"--js_out=import_style=commonjs,binary:{path}".format(
path = out_dir,
Expand All @@ -124,7 +126,7 @@ def _generate_grpc_web_srcs(
]

actions.run(
tools = [protoc_gen_grpc_web],
tools = [protoc_gen_grpc_web, protoc_gen_js],
inputs = all_sources + well_known_proto_files,
outputs = files,
executable = protoc,
Expand All @@ -142,24 +144,17 @@ def _grpc_web_library_impl(ctx):

# create a list of well known proto files if the argument is non-None
well_known_proto_files = []
f = ctx.attr.well_known_protos.files.to_list()[0].dirname
if f != "external/com_google_protobuf/src/google/protobuf":
print(
"Error: Only @com_google_protobuf//:well_known_protos is supported",
)
else:
# f points to "external/com_google_protobuf/src/google/protobuf"
# add -I argument to protoc so it knows where to look for the proto files.
arguments.append("-I{0}".format(f + "/../.."))
well_known_proto_files = [
f
for f in ctx.attr.well_known_protos.files.to_list()
]
arguments.append("-Iexternal/com_google_protobuf/src")
well_known_proto_files = [
f
for f in ctx.attr.well_known_protos.files.to_list()
]

srcs = _generate_grpc_web_srcs(
actions = ctx.actions,
protoc = ctx.executable._protoc,
protoc_gen_grpc_web = ctx.executable._protoc_gen_grpc_web,
protoc_gen_js = ctx.executable._protoc_gen_js,
mode = ctx.attr.mode,
well_known_proto_files = well_known_proto_files,
well_known_proto_arguments = arguments,
Expand Down Expand Up @@ -198,5 +193,10 @@ pl_grpc_web_library = rule(
executable = True,
cfg = "host",
),
"_protoc_gen_js": attr.label(
default = Label("@com_google_protobuf_javascript//generator:protoc-gen-js"),
executable = True,
cfg = "host",
),
}),
)
2 changes: 1 addition & 1 deletion bazel/pl_workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def pl_workspace_setup():
container_deps()

k8s_repositories()
k8s_go_deps()
k8s_go_deps(go_version = None)

def pl_container_images():
_package_manager_setup()
Expand Down
1 change: 0 additions & 1 deletion bazel/proto_compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def pl_cc_proto_library(name, proto, deps = [], **kwargs):
)
grpc_deps = [
"@com_github_grpc_grpc//:grpc++_codegen_proto",
"@com_github_grpc_grpc//:grpc++_codegen_base_src",
"//external:protobuf",
]
pl_cc_library_internal(
Expand Down
6 changes: 4 additions & 2 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ def _com_llvm_lib():
def _cc_deps():
# Dependencies with native bazel build files.

_bazel_repo("com_google_protobuf", patches = ["//bazel/external:protobuf.patch", "//bazel/external:protobuf_gogo_hack.patch", "//bazel/external:protobuf_text_format.patch", "//bazel/external:protobuf_warning.patch"], patch_args = ["-p1"])
_bazel_repo("com_github_grpc_grpc", patches = ["//bazel/external:grpc.patch", "//bazel/external:grpc_mirror.patch", "//bazel/external:grpc_go_toolchain.patch", "//bazel/external:grpc_test_visibility.patch", "//bazel/external:grpc_warnings.patch"], patch_args = ["-p1"])
_bazel_repo("upb")
_bazel_repo("com_google_protobuf", patches = ["//bazel/external:protobuf_gogo_hack.patch", "//bazel/external:protobuf_text_format.patch", "//bazel/external:protobuf_warning.patch"], patch_args = ["-p1"])
_bazel_repo("com_github_grpc_grpc", patches = ["//bazel/external:grpc.patch", "//bazel/external:grpc_go_toolchain.patch", "//bazel/external:grpc_test_visibility.patch", "//bazel/external:grpc_warnings.patch"], patch_args = ["-p1"])

_bazel_repo("boringssl")
_bazel_repo("com_google_benchmark")
Expand Down Expand Up @@ -232,6 +233,7 @@ def _pl_deps():
_bazel_repo("com_github_bazelbuild_buildtools")
_bazel_repo("com_google_googleapis")
_bazel_repo("com_github_fmeum_rules_meta")
_bazel_repo("com_google_protobuf_javascript", patches = ["//bazel/external:protobuf_javascript.patch"], patch_args = ["-p1"])

cc_toolchain_config_repo("unix_cc_toolchain_config", patch = "//bazel/cc_toolchains:unix_cc_toolchain_config.patch")
pl_register_cc_toolchains()
Expand Down
42 changes: 29 additions & 13 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ REPOSITORY_LOCATIONS = dict(
urls = ["https://github.com/gperftools/gperftools/releases/download/gperftools-2.9.1/gperftools-2.9.1.tar.gz"],
),
com_github_grpc_grpc = dict(
sha256 = "d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964",
strip_prefix = "grpc-1.46.3",
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.46.3.tar.gz"],
sha256 = "b55696fb249669744de3e71acc54a9382bea0dce7cd5ba379b356b12b82d4229",
strip_prefix = "grpc-1.51.1",
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.51.1.tar.gz"],
),
# August 19, 2020.
com_github_google_sentencepiece = dict(
Expand Down Expand Up @@ -269,16 +269,23 @@ REPOSITORY_LOCATIONS = dict(
],
),
com_google_googletest = dict(
sha256 = "b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5",
strip_prefix = "googletest-release-1.11.0",
urls = ["https://github.com/google/googletest/archive/release-1.11.0.tar.gz"],
sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2",
strip_prefix = "googletest-release-1.12.1",
urls = ["https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz"],
),
com_google_protobuf = dict(
sha256 = "bab1685f92cc4ea5b6420026eef6c7973ae96fc21f4f1a3ee626dc6ca6d77c12",
strip_prefix = "protobuf-22d0e265de7d2b3d2e9a00d071313502e7d4cccf",
sha256 = "63c5539a8506dc6bccd352a857cea106e0a389ce047a3ff0a78fe3f8fede410d",
strip_prefix = "protobuf-24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/22d0e265de7d2b3d2e9a00d071313502e7d4cccf.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/22d0e265de7d2b3d2e9a00d071313502e7d4cccf.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/protobuf/archive/24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/24487dd1045c7f3d64a21f38a3f0c06cc4cf2edb.tar.gz",
],
),
com_google_protobuf_javascript = dict(
sha256 = "35bca1729532b0a77280bf28ab5937438e3dcccd6b31a282d9ae84c896b6f6e3",
strip_prefix = "protobuf-javascript-3.21.2",
urls = [
"https://github.com/protocolbuffers/protobuf-javascript/archive/refs/tags/v3.21.2.tar.gz",
],
),
com_googlesource_code_re2 = dict(
Expand Down Expand Up @@ -316,10 +323,10 @@ REPOSITORY_LOCATIONS = dict(
],
),
io_bazel_rules_k8s = dict(
sha256 = "a08850199d6900328ef899906717fb1dfcc6cde62701c63725748b2e6ca1d5d9",
strip_prefix = "rules_k8s-d05cbea5c56738ef02c667c10951294928a1d64a",
sha256 = "ce5b9bc0926681e2e7f2147b49096f143e6cbc783e71bc1d4f36ca76b00e6f4a",
strip_prefix = "rules_k8s-0.7",
urls = [
"https://github.com/bazelbuild/rules_k8s/archive/d05cbea5c56738ef02c667c10951294928a1d64a.tar.gz",
"https://github.com/bazelbuild/rules_k8s/archive/refs/tags/v0.7.tar.gz",
],
),
io_bazel_rules_scala = dict(
Expand Down Expand Up @@ -362,6 +369,15 @@ REPOSITORY_LOCATIONS = dict(
"https://raw.githubusercontent.com/bazelbuild/bazel/5.3.1/tools/cpp/unix_cc_toolchain_config.bzl",
],
),
# GRPC and Protobuf pick different versions. Pick the newer one.
upb = dict(
sha256 = "017a7e8e4e842d01dba5dc8aa316323eee080cd1b75986a7d1f94d87220e6502",
strip_prefix = "upb-e4635f223e7d36dfbea3b722a4ca4807a7e882e2",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz",
"https://github.com/protocolbuffers/upb/archive/e4635f223e7d36dfbea3b722a4ca4807a7e882e2.tar.gz",
],
),
)

# To modify one of the forked repos below:
Expand Down

0 comments on commit 00a76c5

Please sign in to comment.