Skip to content

Commit fb8ddb5

Browse files
committed
add new config option: include
Signed-off-by: onur-ozkan <[email protected]>
1 parent 7d49ae9 commit fb8ddb5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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

+24-1
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ pub(crate) struct TomlConfig {
698698
target: Option<HashMap<String, TomlTarget>>,
699699
dist: Option<Dist>,
700700
profile: Option<String>,
701+
include: Option<Vec<PathBuf>>,
701702
}
702703

703704
/// Since we use `#[serde(deny_unknown_fields)]` on `TomlConfig`, we need a wrapper type
@@ -728,7 +729,7 @@ trait Merge {
728729
impl Merge for TomlConfig {
729730
fn merge(
730731
&mut self,
731-
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id }: Self,
732+
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id, include }: Self,
732733
replace: ReplaceOpt,
733734
) {
734735
fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>, replace: ReplaceOpt) {
@@ -741,6 +742,17 @@ impl Merge for TomlConfig {
741742
}
742743
}
743744

745+
for include_path in include.clone().unwrap_or_default() {
746+
let included_toml = Config::get_toml(&include_path).unwrap_or_else(|e| {
747+
eprintln!(
748+
"ERROR: Failed to parse default config profile at '{}': {e}",
749+
include_path.display()
750+
);
751+
exit!(2);
752+
});
753+
self.merge(included_toml, ReplaceOpt::Override);
754+
}
755+
744756
self.change_id.inner.merge(change_id.inner, replace);
745757
self.profile.merge(profile, replace);
746758

@@ -1576,6 +1588,17 @@ impl Config {
15761588
toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate);
15771589
}
15781590

1591+
for include_path in toml.include.clone().unwrap_or_default() {
1592+
let included_toml = get_toml(&include_path).unwrap_or_else(|e| {
1593+
eprintln!(
1594+
"ERROR: Failed to parse default config profile at '{}': {e}",
1595+
include_path.display()
1596+
);
1597+
exit!(2);
1598+
});
1599+
toml.merge(included_toml, ReplaceOpt::Override);
1600+
}
1601+
15791602
let mut override_toml = TomlConfig::default();
15801603
for option in flags.set.iter() {
15811604
fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {

Diff for: src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -390,4 +390,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
390390
severity: ChangeSeverity::Warning,
391391
summary: "The default configuration filename has changed from `config.toml` to `bootstrap.toml`. `config.toml` is deprecated but remains supported for backward compatibility.",
392392
},
393+
ChangeInfo {
394+
change_id: 138934,
395+
severity: ChangeSeverity::Info,
396+
summary: "Added new option `include` to create config extensions.",
397+
},
393398
];

0 commit comments

Comments
 (0)