You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(rust): service-only libs, plugin order, output_mappings for path-mismatched pkgs
Three independent failures surfaced by running protoc-gen-prost,
protoc-gen-prost-serde, and protoc-gen-tonic together across a real
monorepo:
1. Service-only proto_libraries (no messages/enums) caused tonic to
error with "Tried to insert into file that doesn't exist": tonic
appends client/server code into prost's {package}.rs at the
@@protoc_insertion_point(module) marker, but ProtocGenProstPlugin
skipped libraries with no messages or enums. shouldApply and
outputs now also fire on HasServices() so prost emits a stub .rs
for tonic to insert into. Two new tests in protoc-gen-prost_test.
2. Plugin order was non-deterministic: BUILD.bazel attr ordering
(preserved by bazel-gazelle's standard list-merge) put tonic
before prost, so tonic's insertion ran before prost created its
target file — yielding the "Tried to insert into file that
doesn't exist" / "Tried to write the same file twice" pair.
proto_compile.bzl now sorts plugins by name inside the rule impl,
so protoc CLI ordering is independent of attr ordering.
3. proto packages whose path doesn't match the bazel package dir
(e.g. "trumid.common.auth" living at //trumid/common/auth/proto,
or "grpc.health.v1" living at //thirdparty/.../grpc/health/v1)
failed with `mv: ... No such file or directory` because prost
writes to its proto-package-derived path while proto_compile.bzl
expected the output at the bazel pkg. The output_mappings
computation in proto_rust_library.ProvideRule only handled the
Rust-keyword-escape case (e.g. google.type → google/r#type).
Generalized: emit mappings whenever RustProtocOutputDir(pkg)
differs from pc.Rel, regardless of whether keywords are involved.
Extracted RustProtocOutputDir helper; existing
RustKeywordEscapeMappings retained for back-compat with the
exposed Starlark function.
0 commit comments