Skip to content

Commit 2a9d5ab

Browse files
committed
Make it easier to migrate Command to BootstrapCmd
By allowing `run` to receive all of `BootstrapCmd`, `&mut BootstrapCmd`, `Command` and `&mut Command`.
1 parent 3722fb5 commit 2a9d5ab

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ fn doc_std(
737737
format!("library{} in {} format", crate_description(requested_crates), format.as_str());
738738
let _guard = builder.msg_doc(compiler, description, target);
739739

740-
builder.run(&mut cargo.into());
740+
builder.run(cargo);
741741
builder.cp_link_r(&out_dir, out);
742742
}
743743

@@ -862,7 +862,7 @@ impl Step for Rustc {
862862
let proc_macro_out_dir = builder.stage_out(compiler, Mode::Rustc).join("doc");
863863
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
864864

865-
builder.run(&mut cargo.into());
865+
builder.run(cargo);
866866

867867
if !builder.config.dry_run() {
868868
// Sanity check on linked compiler crates
@@ -995,7 +995,7 @@ macro_rules! tool_doc {
995995
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
996996

997997
let _guard = builder.msg_doc(compiler, stringify!($tool).to_lowercase(), target);
998-
builder.run(&mut cargo.into());
998+
builder.run(cargo);
999999

10001000
if !builder.config.dry_run() {
10011001
// Sanity check on linked doc directories

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3064,7 +3064,7 @@ impl Step for TierCheck {
30643064
self.compiler.host,
30653065
self.compiler.host,
30663066
);
3067-
builder.run(BootstrapCommand::from(&mut cargo.into()).delay_failure());
3067+
builder.run(BootstrapCommand::from(cargo).delay_failure());
30683068
}
30693069
}
30703070

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ impl Step for Rustdoc {
602602
&self.compiler.host,
603603
&target,
604604
);
605-
builder.run(&mut cargo.into());
605+
builder.run(cargo);
606606

607607
// Cargo adds a number of paths to the dylib search path on windows, which results in
608608
// the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
@@ -857,7 +857,7 @@ impl Step for LlvmBitcodeLinker {
857857
&self.extra_features,
858858
);
859859

860-
builder.run(&mut cargo.into());
860+
builder.run(cargo);
861861

862862
let tool_out = builder
863863
.cargo_out(self.compiler, Mode::ToolRustc, self.target)

src/bootstrap/src/core/builder.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::EXTRA_CHECK_CFGS;
2525
use crate::{Build, CLang, Crate, DocTests, GitRepo, Mode};
2626

2727
pub use crate::Compiler;
28+
use crate::utils::exec::BootstrapCommand;
2829

2930
use clap::ValueEnum;
3031
// FIXME: replace with std::lazy after it gets stabilized and reaches beta
@@ -2622,3 +2623,9 @@ impl From<Cargo> for Command {
26222623
cargo.command
26232624
}
26242625
}
2626+
2627+
impl From<Cargo> for BootstrapCommand {
2628+
fn from(cargo: Cargo) -> BootstrapCommand {
2629+
Command::from(cargo).into()
2630+
}
2631+
}

src/bootstrap/src/utils/exec.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::ffi::OsStr;
2+
use std::path::Path;
13
use std::process::{Command, ExitStatus, Output};
24

35
/// What should be done when the command fails.
@@ -91,6 +93,14 @@ impl<'a> From<&'a mut Command> for BootstrapCommand {
9193
}
9294
}
9395

96+
/// This implementation is temporary, until all `Command` invocations are migrated to
97+
/// `BootstrapCommand`.
98+
impl<'a> From<&'a mut BootstrapCommand> for BootstrapCommand {
99+
fn from(command: &'a mut BootstrapCommand) -> Self {
100+
BootstrapCommand::from(&mut command.command)
101+
}
102+
}
103+
94104
impl From<Command> for BootstrapCommand {
95105
fn from(command: Command) -> Self {
96106
Self { command, failure_behavior: BehaviorOnFailure::Exit, output_mode: None }

0 commit comments

Comments
 (0)