Skip to content

Commit 595ecf7

Browse files
committed
more refactor
1 parent de82703 commit 595ecf7

File tree

1 file changed

+62
-75
lines changed

1 file changed

+62
-75
lines changed

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

Lines changed: 62 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,18 @@ impl Config {
682682
.or(build_build)
683683
.map(|build| TargetSelection::from_user(&build))
684684
.unwrap_or_else(get_host_target);
685+
let hosts = flags_host
686+
.map(|TargetSelectionList(hosts)| hosts)
687+
.or_else(|| {
688+
build_host.map(|h| h.iter().map(|t| TargetSelection::from_user(t)).collect())
689+
})
690+
.unwrap_or_else(|| vec![host_target]);
691+
let targets = flags_target
692+
.map(|TargetSelectionList(targets)| targets)
693+
.or_else(|| {
694+
build_target.map(|t| t.iter().map(|t| TargetSelection::from_user(t)).collect())
695+
})
696+
.unwrap_or_else(|| hosts.clone());
685697

686698
let submodules = build_submodules;
687699
let llvm_assertions = llvm_assertions_.unwrap_or(false);
@@ -723,29 +735,13 @@ impl Config {
723735
out = absolute(&out).expect("can't make empty path absolute");
724736
}
725737

726-
let host_ = if let Some(TargetSelectionList(hosts)) = flags_host {
727-
Some(hosts)
728-
} else {
729-
build_host
730-
.map(|file_host| file_host.iter().map(|h| TargetSelection::from_user(h)).collect())
731-
};
732-
let target_ = if let Some(TargetSelectionList(targets)) = flags_target {
733-
Some(targets)
734-
} else {
735-
build_target.map(|file_target| {
736-
file_target.iter().map(|h| TargetSelection::from_user(h)).collect()
737-
})
738-
};
739-
740-
if let Some(rustc) = &build_rustc
741-
&& !flags_skip_stage0_validation
742-
{
743-
check_stage0_version(rustc, "rustc", &src, &exec_ctx);
744-
}
745-
if let Some(cargo) = &build_cargo
746-
&& !flags_skip_stage0_validation
747-
{
748-
check_stage0_version(cargo, "cargo", &src, &exec_ctx);
738+
if !flags_skip_stage0_validation {
739+
if let Some(rustc) = &build_rustc {
740+
check_stage0_version(rustc, "rustc", &src, &exec_ctx);
741+
}
742+
if let Some(cargo) = &build_cargo {
743+
check_stage0_version(cargo, "cargo", &src, &exec_ctx);
744+
}
749745
}
750746

751747
let mut paths_: Vec<PathBuf> = flags_skip.into_iter().chain(flags_exclude).collect();
@@ -846,15 +842,6 @@ impl Config {
846842
out = dir;
847843
}
848844

849-
let hosts = if let Some(hosts) = host_ { hosts } else { vec![host_target] };
850-
let targets = if let Some(targets) = target_ {
851-
targets
852-
} else {
853-
// If target is *not* configured, then default to the host
854-
// toolchains.
855-
hosts.clone()
856-
};
857-
858845
let file_content = t!(fs::read_to_string(src.join("src/ci/channel")));
859846
let ci_channel = file_content.trim_end();
860847

@@ -1314,49 +1301,6 @@ impl Config {
13141301
};
13151302

13161303
Config {
1317-
out,
1318-
rust_info,
1319-
cargo_info,
1320-
rust_analyzer_info,
1321-
clippy_info,
1322-
miri_info,
1323-
rustfmt_info,
1324-
enzyme_info,
1325-
in_tree_llvm_info,
1326-
in_tree_gcc_info,
1327-
initial_cargo,
1328-
initial_rustc,
1329-
initial_cargo_clippy,
1330-
initial_sysroot,
1331-
initial_rustfmt,
1332-
submodules,
1333-
paths: flags_paths,
1334-
vendor,
1335-
target_config,
1336-
omit_git_hash,
1337-
skip,
1338-
stage,
1339-
src,
1340-
config,
1341-
cmd,
1342-
llvm_from_ci,
1343-
llvm_assertions,
1344-
lld_mode,
1345-
lld_enabled,
1346-
rust_overflow_checks,
1347-
host_target,
1348-
hosts,
1349-
targets,
1350-
dist_vendor,
1351-
channel,
1352-
is_running_on_ci,
1353-
path_modification_cache,
1354-
patch_binaries_for_nix,
1355-
stage0_metadata,
1356-
download_rustc_commit,
1357-
llvm_thin_lto,
1358-
llvm_link_shared,
1359-
rustc_debug_assertions,
13601304
change_id: toml.change_id.inner,
13611305
bypass_bootstrap_lock: flags_bypass_bootstrap_lock,
13621306
ccache: match build_ccache {
@@ -1521,6 +1465,49 @@ impl Config {
15211465
tidy_extra_checks: build_tidy_extra_checks,
15221466
skip_std_check_if_no_download_rustc: flags_skip_std_check_if_no_download_rustc,
15231467
exec_ctx,
1468+
out,
1469+
rust_info,
1470+
cargo_info,
1471+
rust_analyzer_info,
1472+
clippy_info,
1473+
miri_info,
1474+
rustfmt_info,
1475+
enzyme_info,
1476+
in_tree_llvm_info,
1477+
in_tree_gcc_info,
1478+
initial_cargo,
1479+
initial_rustc,
1480+
initial_cargo_clippy,
1481+
initial_sysroot,
1482+
initial_rustfmt,
1483+
submodules,
1484+
paths: flags_paths,
1485+
vendor,
1486+
target_config,
1487+
omit_git_hash,
1488+
skip,
1489+
stage,
1490+
src,
1491+
config,
1492+
cmd,
1493+
llvm_from_ci,
1494+
llvm_assertions,
1495+
lld_mode,
1496+
lld_enabled,
1497+
rust_overflow_checks,
1498+
host_target,
1499+
hosts,
1500+
targets,
1501+
dist_vendor,
1502+
channel,
1503+
is_running_on_ci,
1504+
path_modification_cache,
1505+
patch_binaries_for_nix,
1506+
stage0_metadata,
1507+
download_rustc_commit,
1508+
llvm_thin_lto,
1509+
llvm_link_shared,
1510+
rustc_debug_assertions,
15241511
}
15251512
}
15261513

0 commit comments

Comments
 (0)