Skip to content

Commit 3caef09

Browse files
committed
add new config option: include
Signed-off-by: onur-ozkan <[email protected]>
1 parent 0b45675 commit 3caef09

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

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
/// This enum is used for deserializing change IDs from TOML, allowing both numeric values and the string `"ignore"`.
@@ -750,7 +751,7 @@ trait Merge {
750751
impl Merge for TomlConfig {
751752
fn merge(
752753
&mut self,
753-
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id }: Self,
754+
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id, include }: Self,
754755
replace: ReplaceOpt,
755756
) {
756757
fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>, replace: ReplaceOpt) {
@@ -763,6 +764,17 @@ impl Merge for TomlConfig {
763764
}
764765
}
765766

767+
for include_path in include.clone().unwrap_or_default() {
768+
let included_toml = Config::get_toml(&include_path).unwrap_or_else(|e| {
769+
eprintln!(
770+
"ERROR: Failed to parse default config profile at '{}': {e}",
771+
include_path.display()
772+
);
773+
exit!(2);
774+
});
775+
self.merge(included_toml, ReplaceOpt::Override);
776+
}
777+
766778
self.change_id.inner.merge(change_id.inner, replace);
767779
self.profile.merge(profile, replace);
768780

@@ -1599,6 +1611,17 @@ impl Config {
15991611
toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate);
16001612
}
16011613

1614+
for include_path in toml.include.clone().unwrap_or_default() {
1615+
let included_toml = get_toml(&include_path).unwrap_or_else(|e| {
1616+
eprintln!(
1617+
"ERROR: Failed to parse default config profile at '{}': {e}",
1618+
include_path.display()
1619+
);
1620+
exit!(2);
1621+
});
1622+
toml.merge(included_toml, ReplaceOpt::Override);
1623+
}
1624+
16021625
let mut override_toml = TomlConfig::default();
16031626
for option in flags.set.iter() {
16041627
fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
391391
severity: ChangeSeverity::Info,
392392
summary: "You can now use `change-id = \"ignore\"` to suppress `change-id ` warnings in the console.",
393393
},
394+
ChangeInfo {
395+
change_id: 138934,
396+
severity: ChangeSeverity::Info,
397+
summary: "Added new option `include` to create config extensions.",
398+
},
394399
];

0 commit comments

Comments
 (0)