@@ -14,6 +14,7 @@ use std::time::{Duration, Instant};
1414
1515use build_helper:: { output, t} ;
1616use lazy_static:: lazy_static;
17+ use termcolor:: { ColorSpec , WriteColor } ;
1718
1819use crate :: cache:: { Cache , Interned , INTERNER } ;
1920use crate :: check;
@@ -1562,6 +1563,7 @@ impl<'a> Builder<'a> {
15621563 let paths = S :: should_run ( ShouldRun :: new ( self ) ) . paths ;
15631564 let path = paths. iter ( ) . map ( |pathset| pathset. path ( self ) ) . next ( ) ;
15641565 let instructions = ReplicationStep {
1566+ color : self . build . config . color ,
15651567 name : step. name ( ) ,
15661568 cmd : self . kind ,
15671569 path : path. expect ( "no paths for step" ) ,
@@ -1600,6 +1602,7 @@ impl<'a> Builder<'a> {
16001602}
16011603
16021604struct ReplicationStep {
1605+ color : Color ,
16031606 cmd : Kind ,
16041607 name : & ' static str ,
16051608 path : PathBuf ,
@@ -1610,11 +1613,26 @@ lazy_static! {
16101613}
16111614
16121615pub ( crate ) extern "C" fn print_replication_steps ( ) {
1616+ use std:: io:: Write ;
16131617 if let Some ( step) = CURRENT_INSTRUCTIONS . lock ( ) . expect ( "mutex guard is dropped on panic" ) . take ( )
16141618 {
1615- println ! ( "note: failed while building {}" , step. name) ;
1616- println ! (
1617- "help: to replicate this failure, run `./x.py {} {}`" ,
1619+ let mut stdout = termcolor:: StandardStream :: stdout ( step. color . into ( ) ) ;
1620+ // ignore errors; we're exiting anyway
1621+ let mut yellow = ColorSpec :: new ( ) ;
1622+ yellow. set_fg ( Some ( termcolor:: Color :: Yellow ) ) ;
1623+ let _ = stdout. set_color ( & yellow) ;
1624+ let _ = write ! ( stdout, "note" ) ;
1625+ let _ = stdout. reset ( ) ;
1626+ let _ = writeln ! ( stdout, ": failed while building {}" , step. name) ;
1627+
1628+ let mut blue = ColorSpec :: new ( ) ;
1629+ blue. set_fg ( Some ( termcolor:: Color :: Blue ) ) ;
1630+ let _ = stdout. set_color ( & blue) ;
1631+ let _ = write ! ( stdout, "help" ) ;
1632+ let _ = stdout. reset ( ) ;
1633+ let _ = writeln ! (
1634+ stdout,
1635+ ": to replicate this failure, run `./x.py {} {}`" ,
16181636 step. cmd,
16191637 step. path. display( )
16201638 ) ;
0 commit comments