Skip to content

Commit 8c5bfe6

Browse files
Copilotphlax
andcommitted
Fix envoy_proto_descriptor for Protobuf v29+ with bzlmod
- Update envoy_proto_descriptor macro to explicitly reference WKT proto files - Add protobuf patch to export WKT proto files with public visibility - Modify plugin.proto visibility to public for bzlmod compatibility Co-authored-by: phlax <454682+phlax@users.noreply.github.com>
1 parent d23893a commit 8c5bfe6

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

bazel/envoy_build_system.bzl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,21 @@ def envoy_proto_descriptor(name, out, srcs = [], external_deps = []):
211211
include_paths.append("external/com_google_googleapis")
212212

213213
if "well_known_protos" in external_deps:
214-
srcs.append("@com_google_protobuf//:well_known_type_protos")
215-
srcs.append("@com_google_protobuf//:descriptor_proto_srcs")
214+
# Explicitly reference Well Known Types from their correct packages
215+
# to support Protobuf v29+ (bzlmod) structure.
216+
# Reference the proto files directly from the subpackages where they are declared.
217+
srcs.append("@com_google_protobuf//src/google/protobuf:any.proto")
218+
srcs.append("@com_google_protobuf//src/google/protobuf:api.proto")
219+
srcs.append("@com_google_protobuf//src/google/protobuf:descriptor.proto")
220+
srcs.append("@com_google_protobuf//src/google/protobuf:duration.proto")
221+
srcs.append("@com_google_protobuf//src/google/protobuf:empty.proto")
222+
srcs.append("@com_google_protobuf//src/google/protobuf:field_mask.proto")
223+
srcs.append("@com_google_protobuf//src/google/protobuf:source_context.proto")
224+
srcs.append("@com_google_protobuf//src/google/protobuf:struct.proto")
225+
srcs.append("@com_google_protobuf//src/google/protobuf:timestamp.proto")
226+
srcs.append("@com_google_protobuf//src/google/protobuf:type.proto")
227+
srcs.append("@com_google_protobuf//src/google/protobuf:wrappers.proto")
228+
srcs.append("@com_google_protobuf//src/google/protobuf/compiler:plugin.proto")
216229
include_paths.append("external/com_google_protobuf/src")
217230

218231
options = ["--include_imports"]

bazel/protobuf.patch

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,48 @@ index 8926b04e5..8994f79f2 100644
8787
cc_binary(
8888
name = "protoc_stage0",
8989
copts = COPTS,
90+
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
91+
--- a/src/google/protobuf/BUILD.bazel
92+
+++ b/src/google/protobuf/BUILD.bazel
93+
@@ -24,6 +24,25 @@ package(
94+
],
95+
)
96+
97+
+# Export Well Known Type proto files for use by genrules and other build rules.
98+
+# This is needed for bzlmod compatibility where file targets need to be explicitly exported.
99+
+exports_files(
100+
+ [
101+
+ "any.proto",
102+
+ "api.proto",
103+
+ "descriptor.proto",
104+
+ "duration.proto",
105+
+ "empty.proto",
106+
+ "field_mask.proto",
107+
+ "source_context.proto",
108+
+ "struct.proto",
109+
+ "timestamp.proto",
110+
+ "type.proto",
111+
+ "wrappers.proto",
112+
+ ],
113+
+ visibility = ["//visibility:public"],
114+
+)
115+
+
116+
proto_library(
117+
name = "any_proto",
118+
srcs = ["any.proto"],
119+
diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel
120+
--- a/src/google/protobuf/compiler/BUILD.bazel
121+
+++ b/src/google/protobuf/compiler/BUILD.bazel
122+
@@ -344,11 +344,7 @@ filegroup(
123+
124+
exports_files(
125+
srcs = ["plugin.proto"],
126+
- visibility = [
127+
- "//:__pkg__",
128+
- "//python:__pkg__",
129+
- "//ruby:__pkg__",
130+
- ],
131+
+ visibility = ["//visibility:public"],
132+
)
133+
134+
cc_library(

0 commit comments

Comments
 (0)