@@ -90,7 +90,7 @@ mod job {
9090pub use crate :: builder:: PathSet ;
9191use crate :: cache:: { Interned , INTERNER } ;
9292pub use crate :: config:: Config ;
93- use crate :: exec:: { BootstrapCommand , OutputOnFailure } ;
93+ use crate :: exec:: { BehaviorOnFailure , BootstrapCommand , OutputOnFailure } ;
9494pub use crate :: flags:: Subcommand ;
9595use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
9696
@@ -976,22 +976,26 @@ impl Build {
976976 /// Runs a command, printing out nice contextual information if it fails.
977977 fn run_quiet ( & self , cmd : & mut Command ) {
978978 let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
979- // TODO: fail bootstrap immediately if this command fails
980- self . run_cmd ( cmd. output_on_failure ( OutputOnFailure :: Verbose ) ) ;
979+ self . run_cmd (
980+ cmd. failure_output ( OutputOnFailure :: Verbose ) . failure_behavior ( BehaviorOnFailure :: Exit ) ,
981+ ) ;
981982 }
982983
983984 /// Runs a command, printing out nice contextual information if it fails.
984985 /// Exits if the command failed to execute at all, otherwise returns its
985986 /// `status.success()`.
986987 fn run_quiet_delaying_failure ( & self , cmd : & mut Command ) -> bool {
987988 let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
988- self . run_cmd ( cmd. output_on_failure ( OutputOnFailure :: Verbose ) . delay_failure ( ) )
989+ self . run_cmd (
990+ cmd. failure_output ( OutputOnFailure :: Verbose )
991+ . failure_behavior ( BehaviorOnFailure :: DelayFail ) ,
992+ )
989993 }
990994
991995 /// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
992996 pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
993997 let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
994- self . run_cmd ( cmd. delay_failure ( ) )
998+ self . run_cmd ( cmd. failure_behavior ( BehaviorOnFailure :: DelayFail ) )
995999 }
9961000
9971001 /// A centralized function for running commands that do not return output.
@@ -1004,7 +1008,7 @@ impl Build {
10041008 Err ( e) => fail ( & format ! ( "failed to execute command: {:?}\n error: {}" , command, e) ) ,
10051009 } ;
10061010 let result = if !output. status . success ( ) {
1007- let output_on_failure = match command. output_on_failure {
1011+ let output_on_failure = match command. failure_output {
10081012 Some ( output) => Some ( output) ,
10091013 None if self . is_verbose ( ) => Some ( OutputOnFailure :: Succint ) ,
10101014 None => None ,
@@ -1040,10 +1044,16 @@ impl Build {
10401044 match result {
10411045 Ok ( _) => true ,
10421046 Err ( _) => {
1043- if command. delay_failure {
1044- let mut failures = self . delayed_failures . borrow_mut ( ) ;
1045- failures. push ( format ! ( "{command:?}" ) ) ;
1046- return false ;
1047+ if let Some ( failure_behavior) = command. failure_behavior {
1048+ match failure_behavior {
1049+ BehaviorOnFailure :: DelayFail => {
1050+ let mut failures = self . delayed_failures . borrow_mut ( ) ;
1051+ failures. push ( format ! ( "{command:?}" ) ) ;
1052+ }
1053+ BehaviorOnFailure :: Exit => {
1054+ exit ! ( 1 ) ;
1055+ }
1056+ }
10471057 }
10481058 if self . fail_fast {
10491059 exit ! ( 1 ) ;
0 commit comments