Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cxx_extractor): fix cc proto_lang_toolchain #5843

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 2 additions & 30 deletions kythe/extractors/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,9 @@ java_library(
# --proto_toolchain_for_cc=@io_kythe//kythe/extractors:cc_proto_toolchain
proto_lang_toolchain(
name = "cc_proto_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--PLUGIN_C++_out=:$(OUT)",
plugin = "//kythe/cxx/tools:proto_metadata_plugin",
runtime = "@com_google_protobuf//:protobuf",
runtime = "@com_google_protobuf//:protobuf_nowkt",
)

# Alternatively, if the plugin doesn't work you can use the default code generator
Expand All @@ -64,22 +50,8 @@ proto_lang_toolchain(
# --cc_proto_library_header_suffixes=.pb.h,.pb.h.meta
proto_lang_toolchain(
name = "cc_native_proto_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=annotate_headers,annotation_pragma_name=kythe_metadata,annotation_guard_name=KYTHE_IS_RUNNING:$(OUT)",
runtime = "@com_google_protobuf//:protobuf",
runtime = "@com_google_protobuf//:protobuf_nowkt",
)

extractor_action(
Expand Down
28 changes: 0 additions & 28 deletions kythe/release/release.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,6 @@ java_library(
# cross-language metadata file generation.
proto_lang_toolchain(
name = "cc_proto_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--$(PLUGIN_OUT)=:$(OUT)",
plugin = ":cc_proto_metadata_plugin",
runtime = "@com_google_protobuf//:protobuf",
Expand All @@ -91,20 +77,6 @@ proto_lang_toolchain(
# --cc_proto_library_header_suffixes=.pb.h,.pb.h.meta
proto_lang_toolchain(
name = "cc_native_proto_toolchain",
blacklisted_protos = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:api_proto",
"@com_google_protobuf//:compiler_plugin_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:empty_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:source_context_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:type_proto",
"@com_google_protobuf//:wrappers_proto",
],
command_line = "--cpp_out=annotate_headers,annotation_pragma_name=kythe_metadata,annotation_guard_name=KYTHE_IS_RUNNING:$(OUT)",
runtime = "@com_google_protobuf//:protobuf",
)
Expand Down
3 changes: 3 additions & 0 deletions setup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ def kythe_rule_repositories():
# Use the rules_rust provided proto plugin, rather than the native one
# which hijacks the --rust_out command line and is incompatible.
"//third_party:protobuf-no-rust.patch",
# Patch https://github.com/protocolbuffers/protobuf/commit/5b6c2459b57c23669d6efc5a14a874c693004eec
# until it gets included in a release.
"//third_party:protobuf-nowkt.patch",
],
patch_args = [
"-p1",
Expand Down
31 changes: 31 additions & 0 deletions third_party/protobuf-nowkt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From 5b6c2459b57c23669d6efc5a14a874c693004eec Mon Sep 17 00:00:00 2001
From: Protobuf Team Bot <protobuf-github-bot@google.com>
Date: Thu, 14 Sep 2023 12:04:25 -0700
Subject: [PATCH] Expose alias to protobuf_nowkt runtime

This will allow users such as Kythe to use the same runtime as the default toolchain in their own proto_lang_toolchain definitions.

PiperOrigin-RevId: 565438071
---
BUILD.bazel | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/BUILD.bazel b/BUILD.bazel
index 88a19996826..492b750c8a3 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -198,6 +198,14 @@ cc_binary(
# C++ runtime
################################################################################

+# Expose the runtime for the proto_lang_toolchain so that it can also be used in
+# a user-defined proto_lang_toolchain.
+alias(
+ name = "protobuf_nowkt",
+ actual = "//src/google/protobuf:protobuf_nowkt",
+ visibility = ["//visibility:public"],
+)
+
# The "lite" runtime works for .proto files that specify the option:
# optimize_for = LITE_RUNTIME;
#