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