@@ -39,6 +39,7 @@ 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 ;
42
43
use crate :: utils:: helpers:: {
43
44
self , dir_is_empty, exe, libdir, mtime, output, run, run_suppressed, symlink_dir,
44
45
try_run_suppressed,
@@ -959,17 +960,32 @@ impl Build {
959
960
960
961
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
961
962
pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
962
- if !self . fail_fast {
963
- #[ allow( deprecated) ] // can't use Build::try_run, that's us
964
- if self . config . try_run ( cmd) . is_err ( ) {
965
- let mut failures = self . delayed_failures . borrow_mut ( ) ;
966
- failures. push ( format ! ( "{cmd:?}" ) ) ;
967
- return false ;
963
+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
964
+ self . run_cmd ( cmd. delay_failure ( ) )
965
+ }
966
+
967
+ /// A centralized function for running commands that do not return output.
968
+ pub ( crate ) fn run_cmd < ' a , C : Into < BootstrapCommand < ' a > > > ( & self , cmd : C ) -> bool {
969
+ let command = cmd. into ( ) ;
970
+ self . verbose ( & format ! ( "running: {command:?}" ) ) ;
971
+
972
+ #[ allow( deprecated) ] // can't use Build::try_run, that's us
973
+ let result = self . config . try_run ( command. command ) ;
974
+
975
+ match result {
976
+ Ok ( _) => true ,
977
+ Err ( _) => {
978
+ if command. delay_failure {
979
+ let mut failures = self . delayed_failures . borrow_mut ( ) ;
980
+ failures. push ( format ! ( "{command:?}" ) ) ;
981
+ return false ;
982
+ }
983
+ if self . fail_fast {
984
+ exit ! ( 1 ) ;
985
+ }
986
+ false
968
987
}
969
- } else {
970
- self . run ( cmd) ;
971
988
}
972
- true
973
989
}
974
990
975
991
pub fn is_verbose_than ( & self , level : usize ) -> bool {
0 commit comments