Skip to content

Output build plan after running custom build scripts #7068

@schomatis

Description

@schomatis

Command-build A-build-plan C-feature-request

I would like to implement an extension to the --build-plan option to generate a build plan only after running all the custom build scripts. I'm opening this issue to get some feedback from the Cargo team and to check if this would be an acceptable change.

This would extend --build-plan in a backwards-compatible way so its default behavior would still be the current implementation of generating the build plan before compiling/running anything. The extended option could look something like:

    --build-plan [=STAGE]   Output the build plan in JSON (unstable) at a STAGE in the build
                            process: `init`, before compiling/running anything (default) or
                            `post-build-scripts`, after *all* the build scripts have been run
                            (and their dependencies compiled).

These are just some arbitrary names for the --help example, I would actually need some help coming up with more suitable terms that reflect the different stages in the build process.

The motivation is to get a snapshot that is more accurate in terms of the modifications the custom build scripts can have over the general build process (at the cost of consuming those away from the build plan) to focus more on the intermediate artifacts that actually get linked into the final binary/library rather than on the "auxiliary" ones used only for the purposes of the custom build scripts, that won't be reflected in the final build other than for its intended side effects.

I've already been experimenting with a possible implementation and the biggest change in the current architecture would be a closer link between the Units being compiled and the target they're intended for (UnitFor.build), to keep track of which Units do we need to compile and which just generate the Invocation for (I can expand on this in a PR with actual code). In terms of the Units that represent custom build scripts (and their execution), since the proposed option targets executing them all there is no extra tracking mechanism needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-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.Z-build-planNightly: --build-plan feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions