Skip to content

Commit 83d5b07

Browse files
committed
move few complex initialization from config to parse-inner
1 parent 433dc2b commit 83d5b07

File tree

1 file changed

+60
-48
lines changed

1 file changed

+60
-48
lines changed

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

Lines changed: 60 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,14 +1088,64 @@ impl Config {
10881088
)
10891089
};
10901090

1091+
let ccache = match build_ccache {
1092+
Some(StringOrBool::String(s)) => Some(s),
1093+
Some(StringOrBool::Bool(true)) => Some("ccache".to_string()),
1094+
_ => None,
1095+
};
1096+
1097+
let explicit_stage_from_config = build_test_stage.is_some()
1098+
|| build_build_stage.is_some()
1099+
|| build_doc_stage.is_some()
1100+
|| build_dist_stage.is_some()
1101+
|| build_install_stage.is_some()
1102+
|| build_check_stage.is_some()
1103+
|| build_bench_stage.is_some();
1104+
1105+
let deny_warnings = match flags_warnings {
1106+
Warnings::Deny => true,
1107+
Warnings::Warn => false,
1108+
Warnings::Default => rust_deny_warnings.unwrap_or(true),
1109+
};
1110+
1111+
let gcc_ci_mode = match gcc_download_ci_gcc {
1112+
Some(value) => match value {
1113+
true => GccCiMode::DownloadFromCi,
1114+
false => GccCiMode::BuildLocally,
1115+
},
1116+
None => GccCiMode::default(),
1117+
};
1118+
1119+
let targets = flags_target
1120+
.map(|TargetSelectionList(targets)| targets)
1121+
.or_else(|| {
1122+
build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect())
1123+
})
1124+
.unwrap_or_else(|| hosts.clone());
1125+
1126+
#[allow(clippy::map_identity)]
1127+
let skip = flags_skip
1128+
.into_iter()
1129+
.chain(flags_exclude)
1130+
.chain(build_exclude.unwrap_or_default())
1131+
.map(|p| {
1132+
// Never return top-level path here as it would break `--skip`
1133+
// logic on rustc's internal test framework which is utilized by compiletest.
1134+
#[cfg(windows)]
1135+
{
1136+
PathBuf::from(p.to_string_lossy().replace('/', "\\"))
1137+
}
1138+
#[cfg(not(windows))]
1139+
{
1140+
p
1141+
}
1142+
})
1143+
.collect();
1144+
10911145
Config {
10921146
change_id: toml.change_id.inner,
10931147
bypass_bootstrap_lock: flags_bypass_bootstrap_lock,
1094-
ccache: match build_ccache {
1095-
Some(StringOrBool::String(s)) => Some(s),
1096-
Some(StringOrBool::Bool(true)) => Some("ccache".to_string()),
1097-
_ => None,
1098-
},
1148+
ccache,
10991149
ninja_in_file: llvm_ninja.unwrap_or(true),
11001150
compiler_docs: build_compiler_docs.unwrap_or(false),
11011151
library_docs_private_items: build_library_docs_private_items.unwrap_or(false),
@@ -1122,25 +1172,15 @@ impl Config {
11221172
stderr_is_tty: std::io::stderr().is_terminal(),
11231173
on_fail: flags_on_fail,
11241174
explicit_stage_from_cli: flags_stage.is_some(),
1125-
explicit_stage_from_config: build_test_stage.is_some()
1126-
|| build_build_stage.is_some()
1127-
|| build_doc_stage.is_some()
1128-
|| build_dist_stage.is_some()
1129-
|| build_install_stage.is_some()
1130-
|| build_check_stage.is_some()
1131-
|| build_bench_stage.is_some(),
1175+
explicit_stage_from_config,
11321176

11331177
keep_stage: flags_keep_stage,
11341178
keep_stage_std: flags_keep_stage_std,
11351179
jobs: Some(threads_from_config(flags_jobs.or(build_jobs).unwrap_or(0))),
11361180
incremental: flags_incremental || rust_incremental == Some(true),
11371181
dump_bootstrap_shims: flags_dump_bootstrap_shims,
11381182
free_args: flags_free_args,
1139-
deny_warnings: match flags_warnings {
1140-
Warnings::Deny => true,
1141-
Warnings::Warn => false,
1142-
Warnings::Default => rust_deny_warnings.unwrap_or(true),
1143-
},
1183+
deny_warnings,
11441184
backtrace_on_ice: rust_backtrace_on_ice.unwrap_or(false),
11451185
llvm_tests: llvm_tests.unwrap_or(false),
11461186
llvm_enzyme: llvm_enzyme.unwrap_or(false),
@@ -1167,13 +1207,7 @@ impl Config {
11671207
llvm_cxxflags,
11681208
llvm_ldflags,
11691209
llvm_use_libcxx: llvm_use_libcxx.unwrap_or(false),
1170-
gcc_ci_mode: match gcc_download_ci_gcc {
1171-
Some(value) => match value {
1172-
true => GccCiMode::DownloadFromCi,
1173-
false => GccCiMode::BuildLocally,
1174-
},
1175-
None => GccCiMode::default(),
1176-
},
1210+
gcc_ci_mode,
11771211
rust_optimize: rust_optimize.unwrap_or(RustOptimize::Bool(true)),
11781212
rust_codegen_units: rust_codegen_units.map(threads_from_config),
11791213
rust_codegen_units_std: rust_codegen_units_std.map(threads_from_config),
@@ -1278,30 +1312,8 @@ impl Config {
12781312
// If we're building from git or tarball sources, enable it by default.
12791313
rust_info.is_managed_git_subrepository() || rust_info.is_from_tarball()
12801314
}),
1281-
targets: flags_target
1282-
.map(|TargetSelectionList(targets)| targets)
1283-
.or_else(|| {
1284-
build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect())
1285-
})
1286-
.unwrap_or_else(|| hosts.clone()),
1287-
#[allow(clippy::map_identity)]
1288-
skip: flags_skip
1289-
.into_iter()
1290-
.chain(flags_exclude)
1291-
.chain(build_exclude.unwrap_or_default())
1292-
.map(|p| {
1293-
// Never return top-level path here as it would break `--skip`
1294-
// logic on rustc's internal test framework which is utilized by compiletest.
1295-
#[cfg(windows)]
1296-
{
1297-
PathBuf::from(p.to_string_lossy().replace('/', "\\"))
1298-
}
1299-
#[cfg(not(windows))]
1300-
{
1301-
p
1302-
}
1303-
})
1304-
.collect(),
1315+
targets,
1316+
skip,
13051317
paths: flags_paths,
13061318
config: toml_path,
13071319
llvm_thin_lto: llvm_thin_lto.unwrap_or(false),

0 commit comments

Comments
 (0)