@@ -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 {
750751impl 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 > {
0 commit comments