@@ -12,7 +12,6 @@ use std::ffi::OsStr;
12
12
use std:: io:: BufReader ;
13
13
use std:: io:: prelude:: * ;
14
14
use std:: path:: { Path , PathBuf } ;
15
- use std:: process:: Stdio ;
16
15
use std:: { env, fs, str} ;
17
16
18
17
use serde_derive:: Deserialize ;
@@ -2511,11 +2510,11 @@ pub fn stream_cargo(
2511
2510
cb : & mut dyn FnMut ( CargoMessage < ' _ > ) ,
2512
2511
) -> bool {
2513
2512
let mut cmd = cargo. into_cmd ( ) ;
2513
+ cmd. do_not_cache ( ) ;
2514
2514
2515
2515
#[ cfg( feature = "tracing" ) ]
2516
2516
let _run_span = crate :: trace_cmd!( cmd) ;
2517
2517
2518
- let cargo = cmd. as_command_mut ( ) ;
2519
2518
// Instruct Cargo to give us json messages on stdout, critically leaving
2520
2519
// stderr as piped so we can get those pretty colors.
2521
2520
let mut message_format = if builder. config . json_output {
@@ -2527,27 +2526,26 @@ pub fn stream_cargo(
2527
2526
message_format. push_str ( ",json-diagnostic-" ) ;
2528
2527
message_format. push_str ( s) ;
2529
2528
}
2530
- cargo . arg ( "--message-format" ) . arg ( message_format) . stdout ( Stdio :: piped ( ) ) ;
2529
+ cmd . arg ( "--message-format" ) . arg ( message_format) ;
2531
2530
2532
2531
for arg in tail_args {
2533
- cargo . arg ( arg) ;
2532
+ cmd . arg ( arg) ;
2534
2533
}
2535
2534
2536
- builder. verbose ( || println ! ( "running: {cargo :?}" ) ) ;
2535
+ builder. verbose ( || println ! ( "running: {cmd :?}" ) ) ;
2537
2536
2538
- if builder. config . dry_run ( ) {
2537
+ let streaming_command = cmd. start_capture_stdout ( & builder. config . exec_ctx ) . stream ( ) ;
2538
+
2539
+ if streaming_command. is_none ( ) {
2539
2540
return true ;
2540
2541
}
2541
2542
2542
- let mut child = match cargo. spawn ( ) {
2543
- Ok ( child) => child,
2544
- Err ( e) => panic ! ( "failed to execute command: {cargo:?}\n ERROR: {e}" ) ,
2545
- } ;
2543
+ let mut streaming_command = streaming_command. unwrap ( ) ;
2546
2544
2547
2545
// Spawn Cargo slurping up its JSON output. We'll start building up the
2548
2546
// `deps` array of all files it generated along with a `toplevel` array of
2549
2547
// files we need to probe for later.
2550
- let stdout = BufReader :: new ( child . stdout . take ( ) . unwrap ( ) ) ;
2548
+ let stdout = BufReader :: new ( streaming_command . stdout . take ( ) . unwrap ( ) ) ;
2551
2549
for line in stdout. lines ( ) {
2552
2550
let line = t ! ( line) ;
2553
2551
match serde_json:: from_str :: < CargoMessage < ' _ > > ( & line) {
@@ -2564,13 +2562,14 @@ pub fn stream_cargo(
2564
2562
}
2565
2563
2566
2564
// Make sure Cargo actually succeeded after we read all of its stdout.
2567
- let status = t ! ( child . wait( ) ) ;
2565
+ let status = t ! ( streaming_command . wait( ) ) ;
2568
2566
if builder. is_verbose ( ) && !status. success ( ) {
2569
2567
eprintln ! (
2570
- "command did not execute successfully: {cargo :?}\n \
2568
+ "command did not execute successfully: {cmd :?}\n \
2571
2569
expected success, got: {status}"
2572
2570
) ;
2573
2571
}
2572
+
2574
2573
status. success ( )
2575
2574
}
2576
2575
0 commit comments