Rollup merge of #136467 - onur-ozkan:override-default-profile-on-tarballs, r=jieyouxu

override default config profile on tarballs

This is the same logic used in the Python script 613bdd4997/src/bootstrap/bootstrap.py (L1273-L1274)
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2025-02-03 19:13:30 +08:00 committed by GitHub
commit f65c6afcec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -700,7 +700,7 @@ trait Merge {
impl Merge for TomlConfig {
fn merge(
&mut self,
TomlConfig { build, install, llvm, rust, dist, target, profile: _, change_id }: Self,
TomlConfig { build, install, llvm, rust, dist, target, profile, change_id }: Self,
replace: ReplaceOpt,
) {
fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>, replace: ReplaceOpt) {
@ -712,7 +712,10 @@ impl Merge for TomlConfig {
}
}
}
self.change_id.inner.merge(change_id.inner, replace);
self.profile.merge(profile, replace);
do_merge(&mut self.build, build, replace);
do_merge(&mut self.install, install, replace);
do_merge(&mut self.llvm, llvm, replace);
@ -1505,6 +1508,10 @@ impl Config {
build.cargo = build.cargo.take().or(std::env::var_os("CARGO").map(|p| p.into()));
}
if GitInfo::new(false, &config.src).is_from_tarball() && toml.profile.is_none() {
toml.profile = Some("dist".into());
}
if let Some(include) = &toml.profile {
// Allows creating alias for profile names, allowing
// profiles to be renamed while maintaining back compatibility