-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
A-build-scriptsArea: build.rs scriptsArea: build.rs scriptsA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.
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();
}
Metadata
Metadata
Assignees
Labels
A-build-scriptsArea: build.rs scriptsArea: build.rs scriptsA-rebuild-detectionArea: rebuild detection and fingerprintingArea: rebuild detection and fingerprintingC-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.