@@ -87,9 +87,14 @@ fn host_target() -> String {
8787/// libraries.
8888fn exec_cargo_with_args ( target : & str , args : & [ & str ] ) -> Vec < PathBuf > {
8989 let mut cmd = Command :: new ( "cargo" ) ;
90- cmd. args ( [ "build" , "--target" , target, "--message-format=json" ] )
91- . args ( args)
92- . stdout ( Stdio :: piped ( ) ) ;
90+ cmd. args ( [
91+ "build" ,
92+ "--target" ,
93+ target,
94+ "--message-format=json-diagnostic-rendered-ansi" ,
95+ ] )
96+ . args ( args)
97+ . stdout ( Stdio :: piped ( ) ) ;
9398
9499 println ! ( "running: {cmd:?}" ) ;
95100 let mut child = cmd. spawn ( ) . expect ( "failed to launch Cargo" ) ;
@@ -100,11 +105,21 @@ fn exec_cargo_with_args(target: &str, args: &[&str]) -> Vec<PathBuf> {
100105
101106 for line in reader. lines ( ) {
102107 let line = line. expect ( "failed to read line" ) ;
103- println ! ( "{line}" ) ; // tee to stdout
104-
105- // Select only steps that create files
106108 let j: Value = serde_json:: from_str ( & line) . expect ( "failed to deserialize" ) ;
107- if j[ "reason" ] != "compiler-artifact" {
109+ let reason = & j[ "reason" ] ;
110+
111+ // Forward output that is meant to be user-facing
112+ if reason == "compiler-message" {
113+ println ! ( "{}" , j[ "message" ] [ "rendered" ] . as_str( ) . unwrap( ) ) ;
114+ } else if reason == "build-finished" {
115+ println ! ( "build finshed. success: {}" , j[ "success" ] ) ;
116+ } else if reason == "build-script-executed" {
117+ let pretty = serde_json:: to_string_pretty ( & j) . unwrap ( ) ;
118+ println ! ( "build script output: {pretty}" , ) ;
119+ }
120+
121+ // Only interested in the artifact list now
122+ if reason != "compiler-artifact" {
108123 continue ;
109124 }
110125
0 commit comments