add new config option: include
Signed-off-by: onur-ozkan <work@onurozkan.dev>
This commit is contained in:
parent
58c2dd9a54
commit
1c1febc59d
2 changed files with 29 additions and 1 deletions
|
@ -701,6 +701,7 @@ pub(crate) struct TomlConfig {
|
|||
target: Option<HashMap<String, TomlTarget>>,
|
||||
dist: Option<Dist>,
|
||||
profile: Option<String>,
|
||||
include: Option<Vec<PathBuf>>,
|
||||
}
|
||||
|
||||
/// This enum is used for deserializing change IDs from TOML, allowing both numeric values and the string `"ignore"`.
|
||||
|
@ -753,7 +754,7 @@ trait Merge {
|
|||
impl Merge for TomlConfig {
|
||||
fn merge(
|
||||
&mut self,
|
||||
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id }: Self,
|
||||
TomlConfig { build, install, llvm, gcc, rust, dist, target, profile, change_id, include }: Self,
|
||||
replace: ReplaceOpt,
|
||||
) {
|
||||
fn do_merge<T: Merge>(x: &mut Option<T>, y: Option<T>, replace: ReplaceOpt) {
|
||||
|
@ -766,6 +767,17 @@ impl Merge for TomlConfig {
|
|||
}
|
||||
}
|
||||
|
||||
for include_path in include.clone().unwrap_or_default() {
|
||||
let included_toml = Config::get_toml(&include_path).unwrap_or_else(|e| {
|
||||
eprintln!(
|
||||
"ERROR: Failed to parse default config profile at '{}': {e}",
|
||||
include_path.display()
|
||||
);
|
||||
exit!(2);
|
||||
});
|
||||
self.merge(included_toml, ReplaceOpt::Override);
|
||||
}
|
||||
|
||||
self.change_id.inner.merge(change_id.inner, replace);
|
||||
self.profile.merge(profile, replace);
|
||||
|
||||
|
@ -1600,6 +1612,17 @@ impl Config {
|
|||
toml.merge(included_toml, ReplaceOpt::IgnoreDuplicate);
|
||||
}
|
||||
|
||||
for include_path in toml.include.clone().unwrap_or_default() {
|
||||
let included_toml = get_toml(&include_path).unwrap_or_else(|e| {
|
||||
eprintln!(
|
||||
"ERROR: Failed to parse default config profile at '{}': {e}",
|
||||
include_path.display()
|
||||
);
|
||||
exit!(2);
|
||||
});
|
||||
toml.merge(included_toml, ReplaceOpt::Override);
|
||||
}
|
||||
|
||||
let mut override_toml = TomlConfig::default();
|
||||
for option in flags.set.iter() {
|
||||
fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
|
||||
|
|
|
@ -396,4 +396,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
|
|||
severity: ChangeSeverity::Info,
|
||||
summary: "Added a new option `build.compiletest-use-stage0-libtest` to force `compiletest` to use the stage 0 libtest.",
|
||||
},
|
||||
ChangeInfo {
|
||||
change_id: 138934,
|
||||
severity: ChangeSeverity::Info,
|
||||
summary: "Added new option `include` to create config extensions.",
|
||||
},
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue