Skip to content

Commit da6fcbf

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 4496f0f commit da6fcbf

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
@@ -102,3 +102,48 @@ index e9ced612f..9454a47bd 100755
102102
+ __import__('pkg_resources').declare_namespace(__name__)
103103
+ except ImportError:
104104
+ __path__ = __import__('pkgutil').extend_path(__path__, __name__)
105+
diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel
106+
--- a/src/google/protobuf/BUILD.bazel
107+
+++ b/src/google/protobuf/BUILD.bazel
108+
@@ -24,6 +24,25 @@ package(
109+
],
110+
)
111+
112+
+# Export Well Known Type proto files for use by genrules and other build rules.
113+
+# This is needed for bzlmod compatibility where file targets need to be explicitly exported.
114+
+exports_files(
115+
+ [
116+
+ "any.proto",
117+
+ "api.proto",
118+
+ "descriptor.proto",
119+
+ "duration.proto",
120+
+ "empty.proto",
121+
+ "field_mask.proto",
122+
+ "source_context.proto",
123+
+ "struct.proto",
124+
+ "timestamp.proto",
125+
+ "type.proto",
126+
+ "wrappers.proto",
127+
+ ],
128+
+ visibility = ["//visibility:public"],
129+
+)
130+
+
131+
proto_library(
132+
name = "any_proto",
133+
srcs = ["any.proto"],
134+
diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel
135+
--- a/src/google/protobuf/compiler/BUILD.bazel
136+
+++ b/src/google/protobuf/compiler/BUILD.bazel
137+
@@ -344,11 +344,7 @@ filegroup(
138+
139+
exports_files(
140+
srcs = ["plugin.proto"],
141+
- visibility = [
142+
- "//:__pkg__",
143+
- "//python:__pkg__",
144+
- "//ruby:__pkg__",
145+
- ],
146+
+ visibility = ["//visibility:public"],
147+
)
148+
149+
cc_library(

0 commit comments

Comments
 (0)