@@ -33,6 +33,17 @@ macro_rules! check_ci_llvm {
3333 } ;
3434}
3535
36+ #[ derive( Clone , Default ) ]
37+ pub enum DryRun {
38+ /// This isn't a dry run.
39+ #[ default]
40+ Disabled ,
41+ /// This is a dry run enabled by bootstrap itself, so it can verify that no work is done.
42+ SelfCheck ,
43+ /// This is a dry run enabled by the `--dry-run` flag.
44+ UserSelected ,
45+ }
46+
3647/// Global configuration for the entire build and/or bootstrap.
3748///
3849/// This structure is derived from a combination of both `config.toml` and
@@ -84,7 +95,7 @@ pub struct Config {
8495 pub jobs : Option < u32 > ,
8596 pub cmd : Subcommand ,
8697 pub incremental : bool ,
87- pub dry_run : bool ,
98+ pub dry_run : DryRun ,
8899 /// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
89100 #[ cfg( not( test) ) ]
90101 download_rustc_commit : Option < String > ,
@@ -820,7 +831,7 @@ impl Config {
820831 config. jobs = flags. jobs . map ( threads_from_config) ;
821832 config. cmd = flags. cmd ;
822833 config. incremental = flags. incremental ;
823- config. dry_run = flags. dry_run ;
834+ config. dry_run = if flags. dry_run { DryRun :: UserSelected } else { DryRun :: Disabled } ;
824835 config. keep_stage = flags. keep_stage ;
825836 config. keep_stage_std = flags. keep_stage_std ;
826837 config. color = flags. color ;
@@ -965,7 +976,7 @@ impl Config {
965976 . unwrap_or_else ( || config. out . join ( config. build . triple ) . join ( "stage0/bin/cargo" ) ) ;
966977
967978 // NOTE: it's important this comes *after* we set `initial_rustc` just above.
968- if config. dry_run {
979+ if config. dry_run ( ) {
969980 let dir = config. out . join ( "tmp-dry-run" ) ;
970981 t ! ( fs:: create_dir_all( & dir) ) ;
971982 config. out = dir;
@@ -1372,6 +1383,13 @@ impl Config {
13721383 config
13731384 }
13741385
1386+ pub ( crate ) fn dry_run ( & self ) -> bool {
1387+ match self . dry_run {
1388+ DryRun :: Disabled => false ,
1389+ DryRun :: SelfCheck | DryRun :: UserSelected => true ,
1390+ }
1391+ }
1392+
13751393 /// A git invocation which runs inside the source directory.
13761394 ///
13771395 /// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
@@ -1461,7 +1479,7 @@ impl Config {
14611479 /// This is computed on demand since LLVM might have to first be downloaded from CI.
14621480 pub ( crate ) fn llvm_link_shared ( builder : & Builder < ' _ > ) -> bool {
14631481 let mut opt = builder. config . llvm_link_shared . get ( ) ;
1464- if opt. is_none ( ) && builder. config . dry_run {
1482+ if opt. is_none ( ) && builder. config . dry_run ( ) {
14651483 // just assume static for now - dynamic linking isn't supported on all platforms
14661484 return false ;
14671485 }
@@ -1488,7 +1506,7 @@ impl Config {
14881506 /// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
14891507 pub ( crate ) fn download_rustc ( builder : & Builder < ' _ > ) -> bool {
14901508 static DOWNLOAD_RUSTC : OnceCell < bool > = OnceCell :: new ( ) ;
1491- if builder. config . dry_run && DOWNLOAD_RUSTC . get ( ) . is_none ( ) {
1509+ if builder. config . dry_run ( ) && DOWNLOAD_RUSTC . get ( ) . is_none ( ) {
14921510 // avoid trying to actually download the commit
14931511 return false ;
14941512 }
@@ -1507,7 +1525,7 @@ impl Config {
15071525 RustfmtState :: SystemToolchain ( p) | RustfmtState :: Downloaded ( p) => Some ( p. clone ( ) ) ,
15081526 RustfmtState :: Unavailable => None ,
15091527 r @ RustfmtState :: LazyEvaluated => {
1510- if builder. config . dry_run {
1528+ if builder. config . dry_run ( ) {
15111529 return Some ( PathBuf :: new ( ) ) ;
15121530 }
15131531 let path = maybe_download_rustfmt ( builder) ;
0 commit comments