Skip to content

Command to run only build scripts #7178

Open
@matklad

Description

@matklad

Hi!

This is a pre-RFC style issue just to write down some long-term thoughts.

The IDE support for rust progressed enough that build scripts need some special support. Specifically, for IDEs it would be useful if Cargo can just run the build scripts and compile proc-macros, without building any code. That is, do all the stuff for $host, and skip everything $target related. With this, IDE can provide full support for generated code and procedural macros, without requiring that the code itself builds (if it can also discover results of build-scripts, like the OUT_DIR).

In the ideal world, I think this should work like this:

cargo build --compile-time-deps # only stuff for $host is run
cargo run # guaranteed  to *not* build anything for $host 
cargo test # guaranteed  to *not* build anything for $host as well

I think we unfortunately can't do that now, as there's little separation between "stages" of dependencies, and, for example cargo run and cargo test might run build scripts slightly differently. This also seems to touch "build profile" and "build-deps features influcence the final artifact" problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-checkS-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions