Skip to content

Commit 1c1febc

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

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
@@ -701,6 +701,7 @@ pub(crate) struct TomlConfig {
701701
target: Option<HashMap<String, TomlTarget>>,
702702
dist: Option<Dist>,
703703
profile: Option<String>,
704+
include: Option<Vec<PathBuf>>,
704705
}
705706

706707
/// This enum is used for deserializing change IDs from TOML, allowing both numeric values and the string `"ignore"`.
@@ -753,7 +754,7 @@ trait Merge {
753754
impl Merge for TomlConfig {
754755
fn merge(
755756
&mut self,
756-
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id }: Self,
757+
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id, include }: Self,
757758
replace: ReplaceOpt,
758759
) {
759760
fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>, replace: ReplaceOpt) {
@@ -766,6 +767,17 @@ impl Merge for TomlConfig {
766767
}
767768
}
768769

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

@@ -1600,6 +1612,17 @@ impl Config {
16001612
toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate);
16011613
}
16021614

1615+
for include_path in toml.include.clone().unwrap_or_default() {
1616+
let included_toml = get_toml(&include_path).unwrap_or_else(|e| {
1617+
eprintln!(
1618+
"ERROR: Failed to parse default config profile at '{}': {e}",
1619+
include_path.display()
1620+
);
1621+
exit!(2);
1622+
});
1623+
toml.merge(included_toml, ReplaceOpt::Override);
1624+
}
1625+
16031626
let mut override_toml = TomlConfig::default();
16041627
for option in flags.set.iter() {
16051628
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
@@ -396,4 +396,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
396396
severity: ChangeSeverity::Info,
397397
summary: "Added a new option `build.compiletest-use-stage0-libtest` to force `compiletest` to use the stage 0 libtest.",
398398
},
399+
ChangeInfo {
400+
change_id: 138934,
401+
severity: ChangeSeverity::Info,
402+
summary: "Added new option `include` to create config extensions.",
403+
},
399404
];

0 commit comments

Comments
 (0)