@@ -87,9 +87,14 @@ fn host_target() -> String {
87
87
/// libraries.
88
88
fn exec_cargo_with_args ( target : & str , args : & [ & str ] ) -> Vec < PathBuf > {
89
89
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 ( ) ) ;
93
98
94
99
println ! ( "running: {cmd:?}" ) ;
95
100
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> {
100
105
101
106
for line in reader. lines ( ) {
102
107
let line = line. expect ( "failed to read line" ) ;
103
- println ! ( "{line}" ) ; // tee to stdout
104
-
105
- // Select only steps that create files
106
108
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" {
108
123
continue ;
109
124
}
110
125
0 commit comments