@@ -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 ,
@@ -1589,6 +1593,13 @@ impl Target {
1589
1593
. collect( ) ;
1590
1594
}
1591
1595
} ) ;
1596
+ ( $key_name: ident = $json_name: expr, list) => ( {
1597
+ if let Some ( v) = obj. find( $json_name) . and_then( Json :: as_array) {
1598
+ base. $key_name = v. iter( )
1599
+ . map( |a| a. as_string( ) . unwrap( ) . to_string( ) )
1600
+ . collect( ) ;
1601
+ }
1602
+ } ) ;
1592
1603
( $key_name: ident, opt_list) => ( {
1593
1604
let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
1594
1605
if let Some ( v) = obj. find( & name) . and_then( Json :: as_array) {
@@ -1605,14 +1616,6 @@ impl Target {
1605
1616
. map( |s| s. to_string( ) ) ;
1606
1617
}
1607
1618
} ) ;
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
1619
( $key_name: ident, LldFlavor ) => ( {
1617
1620
let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
1618
1621
obj. find( & name[ ..] ) . and_then( |o| o. as_string( ) . and_then( |s| {
@@ -1802,7 +1805,7 @@ impl Target {
1802
1805
key ! ( exe_suffix) ;
1803
1806
key ! ( staticlib_prefix) ;
1804
1807
key ! ( staticlib_suffix) ;
1805
- key ! ( os_family = "target-family" , optional ) ;
1808
+ key ! ( families = "target-family" , list ) ;
1806
1809
key ! ( abi_return_struct_as_int, bool ) ;
1807
1810
key ! ( is_like_osx, bool ) ;
1808
1811
key ! ( is_like_solaris, bool ) ;
@@ -2042,7 +2045,7 @@ impl ToJson for Target {
2042
2045
target_option_val ! ( exe_suffix) ;
2043
2046
target_option_val ! ( staticlib_prefix) ;
2044
2047
target_option_val ! ( staticlib_suffix) ;
2045
- target_option_val ! ( os_family , "target-family" ) ;
2048
+ target_option_val ! ( families , "target-family" ) ;
2046
2049
target_option_val ! ( abi_return_struct_as_int) ;
2047
2050
target_option_val ! ( is_like_osx) ;
2048
2051
target_option_val ! ( is_like_solaris) ;
0 commit comments