Skip to content

Commit f607efc

Browse files
committed
Migrate a few command usages to BootstrapCommand
1 parent 91910fc commit f607efc

File tree

9 files changed

+31
-30
lines changed

9 files changed

+31
-30
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ impl Step for UnstableBookGen {
11221122
cmd.arg(builder.src.join("src"));
11231123
cmd.arg(out);
11241124

1125-
builder.run(&mut cmd);
1125+
builder.run(cmd);
11261126
}
11271127
}
11281128

@@ -1217,7 +1217,7 @@ impl Step for RustcBook {
12171217
self.compiler.host,
12181218
self.target,
12191219
);
1220-
builder.run(&mut cmd);
1220+
builder.run(cmd);
12211221
drop(doc_generator_guard);
12221222

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

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

+3-3
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

+6-6
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

+8-8
Original file line numberDiff line numberDiff line change
@@ -2876,19 +2876,19 @@ impl Step for RemoteCopyLibs {
28762876

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

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

2922-
let mut cmd = Command::new("tar");
2922+
let mut cmd = BootstrapCommand::new("tar");
29232923
cmd.arg("-xf")
29242924
.arg(builder.ensure(dist::PlainSourceTarball).tarball())
29252925
.arg("--strip-components=1")
29262926
.current_dir(&dir);
2927-
builder.run(&mut cmd);
2927+
builder.run(cmd);
29282928
builder.run(
2929-
Command::new("./configure")
2929+
BootstrapCommand::new("./configure")
29302930
.args(&builder.config.configure_args)
29312931
.arg("--enable-vendor")
29322932
.current_dir(&dir),
29332933
);
29342934
builder.run(
2935-
Command::new(helpers::make(&builder.config.build.triple))
2935+
BootstrapCommand::new(helpers::make(&builder.config.build.triple))
29362936
.arg("check")
29372937
.current_dir(&dir),
29382938
);
@@ -2952,7 +2952,7 @@ impl Step for Distcheck {
29522952

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

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ pub struct ErrorIndex {
360360
}
361361

362362
impl ErrorIndex {
363-
pub fn command(builder: &Builder<'_>) -> Command {
363+
pub fn command(builder: &Builder<'_>) -> BootstrapCommand {
364364
// Error-index-generator links with the rustdoc library, so we need to add `rustc_lib_paths`
365365
// for rustc_private and libLLVM.so, and `sysroot_lib` for libstd, etc.
366366
let host = builder.config.build;
367367
let compiler = builder.compiler_for(builder.top_stage, host, host);
368-
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
368+
let mut cmd = BootstrapCommand::new(builder.ensure(ErrorIndex { compiler }));
369369
let mut dylib_paths = builder.rustc_lib_paths(compiler);
370370
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
371371
add_dylib_path(dylib_paths, &mut cmd);
@@ -969,10 +969,10 @@ tool_extended!((self, builder),
969969
);
970970

971971
impl<'a> Builder<'a> {
972-
/// Gets a `Command` which is ready to run `tool` in `stage` built for
972+
/// Gets a `BootstrapCommand` which is ready to run `tool` in `stage` built for
973973
/// `host`.
974-
pub fn tool_cmd(&self, tool: Tool) -> Command {
975-
let mut cmd = Command::new(self.tool_exe(tool));
974+
pub fn tool_cmd(&self, tool: Tool) -> BootstrapCommand {
975+
let mut cmd = BootstrapCommand::new(self.tool_exe(tool));
976976
let compiler = self.compiler(0, self.config.build);
977977
let host = &compiler.host;
978978
// Prepares the `cmd` provided to be able to run the `compiler` provided.

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2+
use crate::utils::exec::BootstrapCommand;
23
use std::path::PathBuf;
3-
use std::process::Command;
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 {
@@ -56,6 +56,6 @@ impl Step for Vendor {
5656

5757
cmd.current_dir(self.root_dir);
5858

59-
builder.run(&mut cmd);
59+
builder.run(cmd);
6060
}
6161
}

src/bootstrap/src/core/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ impl<'a> Builder<'a> {
11981198

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

src/bootstrap/src/utils/helpers.rs

+2-1
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

+1-1
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)