Skip to content

Commit 8a890cb

Browse files
committed
Migrate a few command usages to BootstrapCommand
1 parent f7d9543 commit 8a890cb

File tree

9 files changed

+31
-30
lines changed

9 files changed

+31
-30
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ impl Step for UnstableBookGen {
11161116
cmd.arg(builder.src.join("src"));
11171117
cmd.arg(out);
11181118

1119-
builder.run(&mut cmd);
1119+
builder.run(cmd);
11201120
}
11211121
}
11221122

@@ -1211,7 +1211,7 @@ impl Step for RustcBook {
12111211
self.compiler.host,
12121212
self.target,
12131213
);
1214-
builder.run(&mut cmd);
1214+
builder.run(cmd);
12151215
drop(doc_generator_guard);
12161216

12171217
// Run rustbook/mdbook to generate the HTML pages.

src/bootstrap/src/core/build_steps/install.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use std::env;
77
use std::fs;
88
use std::path::{Component, Path, PathBuf};
9-
use std::process::Command;
109

1110
use crate::core::build_steps::dist;
1211
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
1312
use crate::core::config::{Config, TargetSelection};
13+
use crate::utils::exec::BootstrapCommand;
1414
use crate::utils::helpers::t;
1515
use crate::utils::tarball::GeneratedTarball;
1616
use crate::{Compiler, Kind};
@@ -102,7 +102,7 @@ fn install_sh(
102102
let empty_dir = builder.out.join("tmp/empty_dir");
103103
t!(fs::create_dir_all(&empty_dir));
104104

105-
let mut cmd = Command::new(SHELL);
105+
let mut cmd = BootstrapCommand::new(SHELL);
106106
cmd.current_dir(&empty_dir)
107107
.arg(sanitize_sh(&tarball.decompressed_output().join("install.sh")))
108108
.arg(format!("--prefix={}", prepare_dir(&destdir_env, prefix)))
@@ -113,7 +113,7 @@ fn install_sh(
113113
.arg(format!("--libdir={}", prepare_dir(&destdir_env, libdir)))
114114
.arg(format!("--mandir={}", prepare_dir(&destdir_env, mandir)))
115115
.arg("--disable-ldconfig");
116-
builder.run(&mut cmd);
116+
builder.run(cmd);
117117
t!(fs::remove_dir_all(&empty_dir));
118118
}
119119

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Step for BuildManifest {
5050
cmd.arg(&builder.config.channel);
5151

5252
builder.create_dir(&distdir(builder));
53-
builder.run(&mut cmd);
53+
builder.run(cmd);
5454
}
5555
}
5656

@@ -72,7 +72,7 @@ impl Step for BumpStage0 {
7272
fn run(self, builder: &Builder<'_>) -> Self::Output {
7373
let mut cmd = builder.tool_cmd(Tool::BumpStage0);
7474
cmd.args(builder.config.args());
75-
builder.run(&mut cmd);
75+
builder.run(cmd);
7676
}
7777
}
7878

@@ -94,7 +94,7 @@ impl Step for ReplaceVersionPlaceholder {
9494
fn run(self, builder: &Builder<'_>) -> Self::Output {
9595
let mut cmd = builder.tool_cmd(Tool::ReplaceVersionPlaceholder);
9696
cmd.arg(&builder.src);
97-
builder.run(&mut cmd);
97+
builder.run(cmd);
9898
}
9999
}
100100

@@ -188,7 +188,7 @@ impl Step for CollectLicenseMetadata {
188188
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
189189
cmd.env("REUSE_EXE", reuse);
190190
cmd.env("DEST", &dest);
191-
builder.run(&mut cmd);
191+
builder.run(cmd);
192192

193193
dest
194194
}
@@ -218,7 +218,7 @@ impl Step for GenerateCopyright {
218218
let mut cmd = builder.tool_cmd(Tool::GenerateCopyright);
219219
cmd.env("LICENSE_METADATA", &license_metadata);
220220
cmd.env("DEST", &dest);
221-
builder.run(&mut cmd);
221+
builder.run(cmd);
222222

223223
dest
224224
}
@@ -242,7 +242,7 @@ impl Step for GenerateWindowsSys {
242242
fn run(self, builder: &Builder<'_>) {
243243
let mut cmd = builder.tool_cmd(Tool::GenerateWindowsSys);
244244
cmd.arg(&builder.src);
245-
builder.run(&mut cmd);
245+
builder.run(cmd);
246246
}
247247
}
248248

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,19 +2874,19 @@ impl Step for RemoteCopyLibs {
28742874

28752875
// Spawn the emulator and wait for it to come online
28762876
let tool = builder.tool_exe(Tool::RemoteTestClient);
2877-
let mut cmd = Command::new(&tool);
2877+
let mut cmd = BootstrapCommand::new(&tool);
28782878
cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.tempdir());
28792879
if let Some(rootfs) = builder.qemu_rootfs(target) {
28802880
cmd.arg(rootfs);
28812881
}
2882-
builder.run(&mut cmd);
2882+
builder.run(cmd);
28832883

28842884
// Push all our dylibs to the emulator
28852885
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
28862886
let f = t!(f);
28872887
let name = f.file_name().into_string().unwrap();
28882888
if helpers::is_dylib(&name) {
2889-
builder.run(Command::new(&tool).arg("push").arg(f.path()));
2889+
builder.run(BootstrapCommand::new(&tool).arg("push").arg(f.path()));
28902890
}
28912891
}
28922892
}
@@ -2917,20 +2917,20 @@ impl Step for Distcheck {
29172917
builder.ensure(dist::PlainSourceTarball);
29182918
builder.ensure(dist::Src);
29192919

2920-
let mut cmd = Command::new("tar");
2920+
let mut cmd = BootstrapCommand::new("tar");
29212921
cmd.arg("-xf")
29222922
.arg(builder.ensure(dist::PlainSourceTarball).tarball())
29232923
.arg("--strip-components=1")
29242924
.current_dir(&dir);
2925-
builder.run(&mut cmd);
2925+
builder.run(cmd);
29262926
builder.run(
2927-
Command::new("./configure")
2927+
BootstrapCommand::new("./configure")
29282928
.args(&builder.config.configure_args)
29292929
.arg("--enable-vendor")
29302930
.current_dir(&dir),
29312931
);
29322932
builder.run(
2933-
Command::new(helpers::make(&builder.config.build.triple))
2933+
BootstrapCommand::new(helpers::make(&builder.config.build.triple))
29342934
.arg("check")
29352935
.current_dir(&dir),
29362936
);
@@ -2950,7 +2950,7 @@ impl Step for Distcheck {
29502950

29512951
let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
29522952
builder.run(
2953-
Command::new(&builder.initial_cargo)
2953+
BootstrapCommand::new(&builder.initial_cargo)
29542954
// Will read the libstd Cargo.toml
29552955
// which uses the unstable `public-dependency` feature.
29562956
.env("RUSTC_BOOTSTRAP", "1")

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ pub struct ErrorIndex {
433433
}
434434

435435
impl ErrorIndex {
436-
pub fn command(builder: &Builder<'_>) -> Command {
436+
pub fn command(builder: &Builder<'_>) -> BootstrapCommand {
437437
// Error-index-generator links with the rustdoc library, so we need to add `rustc_lib_paths`
438438
// for rustc_private and libLLVM.so, and `sysroot_lib` for libstd, etc.
439439
let host = builder.config.build;
440440
let compiler = builder.compiler_for(builder.top_stage, host, host);
441-
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
441+
let mut cmd = BootstrapCommand::new(builder.ensure(ErrorIndex { compiler }));
442442
let mut dylib_paths = builder.rustc_lib_paths(compiler);
443443
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
444444
add_dylib_path(dylib_paths, &mut cmd);
@@ -1046,10 +1046,10 @@ tool_extended!((self, builder),
10461046
);
10471047

10481048
impl<'a> Builder<'a> {
1049-
/// Gets a `Command` which is ready to run `tool` in `stage` built for
1049+
/// Gets a `BootstrapCommand` which is ready to run `tool` in `stage` built for
10501050
/// `host`.
1051-
pub fn tool_cmd(&self, tool: Tool) -> Command {
1052-
let mut cmd = Command::new(self.tool_exe(tool));
1051+
pub fn tool_cmd(&self, tool: Tool) -> BootstrapCommand {
1052+
let mut cmd = BootstrapCommand::new(self.tool_exe(tool));
10531053
let compiler = self.compiler(0, self.config.build);
10541054
let host = &compiler.host;
10551055
// Prepares the `cmd` provided to be able to run the `compiler` provided.

src/bootstrap/src/core/build_steps/vendor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
22
use std::path::{Path, PathBuf};
3-
use std::process::Command;
3+
use crate::utils::exec::BootstrapCommand;
44

55
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
66
pub(crate) struct Vendor {
@@ -27,7 +27,7 @@ impl Step for Vendor {
2727
}
2828

2929
fn run(self, builder: &Builder<'_>) -> Self::Output {
30-
let mut cmd = Command::new(&builder.initial_cargo);
30+
let mut cmd = BootstrapCommand::new(&builder.initial_cargo);
3131
cmd.arg("vendor");
3232

3333
if self.versioned_dirs {
@@ -59,6 +59,6 @@ impl Step for Vendor {
5959

6060
cmd.current_dir(self.root_dir);
6161

62-
builder.run(&mut cmd);
62+
builder.run(cmd);
6363
}
6464
}

src/bootstrap/src/core/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ impl<'a> Builder<'a> {
12181218

12191219
/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
12201220
/// library lookup path.
1221-
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
1221+
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut BootstrapCommand) {
12221222
// Windows doesn't need dylib path munging because the dlls for the
12231223
// compiler live next to the compiler and the system will find them
12241224
// automatically.

src/bootstrap/src/utils/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ macro_rules! t {
4747
}
4848
};
4949
}
50+
use crate::utils::exec::BootstrapCommand;
5051
pub use t;
5152

5253
pub fn exe(name: &str, target: TargetSelection) -> String {
@@ -72,7 +73,7 @@ pub fn libdir(target: TargetSelection) -> &'static str {
7273

7374
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
7475
/// If the dylib_path_var is already set for this cmd, the old value will be overwritten!
75-
pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) {
76+
pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut BootstrapCommand) {
7677
let mut list = dylib_path();
7778
for path in path {
7879
list.insert(0, path);

src/bootstrap/src/utils/tarball.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'a> Tarball<'a> {
353353
};
354354

355355
cmd.args(["--compression-profile", compression_profile]);
356-
self.builder.run(&mut cmd);
356+
self.builder.run(cmd);
357357

358358
// Ensure there are no symbolic links in the tarball. In particular,
359359
// rustup-toolchain-install-master and most versions of Windows can't handle symbolic links.

0 commit comments

Comments
 (0)