@@ -50,6 +50,7 @@ mod config;
50
50
mod dist;
51
51
mod doc;
52
52
mod download;
53
+ mod exec;
53
54
mod flags;
54
55
mod format;
55
56
mod install;
@@ -90,6 +91,7 @@ mod job {
90
91
pub use crate :: builder:: PathSet ;
91
92
use crate :: cache:: { Interned , INTERNER } ;
92
93
pub use crate :: config:: Config ;
94
+ use crate :: exec:: BootstrapCommand ;
93
95
pub use crate :: flags:: Subcommand ;
94
96
use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
95
97
@@ -1003,17 +1005,32 @@ impl Build {
1003
1005
1004
1006
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
1005
1007
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
1012
1032
}
1013
- } else {
1014
- self . run ( cmd) ;
1015
1033
}
1016
- true
1017
1034
}
1018
1035
1019
1036
pub fn is_verbose_than ( & self , level : usize ) -> bool {
0 commit comments