From c8bcaa89f10e666d3193a3d96cf95f96e2217fdd Mon Sep 17 00:00:00 2001 From: Luke Francl Date: Tue, 23 Jan 2024 14:02:13 -0800 Subject: [PATCH] Add cargo:rerun-if-changed to README Generally you would want to `cargo:rerun-if-changed` on all your protos to avoid unnecessary re-runs of the build.rs script. I added it to the example. --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 185a0c7..43cdd2d 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,16 @@ Add a `build.rs` file to your project to compile the protos and generate Rust co ```rust fn main() { + let proto_source_files = ["./service.proto"]; + + // Tell Cargo to rerun this build script if any of the proto files change + for entry in &proto_source_files { + println!("cargo:rerun-if-changed={}", entry); + } + prost_build::Config::new() .service_generator(twirp_build::service_generator()) - .compile_protos(&["./service.proto"], &["./"]) + .compile_protos(&proto_source_files, &["./"]) .expect("error compiling protos"); } ```