@@ -28,16 +28,21 @@ use std::str;
2828
2929use build_helper:: ci:: { gha, CiEnv } ;
3030use build_helper:: exit;
31- use channel:: GitInfo ;
32- use config:: { DryRun , Target } ;
3331use filetime:: FileTime ;
3432use once_cell:: sync:: OnceCell ;
33+ use termcolor:: { ColorChoice , StandardStream , WriteColor } ;
34+
35+ use channel:: GitInfo ;
36+ use config:: { DryRun , Target } ;
3537
3638use crate :: builder:: Kind ;
39+ pub use crate :: builder:: PathSet ;
40+ use crate :: cache:: { Interned , INTERNER } ;
41+ pub use crate :: config:: Config ;
3742use 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 } ;
4146
4247mod builder;
4348mod cache;
@@ -88,13 +93,6 @@ mod job {
8893 pub unsafe fn setup ( _build : & mut crate :: Build ) { }
8994}
9095
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-
9896const LLVM_TOOLS : & [ & str ] = & [
9997 "llvm-cov" , // used to generate coverage report
10098 "llvm-nm" , // used to inspect binaries; it shows symbol names, their sizes and visibility
@@ -967,44 +965,30 @@ impl Build {
967965
968966 /// Runs a command, printing out nice contextual information if it fails.
969967 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 ( ) ) ;
975971 }
976972
977973 /// Runs a command, printing out nice contextual information if it fails.
978974 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 ( ) ) ;
984978 }
985979
986980 /// Runs a command, printing out nice contextual information if it fails.
987981 /// Exits if the command failed to execute at all, otherwise returns its
988982 /// `status.success()`.
989983 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 ( ) )
1004987 }
1005988
1006989 /// Runs a command, printing out contextual info if it fails, and delaying errors until the build finishes.
1007990 pub ( crate ) fn run_delaying_failure ( & self , cmd : & mut Command ) -> bool {
991+ // FIXME: output mode -> status + err if self.is_verbose()
1008992 let cmd: BootstrapCommand < ' _ > = cmd. into ( ) ;
1009993 self . run_cmd ( cmd. delay_failure ( ) )
1010994 }
@@ -1020,10 +1004,16 @@ impl Build {
10201004 match result {
10211005 Ok ( _) => true ,
10221006 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+ }
10271017 }
10281018 if self . fail_fast {
10291019 exit ! ( 1 ) ;
0 commit comments