Migrate a few command usages to BootstrapCommand

This commit is contained in:
Jakub Beránek 2024-06-22 11:22:39 +02:00
parent f7d9543338
commit 8a890cb6cb
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
9 changed files with 31 additions and 30 deletions

View file

@ -1116,7 +1116,7 @@ fn run(self, builder: &Builder<'_>) {
cmd.arg(builder.src.join("src"));
cmd.arg(out);
builder.run(&mut cmd);
builder.run(cmd);
}
}
@ -1211,7 +1211,7 @@ fn run(self, builder: &Builder<'_>) {
self.compiler.host,
self.target,
);
builder.run(&mut cmd);
builder.run(cmd);
drop(doc_generator_guard);
// Run rustbook/mdbook to generate the HTML pages.

View file

@ -6,11 +6,11 @@
use std::env;
use std::fs;
use std::path::{Component, Path, PathBuf};
use std::process::Command;
use crate::core::build_steps::dist;
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::core::config::{Config, TargetSelection};
use crate::utils::exec::BootstrapCommand;
use crate::utils::helpers::t;
use crate::utils::tarball::GeneratedTarball;
use crate::{Compiler, Kind};
@ -102,7 +102,7 @@ fn install_sh(
let empty_dir = builder.out.join("tmp/empty_dir");
t!(fs::create_dir_all(&empty_dir));
let mut cmd = Command::new(SHELL);
let mut cmd = BootstrapCommand::new(SHELL);
cmd.current_dir(&empty_dir)
.arg(sanitize_sh(&tarball.decompressed_output().join("install.sh")))
.arg(format!("--prefix={}", prepare_dir(&destdir_env, prefix)))
@ -113,7 +113,7 @@ fn install_sh(
.arg(format!("--libdir={}", prepare_dir(&destdir_env, libdir)))
.arg(format!("--mandir={}", prepare_dir(&destdir_env, mandir)))
.arg("--disable-ldconfig");
builder.run(&mut cmd);
builder.run(cmd);
t!(fs::remove_dir_all(&empty_dir));
}

View file

@ -50,7 +50,7 @@ fn run(self, builder: &Builder<'_>) {
cmd.arg(&builder.config.channel);
builder.create_dir(&distdir(builder));
builder.run(&mut cmd);
builder.run(cmd);
}
}
@ -72,7 +72,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut cmd = builder.tool_cmd(Tool::BumpStage0);
cmd.args(builder.config.args());
builder.run(&mut cmd);
builder.run(cmd);
}
}
@ -94,7 +94,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut cmd = builder.tool_cmd(Tool::ReplaceVersionPlaceholder);
cmd.arg(&builder.src);
builder.run(&mut cmd);
builder.run(cmd);
}
}
@ -188,7 +188,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
cmd.env("REUSE_EXE", reuse);
cmd.env("DEST", &dest);
builder.run(&mut cmd);
builder.run(cmd);
dest
}
@ -218,7 +218,7 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut cmd = builder.tool_cmd(Tool::GenerateCopyright);
cmd.env("LICENSE_METADATA", &license_metadata);
cmd.env("DEST", &dest);
builder.run(&mut cmd);
builder.run(cmd);
dest
}
@ -242,7 +242,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) {
let mut cmd = builder.tool_cmd(Tool::GenerateWindowsSys);
cmd.arg(&builder.src);
builder.run(&mut cmd);
builder.run(cmd);
}
}

View file

@ -2874,19 +2874,19 @@ fn run(self, builder: &Builder<'_>) {
// Spawn the emulator and wait for it to come online
let tool = builder.tool_exe(Tool::RemoteTestClient);
let mut cmd = Command::new(&tool);
let mut cmd = BootstrapCommand::new(&tool);
cmd.arg("spawn-emulator").arg(target.triple).arg(&server).arg(builder.tempdir());
if let Some(rootfs) = builder.qemu_rootfs(target) {
cmd.arg(rootfs);
}
builder.run(&mut cmd);
builder.run(cmd);
// Push all our dylibs to the emulator
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
let f = t!(f);
let name = f.file_name().into_string().unwrap();
if helpers::is_dylib(&name) {
builder.run(Command::new(&tool).arg("push").arg(f.path()));
builder.run(BootstrapCommand::new(&tool).arg("push").arg(f.path()));
}
}
}
@ -2917,20 +2917,20 @@ fn run(self, builder: &Builder<'_>) {
builder.ensure(dist::PlainSourceTarball);
builder.ensure(dist::Src);
let mut cmd = Command::new("tar");
let mut cmd = BootstrapCommand::new("tar");
cmd.arg("-xf")
.arg(builder.ensure(dist::PlainSourceTarball).tarball())
.arg("--strip-components=1")
.current_dir(&dir);
builder.run(&mut cmd);
builder.run(cmd);
builder.run(
Command::new("./configure")
BootstrapCommand::new("./configure")
.args(&builder.config.configure_args)
.arg("--enable-vendor")
.current_dir(&dir),
);
builder.run(
Command::new(helpers::make(&builder.config.build.triple))
BootstrapCommand::new(helpers::make(&builder.config.build.triple))
.arg("check")
.current_dir(&dir),
);
@ -2950,7 +2950,7 @@ fn run(self, builder: &Builder<'_>) {
let toml = dir.join("rust-src/lib/rustlib/src/rust/library/std/Cargo.toml");
builder.run(
Command::new(&builder.initial_cargo)
BootstrapCommand::new(&builder.initial_cargo)
// Will read the libstd Cargo.toml
// which uses the unstable `public-dependency` feature.
.env("RUSTC_BOOTSTRAP", "1")

View file

@ -433,12 +433,12 @@ pub struct ErrorIndex {
}
impl ErrorIndex {
pub fn command(builder: &Builder<'_>) -> Command {
pub fn command(builder: &Builder<'_>) -> BootstrapCommand {
// Error-index-generator links with the rustdoc library, so we need to add `rustc_lib_paths`
// for rustc_private and libLLVM.so, and `sysroot_lib` for libstd, etc.
let host = builder.config.build;
let compiler = builder.compiler_for(builder.top_stage, host, host);
let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler }));
let mut cmd = BootstrapCommand::new(builder.ensure(ErrorIndex { compiler }));
let mut dylib_paths = builder.rustc_lib_paths(compiler);
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
add_dylib_path(dylib_paths, &mut cmd);
@ -1046,10 +1046,10 @@ fn run(mut $sel, $builder: &Builder<'_>) -> PathBuf {
);
impl<'a> Builder<'a> {
/// Gets a `Command` which is ready to run `tool` in `stage` built for
/// Gets a `BootstrapCommand` which is ready to run `tool` in `stage` built for
/// `host`.
pub fn tool_cmd(&self, tool: Tool) -> Command {
let mut cmd = Command::new(self.tool_exe(tool));
pub fn tool_cmd(&self, tool: Tool) -> BootstrapCommand {
let mut cmd = BootstrapCommand::new(self.tool_exe(tool));
let compiler = self.compiler(0, self.config.build);
let host = &compiler.host;
// Prepares the `cmd` provided to be able to run the `compiler` provided.

View file

@ -1,6 +1,6 @@
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
use std::path::{Path, PathBuf};
use std::process::Command;
use crate::utils::exec::BootstrapCommand;
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub(crate) struct Vendor {
@ -27,7 +27,7 @@ fn make_run(run: RunConfig<'_>) {
}
fn run(self, builder: &Builder<'_>) -> Self::Output {
let mut cmd = Command::new(&builder.initial_cargo);
let mut cmd = BootstrapCommand::new(&builder.initial_cargo);
cmd.arg("vendor");
if self.versioned_dirs {
@ -59,6 +59,6 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
cmd.current_dir(self.root_dir);
builder.run(&mut cmd);
builder.run(cmd);
}
}

View file

@ -1218,7 +1218,7 @@ pub fn rustc_lib_paths(&self, compiler: Compiler) -> Vec<PathBuf> {
/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
/// library lookup path.
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut BootstrapCommand) {
// Windows doesn't need dylib path munging because the dlls for the
// compiler live next to the compiler and the system will find them
// automatically.

View file

@ -47,6 +47,7 @@ macro_rules! t {
}
};
}
use crate::utils::exec::BootstrapCommand;
pub use t;
pub fn exe(name: &str, target: TargetSelection) -> String {
@ -72,7 +73,7 @@ pub fn libdir(target: TargetSelection) -> &'static str {
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
/// If the dylib_path_var is already set for this cmd, the old value will be overwritten!
pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut Command) {
pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut BootstrapCommand) {
let mut list = dylib_path();
for path in path {
list.insert(0, path);

View file

@ -353,7 +353,7 @@ fn run(self, build_cli: impl FnOnce(&Tarball<'a>, &mut Command)) -> GeneratedTar
};
cmd.args(["--compression-profile", compression_profile]);
self.builder.run(&mut cmd);
self.builder.run(cmd);
// Ensure there are no symbolic links in the tarball. In particular,
// rustup-toolchain-install-master and most versions of Windows can't handle symbolic links.