@@ -14,6 +14,7 @@ use std::time::{Duration, Instant};
14
14
15
15
use build_helper:: { output, t} ;
16
16
use lazy_static:: lazy_static;
17
+ use termcolor:: { ColorSpec , WriteColor } ;
17
18
18
19
use crate :: cache:: { Cache , Interned , INTERNER } ;
19
20
use crate :: check;
@@ -1562,6 +1563,7 @@ impl<'a> Builder<'a> {
1562
1563
let paths = S :: should_run ( ShouldRun :: new ( self ) ) . paths ;
1563
1564
let path = paths. iter ( ) . map ( |pathset| pathset. path ( self ) ) . next ( ) ;
1564
1565
let instructions = ReplicationStep {
1566
+ color : self . build . config . color ,
1565
1567
name : step. name ( ) ,
1566
1568
cmd : self . kind ,
1567
1569
path : path. expect ( "no paths for step" ) ,
@@ -1600,6 +1602,7 @@ impl<'a> Builder<'a> {
1600
1602
}
1601
1603
1602
1604
struct ReplicationStep {
1605
+ color : Color ,
1603
1606
cmd : Kind ,
1604
1607
name : & ' static str ,
1605
1608
path : PathBuf ,
@@ -1610,11 +1613,26 @@ lazy_static! {
1610
1613
}
1611
1614
1612
1615
pub ( crate ) extern "C" fn print_replication_steps ( ) {
1616
+ use std:: io:: Write ;
1613
1617
if let Some ( step) = CURRENT_INSTRUCTIONS . lock ( ) . expect ( "mutex guard is dropped on panic" ) . take ( )
1614
1618
{
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 {} {}`" ,
1618
1636
step. cmd,
1619
1637
step. path. display( )
1620
1638
) ;
0 commit comments