remove config wrappers of download_toolchain and maybe_download_fmt and during config parsing directly invoke cdownload methods

This commit is contained in:
bit-aloo 2025-07-28 19:23:04 +05:30
parent f63f212a04
commit db42d5b36c
No known key found for this signature in database
2 changed files with 13 additions and 17 deletions

View file

@ -45,7 +45,9 @@ use crate::core::config::{
DebuginfoLevel, DryRun, GccCiMode, LlvmLibunwind, Merge, ReplaceOpt, RustcLto, SplitDebuginfo,
StringOrBool, set, threads_from_config,
};
use crate::core::download::is_download_ci_available;
use crate::core::download::{
DownloadContext, download_beta_toolchain, is_download_ci_available, maybe_download_rustfmt,
};
use crate::utils::channel;
use crate::utils::exec::{ExecutionContext, command};
use crate::utils::helpers::{exe, get_host_target};
@ -801,7 +803,8 @@ impl Config {
}
rustc
} else {
config.download_beta_toolchain();
let dwn_ctx = DownloadContext::from(&config);
download_beta_toolchain(dwn_ctx);
config
.out
.join(config.host_target)
@ -827,7 +830,8 @@ impl Config {
}
cargo
} else {
config.download_beta_toolchain();
let dwn_ctx = DownloadContext::from(&config);
download_beta_toolchain(dwn_ctx);
config.initial_sysroot.join("bin").join(exe("cargo", config.host_target))
};
@ -994,8 +998,12 @@ impl Config {
config.apply_dist_config(toml.dist);
config.initial_rustfmt =
if let Some(r) = rustfmt { Some(r) } else { config.maybe_download_rustfmt() };
config.initial_rustfmt = if let Some(r) = rustfmt {
Some(r)
} else {
let dwn_ctx = DownloadContext::from(&config);
maybe_download_rustfmt(dwn_ctx)
};
if matches!(config.lld_mode, LldMode::SelfContained)
&& !config.lld_enabled

View file

@ -128,13 +128,6 @@ impl Config {
cargo_clippy
}
/// NOTE: rustfmt is a completely different toolchain than the bootstrap compiler, so it can't
/// reuse target directories or artifacts
pub(crate) fn maybe_download_rustfmt(&self) -> Option<PathBuf> {
let dwn_ctx: DownloadContext<'_> = self.into();
maybe_download_rustfmt(dwn_ctx)
}
pub(crate) fn ci_rust_std_contents(&self) -> Vec<String> {
self.ci_component_contents(".rust-std-contents")
}
@ -172,11 +165,6 @@ impl Config {
);
}
pub(crate) fn download_beta_toolchain(&self) {
let dwn_ctx: DownloadContext<'_> = self.into();
download_beta_toolchain(dwn_ctx);
}
fn download_toolchain(
&self,
version: &str,