8000 Switching a build script from new style to old style does not fingerprint correctly. · Issue #6779 · rust-lang/cargo · GitHub
[go: up one dir, main page]

Skip to content
Switching a build script from new style to old style does not fingerprint correctly. #6779
@ehuss

Description

@ehuss

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

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsA-rebuild-detectionArea: rebuild detection and fingerprintingC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0