grpc / grpc/grpc-rust

tonic_prost_build: `emit_rerun_if_changed` no longer does anything

Open
#2,511 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Bug Report

The `Builder::emit_rerun_if_changed` method in `tonic-prost-build` does nothing. The field is stored but never used, and the documented behavior ("Passed directly to prost_build::Config.emit_rerun_if_changed") is incorrect because `prost_build::Config` has no such method.

### Version

0.14.4

### Platform
All

### Crates

tonic_prost_build

### Description

The `emit_rerun_if_changed` field is defined in the `Builder` struct (lib.rs:405):

```rust
emit_rerun_if_changed: bool,
```

It has a setter method (lib.rs:639-642):

```rust
/// Passed directly to `prost_build::Config.emit_rerun_if_changed`.
pub fn emit_rerun_if_changed(mut self, enable: bool) -> Self {
self.emit_rerun_if_changed = enable;
self
}
```

However, searching `compile_with_config` (the method that actually uses the Builder fields to configure prost), the `emit_rerun_if_changed` field is **never read or used**. Every other field is passed to the prost_build::Config, but this one is simply ignored.

Furthermore, `prost_build::Config` does not have an `emit_rerun_if_changed` method. The prost-build source contains only a TODO comment about potentially adding this functionality (prost-build config.rs:1037-1041):

```rust
// TODO: This should probably emit 'rerun-if-changed=PATH' directives for cargo, however
// according to [1] if any are output then those paths replace the default crate root,
// which is undesirable. Figure out how to do it in an additive way; perhaps gcc-rs has
// this figured out.
// [1]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.