Skip to content

Commit 1153aba

Browse files
authored
Rollup merge of rust-lang#113068 - clubby789:bootstrap-user-to-dist, r=jyn514
bootstrap: rename 'user' profile to 'dist' Fixes rust-lang#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
2 parents e992895 + 85c4ea0 commit 1153aba

File tree

7 files changed

+43
-10
lines changed

7 files changed

+43
-10
lines changed

src/bootstrap/bootstrap.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,13 @@ def bootstrap(args):
10521052

10531053
profile = RustBuild.get_toml_static(config_toml, 'profile')
10541054
if profile is not None:
1055-
include_file = 'config.{}.toml'.format(profile)
1055+
# Allows creating alias for profile names, allowing
1056+
# profiles to be renamed while maintaining back compatibility
1057+
# Keep in sync with `profile_aliases` in config.rs
1058+
profile_aliases = {
1059+
"user": "dist"
1060+
}
1061+
include_file = 'config.{}.toml'.format(profile_aliases.get(profile) or profile)
10561062
include_dir = os.path.join(rust_root, 'src', 'bootstrap', 'defaults')
10571063
include_path = os.path.join(include_dir, include_file)
10581064
# HACK: This works because `self.get_toml()` returns the first match it finds for a

src/bootstrap/bootstrap_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class GenerateAndParseConfig(unittest.TestCase):
9898
def test_no_args(self):
9999
build = serialize_and_parse([])
100100
self.assertEqual(build.get_toml("changelog-seen"), '2')
101-
self.assertEqual(build.get_toml("profile"), 'user')
101+
self.assertEqual(build.get_toml("profile"), 'dist')
102102
self.assertIsNone(build.get_toml("llvm.download-ci-llvm"))
103103

104104
def test_set_section(self):

src/bootstrap/config.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,14 @@ impl Config {
11291129
};
11301130

11311131
if let Some(include) = &toml.profile {
1132+
// Allows creating alias for profile names, allowing
1133+
// profiles to be renamed while maintaining back compatibility
1134+
// Keep in sync with `profile_aliases` in bootstrap.py
1135+
let profile_aliases = HashMap::from([("user", "dist")]);
1136+
let include = match profile_aliases.get(include.as_str()) {
1137+
Some(alias) => alias,
1138+
None => include.as_str(),
1139+
};
11321140
let mut include_path = config.src.clone();
11331141
include_path.push("src");
11341142
include_path.push("bootstrap");

src/bootstrap/config/tests.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
use crate::config::TomlConfig;
2+
13
use super::{Config, Flags};
24
use clap::CommandFactory;
5+
use serde::Deserialize;
36
use std::{env, path::Path};
47

58
fn parse(config: &str) -> Config {
@@ -159,3 +162,19 @@ fn override_toml_duplicate() {
159162
|&_| toml::from_str("changelog-seen = 0").unwrap(),
160163
);
161164
}
165+
166+
#[test]
167+
fn profile_user_dist() {
168+
fn get_toml(file: &Path) -> TomlConfig {
169+
let contents = if file.ends_with("config.toml") {
170+
"profile = \"user\"".to_owned()
171+
} else {
172+
assert!(file.ends_with("config.dist.toml"));
173+
std::fs::read_to_string(dbg!(file)).unwrap()
174+
};
175+
toml::from_str(&contents)
176+
.and_then(|table: toml::Value| TomlConfig::deserialize(table))
177+
.unwrap()
178+
}
179+
Config::parse_inner(&["check".to_owned()], get_toml);
180+
}

src/bootstrap/configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def parse_example_config(known_args, config):
437437
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", "'{}'".format(target) if "." in target else target)
438438

439439
if 'profile' not in config:
440-
set('profile', 'user', config)
440+
set('profile', 'dist', config)
441441
configure_file(sections, top_level_keys, targets, config)
442442
return section_order, sections, targets
443443

src/bootstrap/setup.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum Profile {
2020
Codegen,
2121
Library,
2222
Tools,
23-
User,
23+
Dist,
2424
None,
2525
}
2626

@@ -43,7 +43,7 @@ impl Profile {
4343
pub fn all() -> impl Iterator<Item = Self> {
4444
use Profile::*;
4545
// N.B. these are ordered by how they are displayed, not alphabetically
46-
[Library, Compiler, Codegen, Tools, User, None].iter().copied()
46+
[Library, Compiler, Codegen, Tools, Dist, None].iter().copied()
4747
}
4848

4949
pub fn purpose(&self) -> String {
@@ -53,7 +53,7 @@ impl Profile {
5353
Compiler => "Contribute to the compiler itself",
5454
Codegen => "Contribute to the compiler, and also modify LLVM or codegen",
5555
Tools => "Contribute to tools which depend on the compiler, but do not modify it directly (e.g. rustdoc, clippy, miri)",
56-
User => "Install Rust from source",
56+
Dist => "Install Rust from source",
5757
None => "Do not modify `config.toml`"
5858
}
5959
.to_string()
@@ -73,7 +73,7 @@ impl Profile {
7373
Profile::Codegen => "codegen",
7474
Profile::Library => "library",
7575
Profile::Tools => "tools",
76-
Profile::User => "user",
76+
Profile::Dist => "dist",
7777
Profile::None => "none",
7878
}
7979
}
@@ -87,7 +87,7 @@ impl FromStr for Profile {
8787
"lib" | "library" => Ok(Profile::Library),
8888
"compiler" => Ok(Profile::Compiler),
8989
"llvm" | "codegen" => Ok(Profile::Codegen),
90-
"maintainer" | "user" => Ok(Profile::User),
90+
"maintainer" | "dist" | "user" => Ok(Profile::Dist),
9191
"tools" | "tool" | "rustdoc" | "clippy" | "miri" | "rustfmt" | "rls" => {
9292
Ok(Profile::Tools)
9393
}
@@ -160,7 +160,7 @@ pub fn setup(config: &Config, profile: Profile) {
160160
"test src/tools/rustfmt",
161161
],
162162
Profile::Library => &["check", "build", "test library/std", "doc"],
163-
Profile::User => &["dist", "build"],
163+
Profile::Dist => &["dist", "build"],
164164
};
165165

166166
println!();
@@ -170,7 +170,7 @@ pub fn setup(config: &Config, profile: Profile) {
170170
println!("- `x.py {}`", cmd);
171171
}
172172

173-
if profile != Profile::User {
173+
if profile != Profile::Dist {
174174
println!(
175175
"For more suggestions, see https://rustc-dev-guide.rust-lang.org/building/suggested.html"
176176
);

0 commit comments

Comments
 (0)