Skip to content

Commit 91910fc

Browse files
committed
Migrate cargo_clippy_cmd and cargo_miri_cmd to BootstrapCommand
1 parent a7dfed9 commit 91910fc

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ pub fn stream_cargo(
20712071
tail_args: Vec<String>,
20722072
cb: &mut dyn FnMut(CargoMessage<'_>),
20732073
) -> bool {
2074-
let mut cargo = Command::from(cargo);
2074+
let mut cargo = BootstrapCommand::from(cargo).command;
20752075
// Instruct Cargo to give us json messages on stdout, critically leaving
20762076
// stderr as piped so we can get those pretty colors.
20772077
let mut message_format = if builder.config.json_output {

src/bootstrap/src/core/build_steps/run.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ impl Step for Miri {
158158
// after another --, so this must be at the end.
159159
miri.args(builder.config.args());
160160

161-
let mut miri = Command::from(miri);
162-
builder.run(&mut miri);
161+
builder.run(miri);
163162
}
164163
}
165164

src/bootstrap/src/core/builder.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -1231,11 +1231,11 @@ impl<'a> Builder<'a> {
12311231
self.ensure(tool::Rustdoc { compiler })
12321232
}
12331233

1234-
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> Command {
1234+
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
12351235
if run_compiler.stage == 0 {
12361236
// `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy.
12371237
let cargo_clippy = self.build.config.download_clippy();
1238-
let mut cmd = Command::new(cargo_clippy);
1238+
let mut cmd = BootstrapCommand::new(cargo_clippy);
12391239
cmd.env("CARGO", &self.initial_cargo);
12401240
return cmd;
12411241
}
@@ -1254,13 +1254,13 @@ impl<'a> Builder<'a> {
12541254
let mut dylib_path = helpers::dylib_path();
12551255
dylib_path.insert(0, self.sysroot(run_compiler).join("lib"));
12561256

1257-
let mut cmd = Command::new(cargo_clippy);
1257+
let mut cmd = BootstrapCommand::new(cargo_clippy);
12581258
cmd.env(helpers::dylib_path_var(), env::join_paths(&dylib_path).unwrap());
12591259
cmd.env("CARGO", &self.initial_cargo);
12601260
cmd
12611261
}
12621262

1263-
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> Command {
1263+
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
12641264
assert!(run_compiler.stage > 0, "miri can not be invoked at stage 0");
12651265
let build_compiler = self.compiler(run_compiler.stage - 1, self.build.build);
12661266

@@ -1276,7 +1276,7 @@ impl<'a> Builder<'a> {
12761276
extra_features: Vec::new(),
12771277
});
12781278
// Invoke cargo-miri, make sure it can find miri and cargo.
1279-
let mut cmd = Command::new(cargo_miri);
1279+
let mut cmd = BootstrapCommand::new(cargo_miri);
12801280
cmd.env("MIRI", &miri);
12811281
cmd.env("CARGO", &self.initial_cargo);
12821282
// Need to add the `run_compiler` libs. Those are the libs produces *by* `build_compiler`,
@@ -1333,7 +1333,7 @@ impl<'a> Builder<'a> {
13331333
mode: Mode,
13341334
target: TargetSelection,
13351335
cmd: &str, // FIXME make this properly typed
1336-
) -> Command {
1336+
) -> BootstrapCommand {
13371337
let mut cargo;
13381338
if cmd == "clippy" {
13391339
cargo = self.cargo_clippy_cmd(compiler);
@@ -1346,7 +1346,7 @@ impl<'a> Builder<'a> {
13461346
cargo = self.cargo_miri_cmd(compiler);
13471347
cargo.arg("miri").arg(subcmd);
13481348
} else {
1349-
cargo = Command::new(&self.initial_cargo);
1349+
cargo = BootstrapCommand::new(&self.initial_cargo);
13501350
cargo.arg(cmd);
13511351
}
13521352

@@ -2376,7 +2376,7 @@ impl HostFlags {
23762376

23772377
#[derive(Debug)]
23782378
pub struct Cargo {
2379-
command: Command,
2379+
command: BootstrapCommand,
23802380
compiler: Compiler,
23812381
target: TargetSelection,
23822382
rustflags: Rustflags,
@@ -2601,8 +2601,8 @@ impl Cargo {
26012601
}
26022602
}
26032603

2604-
impl From<Cargo> for Command {
2605-
fn from(mut cargo: Cargo) -> Command {
2604+
impl From<Cargo> for BootstrapCommand {
2605+
fn from(mut cargo: Cargo) -> BootstrapCommand {
26062606
let rustflags = &cargo.rustflags.0;
26072607
if !rustflags.is_empty() {
26082608
cargo.command.env("RUSTFLAGS", rustflags);
@@ -2621,13 +2621,12 @@ impl From<Cargo> for Command {
26212621
if !cargo.allow_features.is_empty() {
26222622
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
26232623
}
2624-
26252624
cargo.command
26262625
}
26272626
}
26282627

2629-
impl From<Cargo> for BootstrapCommand {
2630-
fn from(cargo: Cargo) -> BootstrapCommand {
2631-
Command::from(cargo).into()
2628+
impl From<Cargo> for Command {
2629+
fn from(cargo: Cargo) -> Command {
2630+
BootstrapCommand::from(cargo).command
26322631
}
26332632
}

0 commit comments

Comments
 (0)