@@ -5,6 +5,7 @@ use std::io;
5
5
use std:: mem;
6
6
use std:: sync:: mpsc:: { channel, Receiver , Sender } ;
7
7
use std:: sync:: Arc ;
8
+ use std:: process:: Output ;
8
9
9
10
use crossbeam_utils;
10
11
use crossbeam_utils:: thread:: Scope ;
@@ -107,12 +108,22 @@ impl<'a> JobState<'a> {
107
108
. send ( Message :: BuildPlanMsg ( module_name, cmd, filenames) ) ;
108
109
}
109
110
110
- pub fn stdout ( & self , out : & str ) {
111
- let _ = self . tx . send ( Message :: Stdout ( out. to_string ( ) ) ) ;
112
- }
113
-
114
- pub fn stderr ( & self , err : & str ) {
115
- let _ = self . tx . send ( Message :: Stderr ( err. to_string ( ) ) ) ;
111
+ pub fn capture_output (
112
+ & self ,
113
+ cmd : ProcessBuilder ,
114
+ print_output : bool ,
115
+ ) -> CargoResult < Output > {
116
+ cmd. exec_with_streaming (
117
+ & mut |out| {
118
+ let _ = self . tx . send ( Message :: Stdout ( out. to_string ( ) ) ) ;
119
+ Ok ( ( ) )
120
+ } ,
121
+ & mut |err| {
122
+ let _ = self . tx . send ( Message :: Stderr ( err. to_string ( ) ) ) ;
123
+ Ok ( ( ) )
124
+ } ,
125
+ print_output,
126
+ )
116
127
}
117
128
}
118
129
@@ -226,7 +237,6 @@ impl<'a> JobQueue<'a> {
226
237
// currently a pretty big task. This is issue #5695.
227
238
let mut error = None ;
228
239
let mut progress = Progress :: with_style ( "Building" , ProgressStyle :: Ratio , cx. bcx . config ) ;
229
- let mut progress_maybe_changed = true ; // avoid flickering due to build script
230
240
if !cx. bcx . config . cli_unstable ( ) . compile_progress {
231
241
progress. disable ( ) ;
232
242
}
@@ -274,22 +284,13 @@ impl<'a> JobQueue<'a> {
274
284
// to the jobserver itself.
275
285
tokens. truncate ( self . active . len ( ) - 1 ) ;
276
286
277
- if progress_maybe_changed {
278
- let count = total - self . queue . len ( ) ;
279
- let active_names = self . active . iter ( )
280
- . map ( Key :: name_for_progress)
281
- . collect :: < Vec < _ > > ( ) ;
282
- drop ( progress. tick_now ( count, total, & format ! ( ": {}" , active_names. join( ", " ) ) ) ) ;
283
- }
287
+ let count = total - self . queue . len ( ) ;
288
+ let active_names = self . active . iter ( )
289
+ . map ( Key :: name_for_progress)
290
+ . collect :: < Vec < _ > > ( ) ;
291
+ drop ( progress. tick_now ( count, total, & format ! ( ": {}" , active_names. join( ", " ) ) ) ) ;
284
292
let event = self . rx . recv ( ) . unwrap ( ) ;
285
-
286
- progress_maybe_changed = match event {
287
- Message :: Stdout ( _) | Message :: Stderr ( _) => cx. bcx . config . extra_verbose ( ) ,
288
- _ => true ,
289
- } ;
290
- if progress_maybe_changed {
291
- progress. clear ( ) ;
292
- }
293
+ progress. clear ( ) ;
293
294
294
295
match event {
295
296
Message :: Run ( cmd) => {
@@ -302,14 +303,10 @@ impl<'a> JobQueue<'a> {
302
303
plan. update ( & module_name, & cmd, & filenames) ?;
303
304
}
304
305
Message :: Stdout ( out) => {
305
- if cx. bcx . config . extra_verbose ( ) {
306
- println ! ( "{}" , out) ;
307
- }
306
+ println ! ( "{}" , out) ;
308
307
}
309
308
Message :: Stderr ( err) => {
310
- if cx. bcx . config . extra_verbose ( ) {
311
- writeln ! ( cx. bcx. config. shell( ) . err( ) , "{}" , err) ?;
312
- }
309
+ writeln ! ( cx. bcx. config. shell( ) . err( ) , "{}" , err) ?;
313
310
}
314
311
Message :: FixDiagnostic ( msg) => {
315
312
print. print ( & msg) ?;
0 commit comments