Migrate cargo_clippy_cmd and cargo_miri_cmd to BootstrapCommand

This commit is contained in:
Jakub Beránek 2024-06-22 11:19:23 +02:00
parent 86b2191460
commit f7d9543338
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
3 changed files with 15 additions and 17 deletions

View file

@ -2077,7 +2077,7 @@ pub fn stream_cargo(
tail_args: Vec<String>,
cb: &mut dyn FnMut(CargoMessage<'_>),
) -> bool {
let mut cargo = Command::from(cargo);
let mut cargo = BootstrapCommand::from(cargo).command;
// Instruct Cargo to give us json messages on stdout, critically leaving
// stderr as piped so we can get those pretty colors.
let mut message_format = if builder.config.json_output {

View file

@ -158,8 +158,7 @@ fn run(self, builder: &Builder<'_>) {
// after another --, so this must be at the end.
miri.args(builder.config.args());
let mut miri = Command::from(miri);
builder.run(&mut miri);
builder.run(miri);
}
}

View file

@ -1251,11 +1251,11 @@ pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
self.ensure(tool::Rustdoc { compiler })
}
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> Command {
pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
if run_compiler.stage == 0 {
// `ensure(Clippy { stage: 0 })` *builds* clippy with stage0, it doesn't use the beta clippy.
let cargo_clippy = self.build.config.download_clippy();
let mut cmd = Command::new(cargo_clippy);
let mut cmd = BootstrapCommand::new(cargo_clippy);
cmd.env("CARGO", &self.initial_cargo);
return cmd;
}
@ -1274,13 +1274,13 @@ pub fn cargo_clippy_cmd(&self, run_compiler: Compiler) -> Command {
let mut dylib_path = helpers::dylib_path();
dylib_path.insert(0, self.sysroot(run_compiler).join("lib"));
let mut cmd = Command::new(cargo_clippy);
let mut cmd = BootstrapCommand::new(cargo_clippy);
cmd.env(helpers::dylib_path_var(), env::join_paths(&dylib_path).unwrap());
cmd.env("CARGO", &self.initial_cargo);
cmd
}
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> Command {
pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> BootstrapCommand {
assert!(run_compiler.stage > 0, "miri can not be invoked at stage 0");
let build_compiler = self.compiler(run_compiler.stage - 1, self.build.build);
@ -1296,7 +1296,7 @@ pub fn cargo_miri_cmd(&self, run_compiler: Compiler) -> Command {
extra_features: Vec::new(),
});
// Invoke cargo-miri, make sure it can find miri and cargo.
let mut cmd = Command::new(cargo_miri);
let mut cmd = BootstrapCommand::new(cargo_miri);
cmd.env("MIRI", &miri);
cmd.env("CARGO", &self.initial_cargo);
// Need to add the `run_compiler` libs. Those are the libs produces *by* `build_compiler`,
@ -1353,7 +1353,7 @@ pub fn bare_cargo(
mode: Mode,
target: TargetSelection,
cmd: &str, // FIXME make this properly typed
) -> Command {
) -> BootstrapCommand {
let mut cargo;
if cmd == "clippy" {
cargo = self.cargo_clippy_cmd(compiler);
@ -1366,7 +1366,7 @@ pub fn bare_cargo(
cargo = self.cargo_miri_cmd(compiler);
cargo.arg("miri").arg(subcmd);
} else {
cargo = Command::new(&self.initial_cargo);
cargo = BootstrapCommand::new(&self.initial_cargo);
cargo.arg(cmd);
}
@ -2374,7 +2374,7 @@ fn encode(self) -> String {
#[derive(Debug)]
pub struct Cargo {
command: Command,
command: BootstrapCommand,
compiler: Compiler,
target: TargetSelection,
rustflags: Rustflags,
@ -2599,8 +2599,8 @@ fn configure_linker(&mut self, builder: &Builder<'_>) -> &mut Cargo {
}
}
impl From<Cargo> for Command {
fn from(mut cargo: Cargo) -> Command {
impl From<Cargo> for BootstrapCommand {
fn from(mut cargo: Cargo) -> BootstrapCommand {
let rustflags = &cargo.rustflags.0;
if !rustflags.is_empty() {
cargo.command.env("RUSTFLAGS", rustflags);
@ -2619,13 +2619,12 @@ fn from(mut cargo: Cargo) -> Command {
if !cargo.allow_features.is_empty() {
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
}
cargo.command
}
}
impl From<Cargo> for BootstrapCommand {
fn from(cargo: Cargo) -> BootstrapCommand {
Command::from(cargo).into()
impl From<Cargo> for Command {
fn from(cargo: Cargo) -> Command {
BootstrapCommand::from(cargo).command
}
}