Handle execution of dry run commands
This commit is contained in:
parent
60c20bfe0c
commit
70b6e04452
@ -2,7 +2,6 @@ use crate::core::build_steps::compile::{Std, Sysroot};
|
||||
use crate::core::build_steps::tool::{RustcPerf, Tool};
|
||||
use crate::core::builder::Builder;
|
||||
use crate::core::config::DebuginfoLevel;
|
||||
use crate::utils::exec::BootstrapCommand;
|
||||
|
||||
/// Performs profiling using `rustc-perf` on a built version of the compiler.
|
||||
pub fn perf(builder: &Builder<'_>) {
|
||||
|
@ -1805,7 +1805,13 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
|
||||
|
||||
let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
|
||||
let lldb_version = builder
|
||||
.run(BootstrapCommand::new(&lldb_exe).capture().allow_failure().arg("--version"))
|
||||
.run(
|
||||
BootstrapCommand::new(&lldb_exe)
|
||||
.capture()
|
||||
.allow_failure()
|
||||
.run_always()
|
||||
.arg("--version"),
|
||||
)
|
||||
.stdout_if_ok();
|
||||
if let Some(ref vers) = lldb_version {
|
||||
cmd.arg("--lldb-version").arg(vers);
|
||||
|
@ -81,8 +81,7 @@ fn workspace_members(build: &Build) -> Vec<Package> {
|
||||
.arg("--no-deps")
|
||||
.arg("--manifest-path")
|
||||
.arg(build.src.join(manifest_path));
|
||||
// FIXME: fix stderr
|
||||
let metadata_output = build.run(cargo.capture()).stdout();
|
||||
let metadata_output = build.run(cargo.capture_stdout().run_always()).stdout();
|
||||
let Output { packages, .. } = t!(serde_json::from_str(&metadata_output));
|
||||
packages
|
||||
};
|
||||
|
@ -936,12 +936,11 @@ impl Build {
|
||||
/// Execute a command and return its output.
|
||||
/// This method should be used for all command executions in bootstrap.
|
||||
fn run<C: AsMut<BootstrapCommand>>(&self, mut command: C) -> CommandOutput {
|
||||
if self.config.dry_run() {
|
||||
let command = command.as_mut();
|
||||
if self.config.dry_run() && !command.run_always {
|
||||
return CommandOutput::default();
|
||||
}
|
||||
|
||||
let command = command.as_mut();
|
||||
|
||||
self.verbose(|| println!("running: {command:?}"));
|
||||
|
||||
let output: io::Result<Output> = match command.output_mode {
|
||||
|
@ -47,6 +47,8 @@ pub struct BootstrapCommand {
|
||||
pub command: Command,
|
||||
pub failure_behavior: BehaviorOnFailure,
|
||||
pub output_mode: OutputMode,
|
||||
// Run the command even during dry run
|
||||
pub run_always: bool,
|
||||
}
|
||||
|
||||
impl BootstrapCommand {
|
||||
@ -107,6 +109,11 @@ impl BootstrapCommand {
|
||||
Self { failure_behavior: BehaviorOnFailure::Ignore, ..self }
|
||||
}
|
||||
|
||||
pub fn run_always(&mut self) -> &mut Self {
|
||||
self.run_always = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Capture the output of the command, do not print it.
|
||||
pub fn capture(self) -> Self {
|
||||
Self { output_mode: OutputMode::CaptureAll, ..self }
|
||||
@ -128,7 +135,12 @@ impl AsMut<BootstrapCommand> for BootstrapCommand {
|
||||
|
||||
impl From<Command> for BootstrapCommand {
|
||||
fn from(command: Command) -> Self {
|
||||
Self { command, failure_behavior: BehaviorOnFailure::Exit, output_mode: OutputMode::Print }
|
||||
Self {
|
||||
command,
|
||||
failure_behavior: BehaviorOnFailure::Exit,
|
||||
output_mode: OutputMode::Print,
|
||||
run_always: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user