@@ -50,6 +50,7 @@ mod config;
5050mod dist;
5151mod doc;
5252mod download;
53+ mod exec;
5354mod flags;
5455mod format;
5556mod install;
@@ -90,6 +91,7 @@ mod job {
9091pub use crate :: builder:: PathSet ;
9192use crate :: cache:: { Interned , INTERNER } ;
9293pub use crate :: config:: Config ;
94+ use crate :: exec:: BootstrapCommand ;
9395pub use crate :: flags:: Subcommand ;
9496use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
9597
@@ -1003,17 +1005,32 @@ impl Build {
10031005
10041006 /// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
10051007 pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
1006- if !self . fail_fast {
1007- #[ allow( deprecated) ] // can't use Build::try_run, that's us
1008- if self . config . try_run ( cmd) . is_err ( ) {
1009- let mut failures = self . delayed_failures . borrow_mut ( ) ;
1010- failures. push ( format ! ( "{cmd:?}" ) ) ;
1011- return false ;
1008+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
1009+ self . run_cmd ( cmd. delay_failure ( ) )
1010+ }
1011+
1012+ /// A centralized function for running commands that do not return output.
1013+ pub ( crate ) fn run_cmd < ' a , C : Into < BootstrapCommand < ' a > > > ( & self , cmd : C ) -> bool {
1014+ let command = cmd. into ( ) ;
1015+ self . verbose ( & format ! ( "running: {command:?}" ) ) ;
1016+
1017+ #[ allow( deprecated) ] // can't use Build::try_run, that's us
1018+ let result = self . config . try_run ( command. command ) ;
1019+
1020+ match result {
1021+ Ok ( _) => true ,
1022+ Err ( _) => {
1023+ if command. delay_failure {
1024+ let mut failures = self . delayed_failures . borrow_mut ( ) ;
1025+ failures. push ( format ! ( "{command:?}" ) ) ;
1026+ return false ;
1027+ }
1028+ if self . fail_fast {
1029+ exit ! ( 1 ) ;
1030+ }
1031+ false
10121032 }
1013- } else {
1014- self . run ( cmd) ;
10151033 }
1016- true
10171034 }
10181035
10191036 pub fn is_verbose_than ( & self , level : usize ) -> bool {
0 commit comments