@@ -33,6 +33,17 @@ macro_rules! check_ci_llvm {
33
33
} ;
34
34
}
35
35
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
+
36
47
/// Global configuration for the entire build and/or bootstrap.
37
48
///
38
49
/// This structure is derived from a combination of both `config.toml` and
@@ -84,7 +95,7 @@ pub struct Config {
84
95
pub jobs : Option < u32 > ,
85
96
pub cmd : Subcommand ,
86
97
pub incremental : bool ,
87
- pub dry_run : bool ,
98
+ pub dry_run : DryRun ,
88
99
/// `None` if we shouldn't download CI compiler artifacts, or the commit to download if we should.
89
100
#[ cfg( not( test) ) ]
90
101
download_rustc_commit : Option < String > ,
@@ -820,7 +831,7 @@ impl Config {
820
831
config. jobs = flags. jobs . map ( threads_from_config) ;
821
832
config. cmd = flags. cmd ;
822
833
config. incremental = flags. incremental ;
823
- config. dry_run = flags. dry_run ;
834
+ config. dry_run = if flags. dry_run { DryRun :: UserSelected } else { DryRun :: Disabled } ;
824
835
config. keep_stage = flags. keep_stage ;
825
836
config. keep_stage_std = flags. keep_stage_std ;
826
837
config. color = flags. color ;
@@ -965,7 +976,7 @@ impl Config {
965
976
. unwrap_or_else ( || config. out . join ( config. build . triple ) . join ( "stage0/bin/cargo" ) ) ;
966
977
967
978
// NOTE: it's important this comes *after* we set `initial_rustc` just above.
968
- if config. dry_run {
979
+ if config. dry_run ( ) {
969
980
let dir = config. out . join ( "tmp-dry-run" ) ;
970
981
t ! ( fs:: create_dir_all( & dir) ) ;
971
982
config. out = dir;
@@ -1372,6 +1383,13 @@ impl Config {
1372
1383
config
1373
1384
}
1374
1385
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
+
1375
1393
/// A git invocation which runs inside the source directory.
1376
1394
///
1377
1395
/// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
@@ -1461,7 +1479,7 @@ impl Config {
1461
1479
/// This is computed on demand since LLVM might have to first be downloaded from CI.
1462
1480
pub ( crate ) fn llvm_link_shared ( builder : & Builder < ' _ > ) -> bool {
1463
1481
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 ( ) {
1465
1483
// just assume static for now - dynamic linking isn't supported on all platforms
1466
1484
return false ;
1467
1485
}
@@ -1488,7 +1506,7 @@ impl Config {
1488
1506
/// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
1489
1507
pub ( crate ) fn download_rustc ( builder : & Builder < ' _ > ) -> bool {
1490
1508
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 ( ) {
1492
1510
// avoid trying to actually download the commit
1493
1511
return false ;
1494
1512
}
@@ -1507,7 +1525,7 @@ impl Config {
1507
1525
RustfmtState :: SystemToolchain ( p) | RustfmtState :: Downloaded ( p) => Some ( p. clone ( ) ) ,
1508
1526
RustfmtState :: Unavailable => None ,
1509
1527
r @ RustfmtState :: LazyEvaluated => {
1510
- if builder. config . dry_run {
1528
+ if builder. config . dry_run ( ) {
1511
1529
return Some ( PathBuf :: new ( ) ) ;
1512
1530
}
1513
1531
let path = maybe_download_rustfmt ( builder) ;
0 commit comments