Skip to content

Commit 69825df

Browse files
committed
add execution context to config and initialize in flag module
1 parent 42f5288 commit 69825df

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ use crate::core::config::flags::{Color, Flags, Warnings};
3030
use crate::core::download::is_download_ci_available;
3131
use crate::utils::cache::{INTERNER, Interned};
3232
use crate::utils::channel::{self, GitInfo};
33-
use crate::utils::helpers::{self, exe, output, t};
33+
use crate::utils::execution_context::ExecutionContext;
34+
use crate::utils::helpers::{self, exe, t};
3435

3536
/// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic.
3637
/// This means they can be modified and changes to these paths should never trigger a compiler build
@@ -422,6 +423,8 @@ pub struct Config {
422423

423424
/// Cache for determining path modifications
424425
pub path_modification_cache: Arc<Mutex<HashMap<Vec<&'static str>, PathFreshness>>>,
426+
427+
pub execution_context: ExecutionContext,
425428
}
426429

427430
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
@@ -1449,8 +1452,9 @@ impl Config {
14491452
feature = "tracing",
14501453
instrument(target = "CONFIG_HANDLING", level = "trace", name = "Config::parse", skip_all)
14511454
)]
1452-
pub fn parse(flags: Flags) -> Config {
1453-
Self::parse_inner(flags, Self::get_toml)
1455+
pub fn parse(flags: Flags, execution_context: ExecutionContext) -> Config {
1456+
let config = Self::parse_inner(flags, Self::get_toml, execution_context);
1457+
config
14541458
}
14551459

14561460
#[cfg_attr(
@@ -1465,8 +1469,10 @@ impl Config {
14651469
pub(crate) fn parse_inner(
14661470
mut flags: Flags,
14671471
get_toml: impl Fn(&Path) -> Result<TomlConfig, toml::de::Error>,
1472+
execution_context: ExecutionContext,
14681473
) -> Config {
14691474
let mut config = Config::default_opts();
1475+
config.execution_context = execution_context;
14701476

14711477
// Set flags.
14721478
config.paths = std::mem::take(&mut flags.paths);

src/bootstrap/src/core/config/flags.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use crate::core::build_steps::perf::PerfArgs;
1313
use crate::core::build_steps::setup::Profile;
1414
use crate::core::builder::{Builder, Kind};
1515
use crate::core::config::{Config, TargetSelectionList, target_selection_list};
16-
use crate::{Build, DocTests};
16+
use crate::utils::execution_context::ExecutionContext;
17+
use crate::{Build, DocTests, DryRun};
1718

1819
#[derive(Copy, Clone, Default, Debug, ValueEnum)]
1920
pub enum Color {
@@ -203,7 +204,8 @@ impl Flags {
203204
HelpVerboseOnly::try_parse_from(normalize_args(args))
204205
{
205206
println!("NOTE: updating submodules before printing available paths");
206-
let config = Config::parse(Self::parse(&[String::from("build")]));
207+
let (flags, execution_context) = Self::parse(&[String::from("build")]);
208+
let config = Config::parse(flags, execution_context);
207209
let build = Build::new(config);
208210
let paths = Builder::get_help(&build, subcommand);
209211
if let Some(s) = paths {
@@ -221,8 +223,16 @@ impl Flags {
221223
feature = "tracing",
222224
instrument(level = "trace", name = "Flags::parse", skip_all, fields(args = ?args))
223225
)]
224-
pub fn parse(args: &[String]) -> Self {
225-
Flags::parse_from(normalize_args(args))
226+
pub fn parse(args: &[String]) -> (Self, ExecutionContext) {
227+
let mut execution_context = ExecutionContext::new();
228+
let flags = Flags::parse_from(normalize_args(args));
229+
execution_context.set_dry_run(if flags.dry_run {
230+
DryRun::UserSelected
231+
} else {
232+
DryRun::Disabled
233+
});
234+
execution_context.set_verbose(flags.verbose);
235+
(flags, execution_context)
226236
}
227237
}
228238

0 commit comments

Comments
 (0)