Skip to content

feat(toml): Parse support for multiple build scripts #15630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 23, 2025

Conversation

namanlp
Copy link
Contributor

@namanlp namanlp commented Jun 4, 2025

Hi Everyone!

This is PR for the manifest parsing of the first milestone of GSoC Project : Build Script Delegation

What does this PR try to resolve?

Currently, just a single build script is allowed for each package. This PR will allow users to create and use multiple build scripts, and is backward compatible with single script as well as boolean values.

Motivation : This will help users to maintain separate smaller and cleaner build scripts instead of one large build script. This is also necessary for build script delegation.

Open questions:

  • What should the build script target names be?
    • Currently they use the file stem of the build script which could run into conflicts

Known Issues:

  • This is just parsing support, and currently, only the first build script of the array is actually executed.

How to test and review this PR?

There is a feature gate multiple-build-scripts that can be passed via cargo-features in Cargo.toml. So, you have to add

cargo-features = ["multiple-build-scripts"]

Preferably on the top of the Cargo.toml and use nightly toolchain to use the feature

This PR is ready to be reviewed and merged

@rustbot rustbot added the A-unstable Area: nightly unstable support label Jun 4, 2025
@epage
Copy link
Contributor

epage commented Jun 4, 2025

Feel free to rebase on master, rather than merge it.

@rustbot rustbot added A-manifest Area: Cargo.toml issues Command-vendor labels Jun 5, 2025
@namanlp namanlp closed this Jun 6, 2025
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch from 60fe887 to f6bebc3 Compare June 6, 2025 21:16
@namanlp namanlp reopened this Jun 6, 2025
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch 2 times, most recently from b7a6036 to 1d18b6b Compare June 8, 2025 22:09
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch from 0321144 to 6de78d5 Compare June 10, 2025 22:39
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Jun 10, 2025
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch 3 times, most recently from 21dbd79 to 902bd62 Compare June 11, 2025 23:22
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch from 902bd62 to 98a9565 Compare June 12, 2025 19:29
Comment on lines 108 to 114
if custom_build.len() > 1 {
anyhow::bail!("multiple build scripts feature is not implemented yet! ")
}
let custom_build = Path::new(&custom_build[0]);
let name = format!(
"build-script-{}",
custom_build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We'll need to loop over
  2. Do we need to make build script names more unique?

@namanlp namanlp force-pushed the multiple-build-scripts-1 branch from d419489 to ce0aacd Compare June 13, 2025 20:47
@epage epage changed the title [WIP] feat: Multiple build scripts feat(toml): Parse support for multiple build scripts Jun 19, 2025
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch from 99a459d to c01a8bd Compare June 19, 2025 21:58
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch 2 times, most recently from a123df8 to 74b5190 Compare June 22, 2025 20:55
@namanlp namanlp force-pushed the multiple-build-scripts-1 branch from 74b5190 to 5c7f68f Compare June 23, 2025 13:45
@epage
Copy link
Contributor

epage commented Jun 23, 2025

Thanks!

@epage epage added this pull request to the merge queue Jun 23, 2025
Merged via the queue into rust-lang:master with commit f94409a Jun 23, 2025
24 checks passed
@namanlp namanlp deleted the multiple-build-scripts-1 branch June 23, 2025 15:02
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 25, 2025
Update cargo

2 commits in 84709f085062cbf3c51fa507527c1b2334015178..409fed7dc1553d49cb9a8c0637d12d65571346ce
2025-06-22 23:58:39 +0000 to 2025-06-23 15:55:04 +0000
- Fix potential deadlock in `CacheState::lock` (rust-lang/cargo#15698)
- feat(toml): Parse support for multiple build scripts (rust-lang/cargo#15630)
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 25, 2025
Update cargo

2 commits in 84709f085062cbf3c51fa507527c1b2334015178..409fed7dc1553d49cb9a8c0637d12d65571346ce
2025-06-22 23:58:39 +0000 to 2025-06-23 15:55:04 +0000
- Fix potential deadlock in `CacheState::lock` (rust-lang/cargo#15698)
- feat(toml): Parse support for multiple build scripts (rust-lang/cargo#15630)
rust-timer added a commit to rust-lang/rust that referenced this pull request Jun 25, 2025
Rollup merge of #142993 - ehuss:update-cargo, r=ehuss

Update cargo

2 commits in 84709f085062cbf3c51fa507527c1b2334015178..409fed7dc1553d49cb9a8c0637d12d65571346ce
2025-06-22 23:58:39 +0000 to 2025-06-23 15:55:04 +0000
- Fix potential deadlock in `CacheState::lock` (rust-lang/cargo#15698)
- feat(toml): Parse support for multiple build scripts (rust-lang/cargo#15630)
@rustbot rustbot added this to the 1.90.0 milestone Jun 25, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 9, 2025
Hi Everyone!

This is PR for the implementation of the first milestone of [GSoC
Project : Build Script
Delegation](https://summerofcode.withgoogle.com/programs/2025/projects/nUt4PdAA)

This will provide actual implementation for #15630

### What does this PR try to resolve?

Now, multiple build scripts are parsed, this PR aims to implement the
functioning the feature. This PR will allow users to use multiple build
scripts, and is backward compatible with single script as well as
boolean values.

**Motivation :** This will help users to maintain separate smaller and
cleaner build scripts instead of one large build script. This is also
necessary for build script delegation.

Deferred
- Accessing each build script's `OUT_DIR`: This will be handled in a
follow up PR. For now, each build script writes to its own `OUT_DIR` and
`OUT_DIR` for the regular build targets is set to the build script with
the **lexicographically largest** name..
- User control over which build script wins in a conflict. This will be
handled in a follow up PR. If two build scripts write to the same env
variable, which gets applied to the binary? Currently, its the build
script with the **lexicographically largest** name. This makes it
deterministic. With some futzing, users can control this for now.
However, with build script delegation, users won't be able to control
this. We likely want it based off of the order the user assigns into the
build script array.
- Something about linking a C library is actually preferring
**lexicographically smallest** name. We should handle conflicts
consistently. We need to dig into what parts are doing it based on
smallest and make sure that whatever priority scheme we use for env
variables applies here as well.

### How to test and review this PR?

There is a feature gate `multiple-build-scripts` that can be passed via
`cargo-features` in `Cargo.toml`. So, you have to add
```toml
cargo-features = ["multiple-build-scripts"]
```
Preferably on the top of the `Cargo.toml` and use nightly toolchain to
use the feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support Command-vendor S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants