@@ -701,6 +701,7 @@ pub(crate) struct TomlConfig {
701
701
target : Option < HashMap < String , TomlTarget > > ,
702
702
dist : Option < Dist > ,
703
703
profile : Option < String > ,
704
+ include : Option < Vec < PathBuf > > ,
704
705
}
705
706
706
707
/// This enum is used for deserializing change IDs from TOML, allowing both numeric values and the string `"ignore"`.
@@ -753,7 +754,7 @@ trait Merge {
753
754
impl Merge for TomlConfig {
754
755
fn merge (
755
756
& 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 ,
757
758
replace : ReplaceOpt ,
758
759
) {
759
760
fn do_merge < T : Merge > ( x : & mut Option < T > , y : Option < T > , replace : ReplaceOpt ) {
@@ -766,6 +767,17 @@ impl Merge for TomlConfig {
766
767
}
767
768
}
768
769
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
+
769
781
self . change_id . inner . merge ( change_id. inner , replace) ;
770
782
self . profile . merge ( profile, replace) ;
771
783
@@ -1600,6 +1612,17 @@ impl Config {
1600
1612
toml. merge ( included_toml, ReplaceOpt :: IgnoreDuplicate ) ;
1601
1613
}
1602
1614
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
+
1603
1626
let mut override_toml = TomlConfig :: default ( ) ;
1604
1627
for option in flags. set . iter ( ) {
1605
1628
fn get_table ( option : & str ) -> Result < TomlConfig , toml:: de:: Error > {
0 commit comments