Skip to content

Commit ab0756d

Browse files
committed
Migrate a few command usages to BootstrapCommand
1 parent 2d4d779 commit ab0756d

File tree

6 files changed

+19
-20
lines changed

6 files changed

+19
-20
lines changed

src/bootstrap/src/core/build_steps/clean.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ macro_rules! clean_crate_tree {
8585

8686
// NOTE: doesn't use `run_cargo` because we don't want to save a stamp file,
8787
// and doesn't use `stream_cargo` to avoid passing `--message-format` which `clean` doesn't accept.
88-
builder.run(&mut cargo);
88+
builder.run(cargo);
8989
}
9090
}
9191
)+ }

src/bootstrap/src/core/build_steps/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ impl Step for ErrorIndex {
10861086
index.arg(out);
10871087
index.arg(&builder.version);
10881088

1089-
builder.run(&mut index);
1089+
builder.run(index);
10901090
}
10911091
}
10921092

src/bootstrap/src/core/build_steps/test.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl Miri {
465465
// Tell it where to put the sysroot.
466466
cargo.env("MIRI_SYSROOT", &miri_sysroot);
467467

468-
let mut cargo = Command::from(cargo);
468+
let mut cargo = BootstrapCommand::from(cargo);
469469
let _guard =
470470
builder.msg(Kind::Build, compiler.stage, "miri sysroot", compiler.host, target);
471471
builder.run(&mut cargo);
@@ -596,7 +596,7 @@ impl Step for Miri {
596596
target,
597597
);
598598
let _time = helpers::timeit(builder);
599-
builder.run(&mut cargo);
599+
builder.run(cargo);
600600
}
601601
}
602602
}
@@ -661,11 +661,11 @@ impl Step for CargoMiri {
661661

662662
// Finally, pass test-args and run everything.
663663
cargo.arg("--").args(builder.config.test_args());
664-
let mut cargo = Command::from(cargo);
664+
let cargo = BootstrapCommand::from(cargo);
665665
{
666666
let _guard = builder.msg_sysroot_tool(Kind::Test, stage, "cargo-miri", host, target);
667667
let _time = helpers::timeit(builder);
668-
builder.run(&mut cargo);
668+
builder.run(cargo);
669669
}
670670
}
671671
}
@@ -845,7 +845,7 @@ impl Step for RustdocJSStd {
845845
fn run(self, builder: &Builder<'_>) {
846846
let nodejs =
847847
builder.config.nodejs.as_ref().expect("need nodejs to run rustdoc-js-std tests");
848-
let mut command = Command::new(nodejs);
848+
let mut command = BootstrapCommand::new(nodejs);
849849
command
850850
.arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
851851
.arg("--crate-name")
@@ -879,7 +879,7 @@ impl Step for RustdocJSStd {
879879
builder.config.build,
880880
self.target,
881881
);
882-
builder.run(&mut command);
882+
builder.run(command);
883883
}
884884
}
885885

@@ -1306,8 +1306,7 @@ impl Step for RunMakeSupport {
13061306
&[],
13071307
);
13081308

1309-
let mut cargo = Command::from(cargo);
1310-
builder.run(&mut cargo);
1309+
builder.run(cargo);
13111310

13121311
let lib_name = "librun_make_support.rlib";
13131312
let lib = builder.tools_dir(self.compiler).join(lib_name);

src/bootstrap/src/core/download.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::{
1111
use build_helper::ci::CiEnv;
1212
use xz2::bufread::XzDecoder;
1313

14+
use crate::utils::exec::BootstrapCommand;
1415
use crate::utils::helpers::hex_encode;
1516
use crate::utils::helpers::{check_run, exe, move_file, program_out_of_date};
1617
use crate::{t, Config};
@@ -56,7 +57,7 @@ impl Config {
5657
/// Runs a command, printing out nice contextual information if it fails.
5758
/// Returns false if do not execute at all, otherwise returns its
5859
/// `status.success()`.
59-
pub(crate) fn check_run(&self, cmd: &mut Command) -> bool {
60+
pub(crate) fn check_run(&self, cmd: &mut BootstrapCommand) -> bool {
6061
if self.dry_run() {
6162
return true;
6263
}
@@ -216,7 +217,7 @@ impl Config {
216217
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
217218
println!("downloading {url}");
218219
// Try curl. If that fails and we are on windows, fallback to PowerShell.
219-
let mut curl = Command::new("curl");
220+
let mut curl = BootstrapCommand::new("curl");
220221
curl.args([
221222
"-y",
222223
"30",

src/bootstrap/src/utils/helpers.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
242242
}
243243
}
244244

245-
pub fn check_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
246-
let status = match cmd.status() {
245+
// FIXME: get rid of this function
246+
pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool {
247+
let status = match cmd.command.status() {
247248
Ok(status) => status,
248249
Err(e) => {
249250
println!("failed to execute command: {cmd:?}\nERROR: {e}");

src/bootstrap/src/utils/tarball.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
//! In uplifting, a tarball from Stage N captures essential components
66
//! to assemble Stage N + 1 compiler.
77
8-
use std::{
9-
path::{Path, PathBuf},
10-
process::Command,
11-
};
8+
use std::path::{Path, PathBuf};
129

1310
use crate::core::builder::Builder;
1411
use crate::core::{build_steps::dist::distdir, builder::Kind};
1512
use crate::utils::channel;
13+
use crate::utils::exec::BootstrapCommand;
1614
use crate::utils::helpers::{move_file, t};
1715

1816
#[derive(Copy, Clone)]
@@ -300,7 +298,7 @@ impl<'a> Tarball<'a> {
300298
}
301299
}
302300

303-
fn non_bare_args(&self, cmd: &mut Command) {
301+
fn non_bare_args(&self, cmd: &mut BootstrapCommand) {
304302
cmd.arg("--rel-manifest-dir=rustlib")
305303
.arg("--legacy-manifest-dirs=rustlib,cargo")
306304
.arg(format!("--product-name={}", self.product_name))
@@ -312,7 +310,7 @@ impl<'a> Tarball<'a> {
312310
.arg(distdir(self.builder));
313311
}
314312

315-
fn run(self, build_cli: impl FnOnce(&Tarball<'a>, &mut Command)) -> GeneratedTarball {
313+
fn run(self, build_cli: impl FnOnce(&Tarball<'a>, &mut BootstrapCommand)) -> GeneratedTarball {
316314
t!(std::fs::create_dir_all(&self.overlay_dir));
317315
self.builder.create(&self.overlay_dir.join("version"), &self.overlay.version(self.builder));
318316
if let Some(info) = self.builder.rust_info().info() {

0 commit comments

Comments
 (0)