@@ -39,11 +39,8 @@ use crate::core::config::flags;
3939use crate :: core:: config:: { DryRun , Target } ;
4040use crate :: core:: config:: { LlvmLibunwind , TargetSelection } ;
4141use crate :: utils:: cache:: { Interned , INTERNER } ;
42- use crate :: utils:: exec:: BootstrapCommand ;
43- use crate :: utils:: helpers:: {
44- self , dir_is_empty, exe, libdir, mtime, output, run, run_suppressed, symlink_dir,
45- try_run_suppressed,
46- } ;
42+ use crate :: utils:: exec:: { BehaviorOnFailure , BootstrapCommand } ;
43+ use crate :: utils:: helpers:: { self , dir_is_empty, exe, libdir, mtime, output, symlink_dir} ;
4744
4845mod core;
4946mod utils;
@@ -922,44 +919,30 @@ impl Build {
922919
923920 /// Runs a command, printing out nice contextual information if it fails.
924921 fn run ( & self , cmd : & mut Command ) {
925- if self . config . dry_run ( ) {
926- return ;
927- }
928- self . verbose ( & format ! ( "running: {cmd:?}" ) ) ;
929- run ( cmd, self . is_verbose ( ) )
922+ // FIXME: output mode -> status + err if self.is_verbose()
923+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
924+ self . run_cmd ( cmd. fail_fast ( ) ) ;
930925 }
931926
932927 /// Runs a command, printing out nice contextual information if it fails.
933928 fn run_quiet ( & self , cmd : & mut Command ) {
934- if self . config . dry_run ( ) {
935- return ;
936- }
937- self . verbose ( & format ! ( "running: {cmd:?}" ) ) ;
938- run_suppressed ( cmd)
929+ // FIXME: output mode -> output + err
930+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
931+ self . run_cmd ( cmd. fail_fast ( ) ) ;
939932 }
940933
941934 /// Runs a command, printing out nice contextual information if it fails.
942935 /// Exits if the command failed to execute at all, otherwise returns its
943936 /// `status.success()`.
944937 fn run_quiet_delaying_failure ( & self , cmd : & mut Command ) -> bool {
945- if self . config . dry_run ( ) {
946- return true ;
947- }
948- if !self . fail_fast {
949- self . verbose ( & format ! ( "running: {cmd:?}" ) ) ;
950- if !try_run_suppressed ( cmd) {
951- let mut failures = self . delayed_failures . borrow_mut ( ) ;
952- failures. push ( format ! ( "{cmd:?}" ) ) ;
953- return false ;
954- }
955- } else {
956- self . run_quiet ( cmd) ;
957- }
958- true
938+ // FIXME: output mode -> output + err
939+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
940+ self . run_cmd ( cmd. delay_failure ( ) )
959941 }
960942
961943 /// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
962944 pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
945+ // FIXME: output mode -> status + err if self.is_verbose()
963946 let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
964947 self . run_cmd ( cmd. delay_failure ( ) )
965948 }
@@ -975,10 +958,16 @@ impl Build {
975958 match result {
976959 Ok ( _) => true ,
977960 Err ( _) => {
978- if command. delay_failure {
979- let mut failures = self . delayed_failures . borrow_mut ( ) ;
980- failures. push ( format ! ( "{command:?}" ) ) ;
981- return false ;
961+ if let Some ( failure_behavior) = command. failure_behavior {
962+ match failure_behavior {
963+ BehaviorOnFailure :: DelayFail => {
964+ let mut failures = self . delayed_failures . borrow_mut ( ) ;
965+ failures. push ( format ! ( "{command:?}" ) ) ;
966+ }
967+ BehaviorOnFailure :: Exit => {
968+ exit ! ( 1 ) ;
969+ }
970+ }
982971 }
983972 if self . fail_fast {
984973 exit ! ( 1 ) ;
0 commit comments