cargo

Rust Build script change tracking

Declare the file used by the build script so Cargo can decide when to rerun it. This line belongs inside build.rs main. Example format: rust. Run in a disposable copy of v16/fixtures/projects/build-demo. Expected result (not executed): After changing label.txt, the next build regenerates the constant. Common mistake: Tracking only the generated file rather than the input file.

Formal Syntax & Structure

rust syntaxrust
println!("cargo::rerun-if-changed=label.txt");

Working Example

Example Snippetrust
println!("cargo::rerun-if-changed=label.txt");
Rust Reference