Skip to content

Files generated by build script into src/ are compiled twice #3076

@nipunn1313

Description

@nipunn1313

Repro steps:

  1. Create build.rs and make appropriate entry in Cargo.toml
  2. Have build.rs conditionally generate a file src/foo.rs (eg generate file if it doesn't exist, or generate file if mtime is older than its configuration)
  3. cargo build --verbose (should run build script, generate file, and build foo.rs)
  4. cargo build --verbose again. This time, I would expect it to be a noop, but it rebuilds foo.rs
  5. cargo build --verbose again. This time it's a noop as expected.

I am running into this issue because I am compiling a .proto file into a protobuf rs file during the build.rs phase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsA-rebuild-detectionArea: rebuild detection and fingerprintingC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-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