Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ impl Config {
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
config.deny_warnings = true;
config.missing_tools = false;
config.config = PathBuf::from("config.toml");

// set by bootstrap.py
config.build = TargetSelection::from_user(&env!("BUILD_TRIPLE"));
Expand Down Expand Up @@ -558,10 +557,10 @@ impl Config {
#[cfg(test)]
let get_toml = |_| TomlConfig::default();
#[cfg(not(test))]
let get_toml = |file: PathBuf| {
let get_toml = |file: &Path| {
use std::process;

let contents = t!(fs::read_to_string(&file), "`include` config not found");
let contents = t!(fs::read_to_string(file), "`include` config not found");
match toml::from_str(&contents) {
Ok(table) => table,
Err(err) => {
Expand All @@ -571,18 +570,21 @@ impl Config {
}
};

let mut toml = flags.config.map(get_toml).unwrap_or_else(TomlConfig::default);
let mut toml = flags.config.as_deref().map(get_toml).unwrap_or_else(TomlConfig::default);
if let Some(include) = &toml.profile {
let mut include_path = config.src.clone();
include_path.push("src");
include_path.push("bootstrap");
include_path.push("defaults");
include_path.push(format!("config.toml.{}", include));
let included_toml = get_toml(include_path);
let included_toml = get_toml(&include_path);
toml.merge(included_toml);
}

config.changelog_seen = toml.changelog_seen;
if let Some(cfg) = flags.config {
config.config = cfg;
}

let build = toml.build.unwrap_or_default();

Expand Down