From ec52e6426481bc07fa1625a5be5804846f1e524c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Misty=20De=20M=C3=A9o?= Date: Wed, 13 Dec 2023 14:19:09 -0800 Subject: [PATCH] feat(generic): adjust stdout=>stderr redirect Pipe stdout from the subprocesses directly to stderr. --- cargo-dist/src/generic_build.rs | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/cargo-dist/src/generic_build.rs b/cargo-dist/src/generic_build.rs index ce87d7d74..bfc13d367 100644 --- a/cargo-dist/src/generic_build.rs +++ b/cargo-dist/src/generic_build.rs @@ -2,8 +2,7 @@ use std::{ env, - io::{stderr, Write}, - process::{Command, Output}, + process::{Command, ExitStatus}, }; use camino::Utf8Path; @@ -77,7 +76,7 @@ fn run_build( dist_graph: &DistGraph, command_string: &[String], target: Option<&str>, -) -> Result { +) -> Result { let mut command_string = command_string.to_owned(); let mut desired_extra_env = vec![]; @@ -99,7 +98,7 @@ fn run_build( .first() .expect("The build command must contain at least one entry"), ); - command.stdout(std::process::Stdio::piped()); + command.stdout(std::io::stderr()); command.stderr(std::process::Stdio::inherit()); for arg in args { command.arg(arg); @@ -133,7 +132,7 @@ fn run_build( info!("exec: {:?}", command); command - .output() + .status() .into_diagnostic() .wrap_err_with(|| format!("failed to exec generic build: {command:?}")) } @@ -152,12 +151,9 @@ pub fn build_generic_target(dist_graph: &DistGraph, target: &GenericBuildStep) - Some(&target.target_triple), )?; - if !result.status.success() { - println!("Build exited non-zero: {}", result.status); + if !result.success() { + println!("Build exited non-zero: {}", result); } - eprintln!(); - eprintln!("stdout:"); - stderr().write_all(&result.stdout).into_diagnostic()?; // Check that we got everything we expected, and normalize to ArtifactIdx => Artifact Path for binary_idx in &target.expected_binaries { @@ -189,12 +185,9 @@ pub fn run_extra_artifacts_build(dist_graph: &DistGraph, target: &ExtraBuildStep let result = run_build(dist_graph, &target.build_command, None)?; let dest = dist_graph.dist_dir.to_owned(); - if !result.status.success() { - println!("Build exited non-zero: {}", result.status); + if !result.success() { + println!("Build exited non-zero: {}", result); } - eprintln!(); - eprintln!("stdout:"); - stderr().write_all(&result.stdout).into_diagnostic()?; // Check that we got everything we expected, and copy into the distribution path for artifact in &target.expected_artifacts {