@@ -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 ;
@@ -964,7 +975,7 @@ impl Config {
964975 . unwrap_or_else ( || config. out . join ( config. build . triple ) . join ( "stage0/bin/cargo" ) ) ;
965976
966977 // NOTE: it's important this comes *after* we set `initial_rustc` just above.
967- if config. dry_run {
978+ if config. dry_run ( ) {
968979 let dir = config. out . join ( "tmp-dry-run" ) ;
969980 t ! ( fs:: create_dir_all( & dir) ) ;
970981 config. out = dir;
@@ -1371,6 +1382,13 @@ impl Config {
13711382 config
13721383 }
13731384
1385+ pub ( crate ) fn dry_run ( & self ) -> bool {
1386+ match self . dry_run {
1387+ DryRun :: Disabled => false ,
1388+ DryRun :: SelfCheck | DryRun :: UserSelected => true ,
1389+ }
1390+ }
1391+
13741392 /// A git invocation which runs inside the source directory.
13751393 ///
13761394 /// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
@@ -1460,7 +1478,7 @@ impl Config {
14601478 /// This is computed on demand since LLVM might have to first be downloaded from CI.
14611479 pub ( crate ) fn llvm_link_shared ( builder : & Builder < ' _ > ) -> bool {
14621480 let mut opt = builder. config . llvm_link_shared . get ( ) ;
1463- if opt. is_none ( ) && builder. config . dry_run {
1481+ if opt. is_none ( ) && builder. config . dry_run ( ) {
14641482 // just assume static for now - dynamic linking isn't supported on all platforms
14651483 return false ;
14661484 }
@@ -1487,7 +1505,7 @@ impl Config {
14871505 /// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
14881506 pub ( crate ) fn download_rustc ( builder : & Builder < ' _ > ) -> bool {
14891507 static DOWNLOAD_RUSTC : OnceCell < bool > = OnceCell :: new ( ) ;
1490- if builder. config . dry_run && DOWNLOAD_RUSTC . get ( ) . is_none ( ) {
1508+ if builder. config . dry_run ( ) && DOWNLOAD_RUSTC . get ( ) . is_none ( ) {
14911509 // avoid trying to actually download the commit
14921510 return false ;
14931511 }
@@ -1506,7 +1524,7 @@ impl Config {
15061524 RustfmtState :: SystemToolchain ( p) | RustfmtState :: Downloaded ( p) => Some ( p. clone ( ) ) ,
15071525 RustfmtState :: Unavailable => None ,
15081526 r @ RustfmtState :: LazyEvaluated => {
1509- if builder. config . dry_run {
1527+ if builder. config . dry_run ( ) {
15101528 return Some ( PathBuf :: new ( ) ) ;
15111529 }
15121530 let path = maybe_download_rustfmt ( builder) ;
0 commit comments