@@ -698,6 +698,7 @@ pub(crate) struct TomlConfig {
698
698
target : Option < HashMap < String , TomlTarget > > ,
699
699
dist : Option < Dist > ,
700
700
profile : Option < String > ,
701
+ include : Option < Vec < PathBuf > > ,
701
702
}
702
703
703
704
/// This enum is used for deserializing change IDs from TOML, allowing both numeric values and the string `"ignore"`.
@@ -750,7 +751,7 @@ trait Merge {
750
751
impl Merge for TomlConfig {
751
752
fn merge (
752
753
& 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 ,
754
755
replace : ReplaceOpt ,
755
756
) {
756
757
fn do_merge < T : Merge > ( x : & mut Option < T > , y : Option < T > , replace : ReplaceOpt ) {
@@ -763,6 +764,17 @@ impl Merge for TomlConfig {
763
764
}
764
765
}
765
766
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
+
766
778
self . change_id . inner . merge ( change_id. inner , replace) ;
767
779
self . profile . merge ( profile, replace) ;
768
780
@@ -1599,6 +1611,17 @@ impl Config {
1599
1611
toml. merge ( included_toml, ReplaceOpt :: IgnoreDuplicate ) ;
1600
1612
}
1601
1613
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
+
1602
1625
let mut override_toml = TomlConfig :: default ( ) ;
1603
1626
for option in flags. set . iter ( ) {
1604
1627
fn get_table ( option : & str ) -> Result < TomlConfig , toml:: de:: Error > {
0 commit comments