Skip to content

Commit

Permalink
Migrate a few command usages to BootstrapCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jun 22, 2024
1 parent 2d4d779 commit ab0756d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ macro_rules! clean_crate_tree {

// NOTE: doesn't use `run_cargo` because we don't want to save a stamp file,
// and doesn't use `stream_cargo` to avoid passing `--message-format` which `clean` doesn't accept.
builder.run(&mut cargo);
builder.run(cargo);
}
}
)+ }
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ impl Step for ErrorIndex {
index.arg(out);
index.arg(&builder.version);

builder.run(&mut index);
builder.run(index);
}
}

Expand Down
15 changes: 7 additions & 8 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl Miri {
// Tell it where to put the sysroot.
cargo.env("MIRI_SYSROOT", &miri_sysroot);

let mut cargo = Command::from(cargo);
let mut cargo = BootstrapCommand::from(cargo);
let _guard =
builder.msg(Kind::Build, compiler.stage, "miri sysroot", compiler.host, target);
builder.run(&mut cargo);
Expand Down Expand Up @@ -596,7 +596,7 @@ impl Step for Miri {
target,
);
let _time = helpers::timeit(builder);
builder.run(&mut cargo);
builder.run(cargo);
}
}
}
Expand Down Expand Up @@ -661,11 +661,11 @@ impl Step for CargoMiri {

// Finally, pass test-args and run everything.
cargo.arg("--").args(builder.config.test_args());
let mut cargo = Command::from(cargo);
let cargo = BootstrapCommand::from(cargo);
{
let _guard = builder.msg_sysroot_tool(Kind::Test, stage, "cargo-miri", host, target);
let _time = helpers::timeit(builder);
builder.run(&mut cargo);
builder.run(cargo);
}
}
}
Expand Down Expand Up @@ -845,7 +845,7 @@ impl Step for RustdocJSStd {
fn run(self, builder: &Builder<'_>) {
let nodejs =
builder.config.nodejs.as_ref().expect("need nodejs to run rustdoc-js-std tests");
let mut command = Command::new(nodejs);
let mut command = BootstrapCommand::new(nodejs);
command
.arg(builder.src.join("src/tools/rustdoc-js/tester.js"))
.arg("--crate-name")
Expand Down Expand Up @@ -879,7 +879,7 @@ impl Step for RustdocJSStd {
builder.config.build,
self.target,
);
builder.run(&mut command);
builder.run(command);
}
}

Expand Down Expand Up @@ -1306,8 +1306,7 @@ impl Step for RunMakeSupport {
&[],
);

let mut cargo = Command::from(cargo);
builder.run(&mut cargo);
builder.run(cargo);

let lib_name = "librun_make_support.rlib";
let lib = builder.tools_dir(self.compiler).join(lib_name);
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/core/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{
use build_helper::ci::CiEnv;
use xz2::bufread::XzDecoder;

use crate::utils::exec::BootstrapCommand;
use crate::utils::helpers::hex_encode;
use crate::utils::helpers::{check_run, exe, move_file, program_out_of_date};
use crate::{t, Config};
Expand Down Expand Up @@ -56,7 +57,7 @@ impl Config {
/// Runs a command, printing out nice contextual information if it fails.
/// Returns false if do not execute at all, otherwise returns its
/// `status.success()`.
pub(crate) fn check_run(&self, cmd: &mut Command) -> bool {
pub(crate) fn check_run(&self, cmd: &mut BootstrapCommand) -> bool {
if self.dry_run() {
return true;
}
Expand Down Expand Up @@ -216,7 +217,7 @@ impl Config {
fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error: &str) {
println!("downloading {url}");
// Try curl. If that fails and we are on windows, fallback to PowerShell.
let mut curl = Command::new("curl");
let mut curl = BootstrapCommand::new("curl");
curl.args([
"-y",
"30",
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/src/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
}
}

pub fn check_run(cmd: &mut Command, print_cmd_on_fail: bool) -> bool {
let status = match cmd.status() {
// FIXME: get rid of this function
pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool {
let status = match cmd.command.status() {
Ok(status) => status,
Err(e) => {
println!("failed to execute command: {cmd:?}\nERROR: {e}");
Expand Down
10 changes: 4 additions & 6 deletions src/bootstrap/src/utils/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
//! In uplifting, a tarball from Stage N captures essential components
//! to assemble Stage N + 1 compiler.
use std::{
path::{Path, PathBuf},
process::Command,
};
use std::path::{Path, PathBuf};

use crate::core::builder::Builder;
use crate::core::{build_steps::dist::distdir, builder::Kind};
use crate::utils::channel;
use crate::utils::exec::BootstrapCommand;
use crate::utils::helpers::{move_file, t};

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -300,7 +298,7 @@ impl<'a> Tarball<'a> {
}
}

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

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

0 comments on commit ab0756d

Please sign in to comment.