Skip to content

Commit 3beb59f

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 c382434 commit 3beb59f

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
@@ -993,7 +993,7 @@ macro_rules! tool_doc {
993993
symlink_dir_force(&builder.config, &out, &proc_macro_out_dir);
994994

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

998998
if !builder.config.dry_run() {
999999
// 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
@@ -3063,7 +3063,7 @@ impl Step for TierCheck {
30633063
self.compiler.host,
30643064
self.compiler.host,
30653065
);
3066-
builder.run(BootstrapCommand::from(&mut cargo.into()).delay_failure());
3066+
builder.run(BootstrapCommand::from(cargo).delay_failure());
30673067
}
30683068
}
30693069

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ impl Step for Rustdoc {
532532
&self.compiler.host,
533533
&target,
534534
);
535-
builder.run(&mut cargo.into());
535+
builder.run(cargo);
536536

537537
// Cargo adds a number of paths to the dylib search path on windows, which results in
538538
// the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
@@ -781,7 +781,7 @@ impl Step for LlvmBitcodeLinker {
781781
&self.extra_features,
782782
);
783783

784-
builder.run(&mut cargo.into());
784+
builder.run(cargo);
785785

786786
let tool_out = builder
787787
.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
@@ -27,6 +27,7 @@ use crate::EXTRA_CHECK_CFGS;
2727
use crate::{Build, CLang, Crate, DocTests, GitRepo, Mode};
2828

2929
pub use crate::Compiler;
30+
use crate::utils::exec::BootstrapCommand;
3031

3132
use clap::ValueEnum;
3233
// FIXME: replace with std::lazy after it gets stabilized and reaches beta
@@ -2624,3 +2625,9 @@ impl From<Cargo> for Command {
26242625
cargo.command
26252626
}
26262627
}
2628+
2629+
impl From<Cargo> for BootstrapCommand {
2630+
fn from(cargo: Cargo) -> BootstrapCommand {
2631+
Command::from(cargo).into()
2632+
}
2633+
}

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)