Originally posted by **mickvangelderen** June 17, 2022
I find myself writing a build script similar to the following for every project:
```rust
fn main() {
let protos = ["proto/rocsys/canonical.proto"];
let includes = ["proto"];
tonic_build::configure()
.server_mod_attribute("rocsys.canonical", "#[cfg(feature = \"server\")]")
.client_mod_attribute("rocsys.canonical", "#[cfg(feature = \"client\")]")
.compile(&protos, &includes)
.unwrap();
for path in protos.iter().copied().chain(includes.iter().copied()) {
println!("cargo:rerun-if-changed={}", path)
}
}
```
I was wondering if we could let tonic emit those rerun-if-changed statements for us. It would be even better if we could narrow down the rerun-if-changed instructions only to the included files rather than asking cargo to monitor the entire include directories.
It is possible that this feature already exists but I couldn't find any signs of tonic_build writing to `stdout` nor does my build script print anything to `stdout` when removing my own `println` statements.
Is this indeed a missing feature? If so, should it maybe be added to tonic_build (perhaps under a configuration flag since not everyone using tonic_build may be using cargo).
Discussed in https://github.com/hyperium/tonic/discussions/1019
Is this indeed a missing feature? If so, should it maybe be added to
tonic_build
(perhaps under a configuration flag since not everyone usingtonic_build
may be usingcargo
).