Switching a build script from new style to old style does not fingerprint correctly.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
If a build script switches from new-style (with rerun-if statements) to old-style (no rerun-if statements), then the fingerprint does not get updated correctly. This means that running cargo build a second time will re-run the script when it should be fresh.
Fixing this is somewhat difficult. The closure in prepare_build_cmd would need to recompute the old-style FingerprintLocal values, but those require access to a Context which is not available.
Below is a demonstration.
#[test]
fn build_script_to_old_style_rebuild() {
// Changing from new-style to old-style should track freshness properly.
let p = project()
.file("src/lib.rs", "")
.file("build.rs",
r#"
fn main() {
println!("cargo:rerun-if-changed=build.rs");
}
"#)
.build();
p.cargo("build").run();
p.cargo("build -v").with_stderr("\
[FRESH] foo [..]
[FINISHED] [..]
").run();
p.change_file("build.rs", "fn main() {}");
p.cargo("build -v").with_stderr("\
[COMPILING] foo [..]
[RUNNING] [..]build.rs[..]
[RUNNING] [..]build-script-build[..]
[RUNNING] [..]lib.rs[..]
[FINISHED] [..]
").run();
// This line is currently bugged and doesn't appear fresh.
p.cargo("build -v").with_stderr("\
[FRESH] foo [..]
[FINISHED] [..]
").run();
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the build_script_to_old_style_rebuild test and reproduce the transition from a build script with rerun-if statements to one without them. Read prepare_build_cmd, FingerprintLocal, and the Context requirement described in the issue. Done means the final cargo build reports [FRESH] rather than rerunning the script and dependent targets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100