@@ -1042,8 +1042,12 @@ pub struct TargetOptions {
1042
1042
pub staticlib_prefix : String ,
1043
1043
/// String to append to the name of every static library. Defaults to ".a".
1044
1044
pub staticlib_suffix : String ,
1045
- /// OS family to use for conditional compilation. Valid options: "unix", "windows".
1046
- pub os_family : Option < String > ,
1045
+ /// Values of the `target_family` cfg set for this target.
1046
+ ///
1047
+ /// Common options are: "unix", "windows". Defaults to no families.
1048
+ ///
1049
+ /// See <https://doc.rust-lang.org/reference/conditional-compilation.html#target_family>.
1050
+ pub families : Vec < String > ,
1047
1051
/// Whether the target toolchain's ABI supports returning small structs as an integer.
1048
1052
pub abi_return_struct_as_int : bool ,
1049
1053
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
@@ -1293,7 +1297,7 @@ impl Default for TargetOptions {
1293
1297
exe_suffix : String :: new ( ) ,
1294
1298
staticlib_prefix : "lib" . to_string ( ) ,
1295
1299
staticlib_suffix : ".a" . to_string ( ) ,
1296
- os_family : None ,
1300
+ families : Vec :: new ( ) ,
1297
1301
abi_return_struct_as_int : false ,
1298
1302
is_like_osx : false ,
1299
1303
is_like_solaris : false ,
@@ -1605,14 +1609,6 @@ impl Target {
1605
1609
. map( |s| s. to_string( ) ) ;
1606
1610
}
1607
1611
} ) ;
1608
- ( $key_name: ident = $json_name: expr, optional) => ( {
1609
- let name = $json_name;
1610
- if let Some ( o) = obj. find( name) {
1611
- base. $key_name = o
1612
- . as_string( )
1613
- . map( |s| s. to_string( ) ) ;
1614
- }
1615
- } ) ;
1616
1612
( $key_name: ident, LldFlavor ) => ( {
1617
1613
let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
1618
1614
obj. find( & name[ ..] ) . and_then( |o| o. as_string( ) . and_then( |s| {
@@ -1759,6 +1755,16 @@ impl Target {
1759
1755
Some ( Ok ( ( ) ) )
1760
1756
} ) ) . unwrap_or( Ok ( ( ) ) )
1761
1757
} ) ;
1758
+ ( $key_name: ident, TargetFamilies ) => ( {
1759
+ let value = obj. find( "target-family" ) ;
1760
+ if let Some ( v) = value. and_then( Json :: as_array) {
1761
+ base. $key_name = v. iter( )
1762
+ . map( |a| a. as_string( ) . unwrap( ) . to_string( ) )
1763
+ . collect( ) ;
1764
+ } else if let Some ( v) = value. and_then( Json :: as_string) {
1765
+ base. $key_name = vec![ v. to_string( ) ] ;
1766
+ }
1767
+ } ) ;
1762
1768
}
1763
1769
1764
1770
if let Some ( s) = obj. find ( "target-endian" ) . and_then ( Json :: as_string) {
@@ -1802,7 +1808,7 @@ impl Target {
1802
1808
key ! ( exe_suffix) ;
1803
1809
key ! ( staticlib_prefix) ;
1804
1810
key ! ( staticlib_suffix) ;
1805
- key ! ( os_family = "target-family" , optional ) ;
1811
+ key ! ( families , TargetFamilies ) ;
1806
1812
key ! ( abi_return_struct_as_int, bool ) ;
1807
1813
key ! ( is_like_osx, bool ) ;
1808
1814
key ! ( is_like_solaris, bool ) ;
@@ -2042,7 +2048,7 @@ impl ToJson for Target {
2042
2048
target_option_val ! ( exe_suffix) ;
2043
2049
target_option_val ! ( staticlib_prefix) ;
2044
2050
target_option_val ! ( staticlib_suffix) ;
2045
- target_option_val ! ( os_family , "target-family" ) ;
2051
+ target_option_val ! ( families , "target-family" ) ;
2046
2052
target_option_val ! ( abi_return_struct_as_int) ;
2047
2053
target_option_val ! ( is_like_osx) ;
2048
2054
target_option_val ! ( is_like_solaris) ;
0 commit comments