@@ -28,16 +28,21 @@ use std::str;
28
28
29
29
use build_helper:: ci:: { gha, CiEnv } ;
30
30
use build_helper:: exit;
31
- use channel:: GitInfo ;
32
- use config:: { DryRun , Target } ;
33
31
use filetime:: FileTime ;
34
32
use once_cell:: sync:: OnceCell ;
33
+ use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
34
+
35
+ use channel:: GitInfo ;
36
+ use config:: { DryRun , Target } ;
35
37
36
38
use crate :: builder:: Kind ;
39
+ pub use crate :: builder:: PathSet ;
40
+ use crate :: cache:: { Interned , INTERNER } ;
41
+ pub use crate :: config:: Config ;
37
42
use crate :: config:: { LlvmLibunwind , TargetSelection } ;
38
- use crate :: util :: {
39
- dir_is_empty , exe , libdir , mtime , output , run , run_suppressed , symlink_dir , try_run_suppressed ,
40
- } ;
43
+ use crate :: exec :: { BehaviorOnFailure , BootstrapCommand } ;
44
+ pub use crate :: flags :: Subcommand ;
45
+ use crate :: util :: { dir_is_empty , exe , libdir , mtime , output , run , symlink_dir } ;
41
46
42
47
mod builder;
43
48
mod cache;
@@ -88,13 +93,6 @@ mod job {
88
93
pub unsafe fn setup ( _build : & mut crate :: Build ) { }
89
94
}
90
95
91
- pub use crate :: builder:: PathSet ;
92
- use crate :: cache:: { Interned , INTERNER } ;
93
- pub use crate :: config:: Config ;
94
- use crate :: exec:: BootstrapCommand ;
95
- pub use crate :: flags:: Subcommand ;
96
- use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
97
-
98
96
const LLVM_TOOLS : & [ & str ] = & [
99
97
"llvm-cov" , // used to generate coverage report
100
98
"llvm-nm" , // used to inspect binaries; it shows symbol names, their sizes and visibility
@@ -967,44 +965,30 @@ impl Build {
967
965
968
966
/// Runs a command, printing out nice contextual information if it fails.
969
967
fn run ( & self , cmd : & mut Command ) {
970
- if self . config . dry_run ( ) {
971
- return ;
972
- }
973
- self . verbose ( & format ! ( "running: {cmd:?}" ) ) ;
974
- run ( cmd, self . is_verbose ( ) )
968
+ // FIXME: output mode -> status + err if self.is_verbose()
969
+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
970
+ self . run_cmd ( cmd. fail_fast ( ) ) ;
975
971
}
976
972
977
973
/// Runs a command, printing out nice contextual information if it fails.
978
974
fn run_quiet ( & self , cmd : & mut Command ) {
979
- if self . config . dry_run ( ) {
980
- return ;
981
- }
982
- self . verbose ( & format ! ( "running: {cmd:?}" ) ) ;
983
- run_suppressed ( cmd)
975
+ // FIXME: output mode -> output + err
976
+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
977
+ self . run_cmd ( cmd. fail_fast ( ) ) ;
984
978
}
985
979
986
980
/// Runs a command, printing out nice contextual information if it fails.
987
981
/// Exits if the command failed to execute at all, otherwise returns its
988
982
/// `status.success()`.
989
983
fn run_quiet_delaying_failure ( & self , cmd : & mut Command ) -> bool {
990
- if self . config . dry_run ( ) {
991
- return true ;
992
- }
993
- if !self . fail_fast {
994
- self . verbose ( & format ! ( "running: {cmd:?}" ) ) ;
995
- if !try_run_suppressed ( cmd) {
996
- let mut failures = self . delayed_failures . borrow_mut ( ) ;
997
- failures. push ( format ! ( "{cmd:?}" ) ) ;
998
- return false ;
999
- }
1000
- } else {
1001
- self . run_quiet ( cmd) ;
1002
- }
1003
- true
984
+ // FIXME: output mode -> output + err
985
+ let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
986
+ self . run_cmd ( cmd. delay_failure ( ) )
1004
987
}
1005
988
1006
989
/// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
1007
990
pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
991
+ // FIXME: output mode -> status + err if self.is_verbose()
1008
992
let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
1009
993
self . run_cmd ( cmd. delay_failure ( ) )
1010
994
}
@@ -1020,10 +1004,16 @@ impl Build {
1020
1004
match result {
1021
1005
Ok ( _) => true ,
1022
1006
Err ( _) => {
1023
- if command. delay_failure {
1024
- let mut failures = self . delayed_failures . borrow_mut ( ) ;
1025
- failures. push ( format ! ( "{command:?}" ) ) ;
1026
- return false ;
1007
+ if let Some ( failure_behavior) = command. failure_behavior {
1008
+ match failure_behavior {
1009
+ BehaviorOnFailure :: DelayFail => {
1010
+ let mut failures = self . delayed_failures . borrow_mut ( ) ;
1011
+ failures. push ( format ! ( "{command:?}" ) ) ;
1012
+ }
1013
+ BehaviorOnFailure :: Exit => {
1014
+ exit ! ( 1 ) ;
1015
+ }
1016
+ }
1027
1017
}
1028
1018
if self . fail_fast {
1029
1019
exit ! ( 1 ) ;
0 commit comments