@@ -580,6 +580,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
580
580
rustdoc. arg ( "--crate-name" ) . arg ( & unit. target . crate_name ( ) ) ;
581
581
add_path_args ( bcx, unit, & mut rustdoc) ;
582
582
add_cap_lints ( bcx, unit, & mut rustdoc) ;
583
+ add_color ( bcx, & mut rustdoc) ;
583
584
584
585
if unit. kind != Kind :: Host {
585
586
if let Some ( ref target) = bcx. build_config . requested_target {
@@ -672,6 +673,15 @@ fn add_cap_lints(bcx: &BuildContext, unit: &Unit, cmd: &mut ProcessBuilder) {
672
673
}
673
674
}
674
675
676
+ fn add_color ( bcx : & BuildContext , cmd : & mut ProcessBuilder ) {
677
+ let capture_output = bcx. config . cli_unstable ( ) . compile_progress ;
678
+ let shell = bcx. config . shell ( ) ;
679
+ if capture_output || shell. color_choice ( ) != ColorChoice :: CargoAuto {
680
+ let color = if shell. supports_color ( ) { "always" } else { "never" } ;
681
+ cmd. args ( & [ "--color" , color] ) ;
682
+ }
683
+ }
684
+
675
685
fn build_base_args < ' a , ' cfg > (
676
686
cx : & mut Context < ' a , ' cfg > ,
677
687
cmd : & mut ProcessBuilder ,
@@ -696,17 +706,8 @@ fn build_base_args<'a, 'cfg>(
696
706
697
707
cmd. arg ( "--crate-name" ) . arg ( & unit. target . crate_name ( ) ) ;
698
708
699
- add_path_args ( & cx. bcx , unit, cmd) ;
700
-
701
- match bcx. config . shell ( ) . color_choice ( ) {
702
- ColorChoice :: Always => {
703
- cmd. arg ( "--color" ) . arg ( "always" ) ;
704
- }
705
- ColorChoice :: Never => {
706
- cmd. arg ( "--color" ) . arg ( "never" ) ;
707
- }
708
- ColorChoice :: CargoAuto => { }
709
- }
709
+ add_path_args ( bcx, unit, cmd) ;
710
+ add_color ( bcx, cmd) ;
710
711
711
712
if bcx. build_config . json_messages ( ) {
712
713
cmd. arg ( "--error-format" ) . arg ( "json" ) ;
0 commit comments