@@ -72,6 +72,18 @@ pub trait Executor: Send + Sync + 'static {
7272 Ok ( ( ) )
7373 }
7474
75+ fn exec_and_capture_output (
76+ & self ,
77+ cmd : ProcessBuilder ,
78+ id : & PackageId ,
79+ target : & Target ,
80+ mode : CompileMode ,
81+ _state : & job_queue:: JobState < ' _ > ,
82+ ) -> CargoResult < ( ) > {
83+ // we forward to exec() to keep RLS working.
84+ self . exec ( cmd, id, target, mode)
85+ }
86+
7587 fn exec_json (
7688 & self ,
7789 cmd : ProcessBuilder ,
@@ -97,7 +109,18 @@ pub trait Executor: Send + Sync + 'static {
97109#[ derive( Copy , Clone ) ]
98110pub struct DefaultExecutor ;
99111
100- impl Executor for DefaultExecutor { }
112+ impl Executor for DefaultExecutor {
113+ fn exec_and_capture_output (
114+ & self ,
115+ cmd : ProcessBuilder ,
116+ _id : & PackageId ,
117+ _target : & Target ,
118+ _mode : CompileMode ,
119+ state : & job_queue:: JobState < ' _ > ,
120+ ) -> CargoResult < ( ) > {
121+ state. capture_output ( cmd, false ) . map ( drop)
122+ }
123+ }
101124
102125fn compile < ' a , ' cfg : ' a > (
103126 cx : & mut Context < ' a , ' cfg > ,
@@ -216,6 +239,8 @@ fn rustc<'a, 'cfg>(
216239 . unwrap_or_else ( || cx. bcx . config . cwd ( ) )
217240 . to_path_buf ( ) ;
218241
242+ let should_capture_output = cx. bcx . config . cli_unstable ( ) . compile_progress ;
243+
219244 return Ok ( Work :: new ( move |state| {
220245 // Only at runtime have we discovered what the extra -L and -l
221246 // arguments are for native libraries, so we process those here. We
@@ -291,7 +316,12 @@ fn rustc<'a, 'cfg>(
291316 } else if build_plan {
292317 state. build_plan ( buildkey, rustc. clone ( ) , outputs. clone ( ) ) ;
293318 } else {
294- exec. exec ( rustc, & package_id, & target, mode)
319+ let exec_result = if should_capture_output {
320+ exec. exec_and_capture_output ( rustc, & package_id, & target, mode, state)
321+ } else {
322+ exec. exec ( rustc, & package_id, & target, mode)
323+ } ;
324+ exec_result
295325 . map_err ( Internal :: new)
296326 . chain_err ( || format ! ( "Could not compile `{}`." , name) ) ?;
297327 }
@@ -613,6 +643,8 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
613643 let build_state = cx. build_state . clone ( ) ;
614644 let key = ( unit. pkg . package_id ( ) . clone ( ) , unit. kind ) ;
615645
646+ let should_capture_output = cx. bcx . config . cli_unstable ( ) . compile_progress ;
647+
616648 Ok ( Work :: new ( move |state| {
617649 if let Some ( output) = build_state. outputs . lock ( ) . unwrap ( ) . get ( & key) {
618650 for cfg in output. cfgs . iter ( ) {
@@ -623,9 +655,13 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
623655 }
624656 }
625657 state. running ( & rustdoc) ;
626- rustdoc
627- . exec ( )
628- . chain_err ( || format ! ( "Could not document `{}`." , name) ) ?;
658+
659+ let exec_result = if should_capture_output {
660+ state. capture_output ( rustdoc, false ) . map ( drop)
661+ } else {
662+ rustdoc. exec ( )
663+ } ;
664+ exec_result. chain_err ( || format ! ( "Could not document `{}`." , name) ) ?;
629665 Ok ( ( ) )
630666 } ) )
631667}
0 commit comments