Skip to content

fix: Don't emit --keep-going for custom build script commands #17232

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 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions crates/project-model/src/build_scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ impl WorkspaceBuildScripts {
config: &CargoConfig,
allowed_features: &FxHashSet<String>,
manifest_path: &ManifestPath,
toolchain: Option<&Version>,
sysroot: Option<&Sysroot>,
) -> io::Result<Command> {
const RUST_1_75: Version = Version::new(1, 75, 0);
let mut cmd = match config.run_build_script_command.as_deref() {
Some([program, args @ ..]) => {
let mut cmd = Command::new(program);
Expand Down Expand Up @@ -120,6 +122,10 @@ impl WorkspaceBuildScripts {
cmd.arg("-Zscript");
}

if toolchain.map_or(false, |it| *it >= RUST_1_75) {
cmd.arg("--keep-going");
}

cmd
}
};
Expand All @@ -142,11 +148,9 @@ impl WorkspaceBuildScripts {
config: &CargoConfig,
workspace: &CargoWorkspace,
progress: &dyn Fn(String),
toolchain: &Option<Version>,
toolchain: Option<&Version>,
sysroot: Option<&Sysroot>,
) -> io::Result<WorkspaceBuildScripts> {
const RUST_1_75: Version = Version::new(1, 75, 0);

let current_dir = match &config.invocation_location {
InvocationLocation::Root(root) if config.run_build_script_command.is_some() => {
root.as_path()
Expand All @@ -156,11 +160,13 @@ impl WorkspaceBuildScripts {
.as_ref();

let allowed_features = workspace.workspace_features();
let mut cmd =
Self::build_command(config, &allowed_features, workspace.manifest_path(), sysroot)?;
if toolchain.as_ref().map_or(false, |it| *it >= RUST_1_75) {
cmd.args(["--keep-going"]);
}
let cmd = Self::build_command(
config,
&allowed_features,
workspace.manifest_path(),
toolchain,
sysroot,
)?;
Self::run_per_ws(cmd, workspace, current_dir, progress)
}

Expand Down Expand Up @@ -189,6 +195,7 @@ impl WorkspaceBuildScripts {
// This is not gonna be used anyways, so just construct a dummy here
&ManifestPath::try_from(workspace_root.clone()).unwrap(),
None,
None,
)?;
// NB: Cargo.toml could have been modified between `cargo metadata` and
// `cargo check`. We shouldn't assume that package ids we see here are
Expand Down
2 changes: 1 addition & 1 deletion crates/project-model/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl ProjectWorkspace {
config,
cargo,
progress,
&self.toolchain,
self.toolchain.as_ref(),
self.sysroot.as_ref().ok(),
)
.with_context(|| {
Expand Down