Skip to content

Commit a75326b

Browse files
committed
move build config to the top of parse method
1 parent 2c96132 commit a75326b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -487,17 +487,6 @@ impl Config {
487487
&get_toml,
488488
);
489489

490-
if cfg!(test) {
491-
// When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
492-
// same ones used to call the tests (if custom ones are not defined in the toml). If we
493-
// don't do that, bootstrap will use its own detection logic to find a suitable rustc
494-
// and Cargo, which doesn't work when the caller is specìfying a custom local rustc or
495-
// Cargo in their bootstrap.toml.
496-
let build = toml.build.get_or_insert_with(Default::default);
497-
build.rustc = build.rustc.take().or(std::env::var_os("RUSTC").map(|p| p.into()));
498-
build.cargo = build.cargo.take().or(std::env::var_os("CARGO").map(|p| p.into()));
499-
}
500-
501490
// Now override TOML values with flags, to make sure that we won't later override flags with
502491
// TOML values by accident instead, because flags have higher priority.
503492
let Build {
@@ -507,7 +496,7 @@ impl Config {
507496
target: build_target_toml,
508497
build_dir: build_build_dir_toml,
509498
cargo: build_cargo_toml,
510-
rustc: build_rustc_toml,
499+
rustc: mut build_rustc_toml,
511500
rustfmt: build_rustfmt_toml,
512501
cargo_clippy: build_cargo_clippy_toml,
513502
docs: build_docs_toml,
@@ -556,8 +545,20 @@ impl Config {
556545
ccache: build_ccache_toml,
557546
exclude: build_exclude_toml,
558547
} = toml.build.unwrap_or_default();
548+
549+
if cfg!(test) {
550+
// When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
551+
// same ones used to call the tests (if custom ones are not defined in the toml). If we
552+
// don't do that, bootstrap will use its own detection logic to find a suitable rustc
553+
// and Cargo, which doesn't work when the caller is specìfying a custom local rustc or
554+
// Cargo in their bootstrap.toml.
555+
build_rustc_toml = build_rustc_toml.take().or(std::env::var_os("RUSTC").map(|p| p.into()));
556+
build_build_toml = build_build_toml.take().or(std::env::var_os("CARGO").map(|p| p.into_string().unwrap()));
557+
}
558+
559559
build_jobs_toml = flags_jobs.or(build_jobs_toml);
560560
build_build_toml = flags_build.or(build_build_toml);
561+
561562
let build_dir = flags_build_dir.or(build_build_dir_toml.map(PathBuf::from));
562563
let host = if let Some(TargetSelectionList(hosts)) = flags_host {
563564
Some(hosts)

0 commit comments

Comments
 (0)