Skip to content

Commit ffc4705

Browse files
committed
bootstrap: support local profiles
Signed-off-by: onur-ozkan <[email protected]>
1 parent 7d49ae9 commit ffc4705

File tree

2 files changed

+32
-23
lines changed

2 files changed

+32
-23
lines changed

Diff for: src/bootstrap/bootstrap.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -1280,15 +1280,18 @@ def bootstrap(args):
12801280
profile = "dist"
12811281

12821282
if profile is not None:
1283-
# Allows creating alias for profile names, allowing
1284-
# profiles to be renamed while maintaining back compatibility
1285-
# Keep in sync with `profile_aliases` in config.rs
1286-
profile_aliases = {"user": "dist"}
1287-
include_file = "bootstrap.{}.toml".format(
1288-
profile_aliases.get(profile) or profile
1289-
)
1290-
include_dir = os.path.join(rust_root, "src", "bootstrap", "defaults")
1291-
include_path = os.path.join(include_dir, include_file)
1283+
include_path = os.path.join("{}.toml".format(profile))
1284+
1285+
if not os.path.exists(include_path):
1286+
# Allows creating alias for profile names, allowing
1287+
# profiles to be renamed while maintaining back compatibility
1288+
# Keep in sync with `profile_aliases` in config.rs
1289+
profile_aliases = {"user": "dist"}
1290+
include_file = "bootstrap.{}.toml".format(
1291+
profile_aliases.get(profile) or profile
1292+
)
1293+
include_dir = os.path.join(rust_root, "src", "bootstrap", "defaults")
1294+
include_path = os.path.join(include_dir, include_file)
12921295

12931296
if not os.path.exists(include_path):
12941297
raise Exception(

Diff for: src/bootstrap/src/core/config/config.rs

+20-14
Original file line numberDiff line numberDiff line change
@@ -1552,27 +1552,33 @@ impl Config {
15521552
toml.profile = Some("dist".into());
15531553
}
15541554

1555-
if let Some(include) = &toml.profile {
1556-
// Allows creating alias for profile names, allowing
1557-
// profiles to be renamed while maintaining back compatibility
1558-
// Keep in sync with `profile_aliases` in bootstrap.py
1559-
let profile_aliases = HashMap::from([("user", "dist")]);
1560-
let include = match profile_aliases.get(include.as_str()) {
1561-
Some(alias) => alias,
1562-
None => include.as_str(),
1563-
};
1564-
let mut include_path = config.src.clone();
1565-
include_path.push("src");
1566-
include_path.push("bootstrap");
1567-
include_path.push("defaults");
1568-
include_path.push(format!("bootstrap.{include}.toml"));
1555+
if let Some(profile) = &toml.profile {
1556+
let mut include_path = PathBuf::from(format!("{profile}.toml"));
1557+
1558+
if !include_path.exists() {
1559+
// Allows creating alias for profile names, allowing
1560+
// profiles to be renamed while maintaining back compatibility
1561+
// Keep in sync with `profile_aliases` in bootstrap.py
1562+
let profile_aliases = HashMap::from([("user", "dist")]);
1563+
let profile = match profile_aliases.get(profile.as_str()) {
1564+
Some(alias) => alias,
1565+
None => profile.as_str(),
1566+
};
1567+
1568+
include_path = config
1569+
.src
1570+
.join("src/bootstrap/defaults")
1571+
.join(format!("bootstrap.{profile}.toml"));
1572+
}
1573+
15691574
let included_toml = get_toml(&include_path).unwrap_or_else(|e| {
15701575
eprintln!(
15711576
"ERROR: Failed to parse default config profile at '{}': {e}",
15721577
include_path.display()
15731578
);
15741579
exit!(2);
15751580
});
1581+
15761582
toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate);
15771583
}
15781584

0 commit comments

Comments
 (0)