@@ -39,11 +39,8 @@ use crate::core::config::flags;
39
39
use crate :: core:: config:: { DryRun , Target } ;
40
40
use crate :: core:: config:: { LlvmLibunwind , TargetSelection } ;
41
41
use 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} ;
47
44
48
45
mod core;
49
46
mod utils;
@@ -922,44 +919,30 @@ impl Build {
922
919
923
920
/// Runs a command, printing out nice contextual information if it fails.
924
921
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 ( ) ) ;
930
925
}
931
926
932
927
/// Runs a command, printing out nice contextual information if it fails.
933
928
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 ( ) ) ;
939
932
}
940
933
941
934
/// Runs a command, printing out nice contextual information if it fails.
942
935
/// Exits if the command failed to execute at all, otherwise returns its
943
936
/// `status.success()`.
944
937
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 ( ) )
959
941
}
960
942
961
943
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
962
944
pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
945
+ // FIXME: output mode -> status + err if self.is_verbose()
963
946
let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
964
947
self . run_cmd ( cmd. delay_failure ( ) )
965
948
}
@@ -975,10 +958,16 @@ impl Build {
975
958
match result {
976
959
Ok ( _) => true ,
977
960
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
+ }
982
971
}
983
972
if self . fail_fast {
984
973
exit ! ( 1 ) ;
0 commit comments