Rollup merge of #113068 - clubby789:bootstrap-user-to-dist, r=jyn514
bootstrap: rename 'user' profile to 'dist' Fixes #112074 Unfortunately a big chunk of the diff is adding `PartialEq/Eq/Debug` impls so we can `assert_eq` but I think better to have them in the long run. For back compat, ensure `"maintainer"`, `"user"` and `"dist"` are all parsed as `Profile::Dist`. r? `@jyn514` cc `@AnakinSkywalkeer` who worked on the previous attempt at this
This commit is contained in:
commit
1153aba3ec
@ -1052,7 +1052,13 @@ def bootstrap(args):
|
||||
|
||||
profile = RustBuild.get_toml_static(config_toml, 'profile')
|
||||
if profile is not None:
|
||||
include_file = 'config.{}.toml'.format(profile)
|
||||
# Allows creating alias for profile names, allowing
|
||||
# profiles to be renamed while maintaining back compatibility
|
||||
# Keep in sync with `profile_aliases` in config.rs
|
||||
profile_aliases = {
|
||||
"user": "dist"
|
||||
}
|
||||
include_file = 'config.{}.toml'.format(profile_aliases.get(profile) or profile)
|
||||
include_dir = os.path.join(rust_root, 'src', 'bootstrap', 'defaults')
|
||||
include_path = os.path.join(include_dir, include_file)
|
||||
# HACK: This works because `self.get_toml()` returns the first match it finds for a
|
||||
|
@ -98,7 +98,7 @@ class GenerateAndParseConfig(unittest.TestCase):
|
||||
def test_no_args(self):
|
||||
build = serialize_and_parse([])
|
||||
self.assertEqual(build.get_toml("changelog-seen"), '2')
|
||||
self.assertEqual(build.get_toml("profile"), 'user')
|
||||
self.assertEqual(build.get_toml("profile"), 'dist')
|
||||
self.assertIsNone(build.get_toml("llvm.download-ci-llvm"))
|
||||
|
||||
def test_set_section(self):
|
||||
|
@ -1129,6 +1129,14 @@ impl Config {
|
||||
};
|
||||
|
||||
if let Some(include) = &toml.profile {
|
||||
// Allows creating alias for profile names, allowing
|
||||
// profiles to be renamed while maintaining back compatibility
|
||||
// Keep in sync with `profile_aliases` in bootstrap.py
|
||||
let profile_aliases = HashMap::from([("user", "dist")]);
|
||||
let include = match profile_aliases.get(include.as_str()) {
|
||||
Some(alias) => alias,
|
||||
None => include.as_str(),
|
||||
};
|
||||
let mut include_path = config.src.clone();
|
||||
include_path.push("src");
|
||||
include_path.push("bootstrap");
|
||||
|
@ -1,5 +1,8 @@
|
||||
use crate::config::TomlConfig;
|
||||
|
||||
use super::{Config, Flags};
|
||||
use clap::CommandFactory;
|
||||
use serde::Deserialize;
|
||||
use std::{env, path::Path};
|
||||
|
||||
fn parse(config: &str) -> Config {
|
||||
@ -159,3 +162,19 @@ fn override_toml_duplicate() {
|
||||
|&_| toml::from_str("changelog-seen = 0").unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn profile_user_dist() {
|
||||
fn get_toml(file: &Path) -> TomlConfig {
|
||||
let contents = if file.ends_with("config.toml") {
|
||||
"profile = \"user\"".to_owned()
|
||||
} else {
|
||||
assert!(file.ends_with("config.dist.toml"));
|
||||
std::fs::read_to_string(dbg!(file)).unwrap()
|
||||
};
|
||||
toml::from_str(&contents)
|
||||
.and_then(|table: toml::Value| TomlConfig::deserialize(table))
|
||||
.unwrap()
|
||||
}
|
||||
Config::parse_inner(&["check".to_owned()], get_toml);
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ def parse_example_config(known_args, config):
|
||||
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", "'{}'".format(target) if "." in target else target)
|
||||
|
||||
if 'profile' not in config:
|
||||
set('profile', 'user', config)
|
||||
set('profile', 'dist', config)
|
||||
configure_file(sections, top_level_keys, targets, config)
|
||||
return section_order, sections, targets
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub enum Profile {
|
||||
Codegen,
|
||||
Library,
|
||||
Tools,
|
||||
User,
|
||||
Dist,
|
||||
None,
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ impl Profile {
|
||||
pub fn all() -> impl Iterator<Item = Self> {
|
||||
use Profile::*;
|
||||
// N.B. these are ordered by how they are displayed, not alphabetically
|
||||
[Library, Compiler, Codegen, Tools, User, None].iter().copied()
|
||||
[Library, Compiler, Codegen, Tools, Dist, None].iter().copied()
|
||||
}
|
||||
|
||||
pub fn purpose(&self) -> String {
|
||||
@ -53,7 +53,7 @@ impl Profile {
|
||||
Compiler => "Contribute to the compiler itself",
|
||||
Codegen => "Contribute to the compiler, and also modify LLVM or codegen",
|
||||
Tools => "Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)",
|
||||
User => "Install Rust from source",
|
||||
Dist => "Install Rust from source",
|
||||
None => "Do not modify `config.toml`"
|
||||
}
|
||||
.to_string()
|
||||
@ -73,7 +73,7 @@ impl Profile {
|
||||
Profile::Codegen => "codegen",
|
||||
Profile::Library => "library",
|
||||
Profile::Tools => "tools",
|
||||
Profile::User => "user",
|
||||
Profile::Dist => "dist",
|
||||
Profile::None => "none",
|
||||
}
|
||||
}
|
||||
@ -87,7 +87,7 @@ impl FromStr for Profile {
|
||||
"lib" | "library" => Ok(Profile::Library),
|
||||
"compiler" => Ok(Profile::Compiler),
|
||||
"llvm" | "codegen" => Ok(Profile::Codegen),
|
||||
"maintainer" | "user" => Ok(Profile::User),
|
||||
"maintainer" | "dist" | "user" => Ok(Profile::Dist),
|
||||
"tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" | "rls" => {
|
||||
Ok(Profile::Tools)
|
||||
}
|
||||
@ -160,7 +160,7 @@ pub fn setup(config: &Config, profile: Profile) {
|
||||
"test src/tools/rustfmt",
|
||||
],
|
||||
Profile::Library => &["check", "build", "test library/std", "doc"],
|
||||
Profile::User => &["dist", "build"],
|
||||
Profile::Dist => &["dist", "build"],
|
||||
};
|
||||
|
||||
println!();
|
||||
@ -170,7 +170,7 @@ pub fn setup(config: &Config, profile: Profile) {
|
||||
println!("- `x.py {}`", cmd);
|
||||
}
|
||||
|
||||
if profile != Profile::User {
|
||||
if profile != Profile::Dist {
|
||||
println!(
|
||||
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user