bazelbuild / bazelbuild/rules_rust
Is it possible to keep the intermediate `.rs` file used during `rust_prost_library`?
- Dominant language
- Starlark
- Stars
- 843
- Forks
- 651
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 15
Description
`rust_prost_library`'s `ProstGenProto` action will - it seems - create an ephemeral `*.lib.rs` file before building the resulting `*.rlib` file.
Note the `--out_librs=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.lib.rs` arg in the protoc_wrapper command:
```
$ bazel build --subcommands //rust/proto:connect_rust_proto
...
SUBCOMMAND: # //rust/proto:connect_proto [action 'ProstGenProto //rust/proto:connect_proto', configuration: ce57de3d3d3898ef19a604dc9e90220b91db82beb22d97846032d915a639010f, execution platform: //tools/bazel/rbe/config/config:platform, mnemonic: ProstGenProto]
(cd /usr/local/google/home/dthor/.cache/bazel/_bazel_dthor/0f8c52850e7230283fc2f8033149fba2/execroot/_main && \
exec env - \
BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 \
PATH=/bin:/usr/bin:/usr/local/bin \
bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/rules_rust_prost+/private/protoc_wrapper '--prost_out=bazel-out/k8-fastbuild/bin' '--plugin=protoc-gen-prost=bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/rules_rust++crate+crates__protoc-gen-prost-0.4.0/protoc-gen-prost__bin' -I. rust/proto/connect.proto '--protoc=bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/protobuf+/protoc' '--label=//rust/proto:connect_proto' '--out_librs=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.lib.rs' '--package_info_output=connect_proto=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.prost_package_info' '--deps_info=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto.prost_deps_info' '--descriptor_set=bazel-out/k8-fastbuild/bin/rust/proto/connect_proto-descriptor-set.proto.bin' '--prost_opt=enable_type_names' '--plugin=protoc-gen-tonic=bazel-out/k8-opt-exec-ST-7ac76b60419a/bin/external/rules_rust++crate+crates__protoc-gen-tonic-0.4.1/protoc-gen-tonic__bin' '--tonic_opt=no_include' --is_tonic '--rustfmt=external/rules_rust++rust+rustfmt_nightly-2025-04-03__x86_64-unknown-linux-gnu_tools/bin/rustfmt')
# Configuration: ce57de3d3d3898ef19a604dc9e90220b91db82beb22d97846032d915a639010f
# Execution platform: //tools/bazel/rbe/config/config:platform
# Runner: remote
```
https://github.com/bazelbuild/rules_rust/blob/76abd40167aa8a1a9ef399783c4c610b9c6331a6/extensions/prost/private/prost.bzl#L66
https://github.com/bazelbuild/rules_rust/blob/76abd40167aa8a1a9ef399783c4c610b9c6331a6/extensions/prost/private/prost.bzl#L316-L323
**Is it possible to keep that `*.lib.rs` file around?** Even just in the sandbox or outdir or cache or something. Having it accessible can help debug issues with protos.
Contributor guide
Assessment
This issue has not been assessed yet.