@@ -39,6 +39,7 @@ 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 ;
4243use crate :: utils:: helpers:: {
4344 self , dir_is_empty, exe, libdir, mtime, output, run, run_suppressed, symlink_dir,
4445 try_run_suppressed,
@@ -959,17 +960,32 @@ impl Build {
959960
960961 /// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
961962 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
968987 }
969- } else {
970- self . run ( cmd) ;
971988 }
972- true
973989 }
974990
975991 pub fn is_verbose_than ( & self , level : usize ) -> bool {
0 commit comments