fix printing cargo args on --dry-run

This commit is contained in:
jyn 2023-11-04 17:48:09 -04:00
parent 3ad8e2d129
commit 0ffac661fa

View File

@ -1809,10 +1809,6 @@ pub fn run_cargo(
is_check: bool, is_check: bool,
rlib_only_metadata: bool, rlib_only_metadata: bool,
) -> Vec<PathBuf> { ) -> Vec<PathBuf> {
if builder.config.dry_run() {
return Vec::new();
}
// `target_root_dir` looks like $dir/$target/release // `target_root_dir` looks like $dir/$target/release
let target_root_dir = stamp.parent().unwrap(); let target_root_dir = stamp.parent().unwrap();
// `target_deps_dir` looks like $dir/$target/release/deps // `target_deps_dir` looks like $dir/$target/release/deps
@ -1919,6 +1915,10 @@ pub fn run_cargo(
crate::exit!(1); crate::exit!(1);
} }
if builder.config.dry_run() {
return Vec::new();
}
// Ok now we need to actually find all the files listed in `toplevel`. We've // Ok now we need to actually find all the files listed in `toplevel`. We've
// got a list of prefix/extensions and we basically just need to find the // got a list of prefix/extensions and we basically just need to find the
// most recent file in the `deps` folder corresponding to each one. // most recent file in the `deps` folder corresponding to each one.
@ -1974,9 +1974,6 @@ pub fn stream_cargo(
cb: &mut dyn FnMut(CargoMessage<'_>), cb: &mut dyn FnMut(CargoMessage<'_>),
) -> bool { ) -> bool {
let mut cargo = Command::from(cargo); let mut cargo = Command::from(cargo);
if builder.config.dry_run() {
return true;
}
// Instruct Cargo to give us json messages on stdout, critically leaving // Instruct Cargo to give us json messages on stdout, critically leaving
// stderr as piped so we can get those pretty colors. // stderr as piped so we can get those pretty colors.
let mut message_format = if builder.config.json_output { let mut message_format = if builder.config.json_output {
@ -1995,6 +1992,11 @@ pub fn stream_cargo(
} }
builder.verbose(&format!("running: {cargo:?}")); builder.verbose(&format!("running: {cargo:?}"));
if builder.config.dry_run() {
return true;
}
let mut child = match cargo.spawn() { let mut child = match cargo.spawn() {
Ok(child) => child, Ok(child) => child,
Err(e) => panic!("failed to execute command: {cargo:?}\nERROR: {e}"), Err(e) => panic!("failed to execute command: {cargo:?}\nERROR: {e}"),