@@ -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 ;
@@ -964,7 +975,7 @@ impl Config {
964
975
. unwrap_or_else ( || config. out . join ( config. build . triple ) . join ( "stage0/bin/cargo" ) ) ;
965
976
966
977
// NOTE: it's important this comes *after* we set `initial_rustc` just above.
967
- if config. dry_run {
978
+ if config. dry_run ( ) {
968
979
let dir = config. out . join ( "tmp-dry-run" ) ;
969
980
t ! ( fs:: create_dir_all( & dir) ) ;
970
981
config. out = dir;
@@ -1371,6 +1382,13 @@ impl Config {
1371
1382
config
1372
1383
}
1373
1384
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
+
1374
1392
/// A git invocation which runs inside the source directory.
1375
1393
///
1376
1394
/// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
@@ -1460,7 +1478,7 @@ impl Config {
1460
1478
/// This is computed on demand since LLVM might have to first be downloaded from CI.
1461
1479
pub ( crate ) fn llvm_link_shared ( builder : & Builder < ' _ > ) -> bool {
1462
1480
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 ( ) {
1464
1482
// just assume static for now - dynamic linking isn't supported on all platforms
1465
1483
return false ;
1466
1484
}
@@ -1487,7 +1505,7 @@ impl Config {
1487
1505
/// Return whether we will use a downloaded, pre-compiled version of rustc, or just build from source.
1488
1506
pub ( crate ) fn download_rustc ( builder : & Builder < ' _ > ) -> bool {
1489
1507
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 ( ) {
1491
1509
// avoid trying to actually download the commit
1492
1510
return false ;
1493
1511
}
@@ -1506,7 +1524,7 @@ impl Config {
1506
1524
RustfmtState :: SystemToolchain ( p) | RustfmtState :: Downloaded ( p) => Some ( p. clone ( ) ) ,
1507
1525
RustfmtState :: Unavailable => None ,
1508
1526
r @ RustfmtState :: LazyEvaluated => {
1509
- if builder. config . dry_run {
1527
+ if builder. config . dry_run ( ) {
1510
1528
return Some ( PathBuf :: new ( ) ) ;
1511
1529
}
1512
1530
let path = maybe_download_rustfmt ( builder) ;
0 commit comments