@@ -1042,8 +1042,12 @@ pub struct TargetOptions {
10421042 pub staticlib_prefix : String ,
10431043 /// String to append to the name of every static library. Defaults to ".a".
10441044 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 > ,
10471051 /// Whether the target toolchain's ABI supports returning small structs as an integer.
10481052 pub abi_return_struct_as_int : bool ,
10491053 /// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
@@ -1293,7 +1297,7 @@ impl Default for TargetOptions {
12931297 exe_suffix : String :: new ( ) ,
12941298 staticlib_prefix : "lib" . to_string ( ) ,
12951299 staticlib_suffix : ".a" . to_string ( ) ,
1296- os_family : None ,
1300+ families : Vec :: new ( ) ,
12971301 abi_return_struct_as_int : false ,
12981302 is_like_osx : false ,
12991303 is_like_solaris : false ,
@@ -1605,14 +1609,6 @@ impl Target {
16051609 . map( |s| s. to_string( ) ) ;
16061610 }
16071611 } ) ;
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- } ) ;
16161612 ( $key_name: ident, LldFlavor ) => ( {
16171613 let name = ( stringify!( $key_name) ) . replace( "_" , "-" ) ;
16181614 obj. find( & name[ ..] ) . and_then( |o| o. as_string( ) . and_then( |s| {
@@ -1759,6 +1755,16 @@ impl Target {
17591755 Some ( Ok ( ( ) ) )
17601756 } ) ) . unwrap_or( Ok ( ( ) ) )
17611757 } ) ;
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+ } ) ;
17621768 }
17631769
17641770 if let Some ( s) = obj. find ( "target-endian" ) . and_then ( Json :: as_string) {
@@ -1802,7 +1808,7 @@ impl Target {
18021808 key ! ( exe_suffix) ;
18031809 key ! ( staticlib_prefix) ;
18041810 key ! ( staticlib_suffix) ;
1805- key ! ( os_family = "target-family" , optional ) ;
1811+ key ! ( families , TargetFamilies ) ;
18061812 key ! ( abi_return_struct_as_int, bool ) ;
18071813 key ! ( is_like_osx, bool ) ;
18081814 key ! ( is_like_solaris, bool ) ;
@@ -2042,7 +2048,7 @@ impl ToJson for Target {
20422048 target_option_val ! ( exe_suffix) ;
20432049 target_option_val ! ( staticlib_prefix) ;
20442050 target_option_val ! ( staticlib_suffix) ;
2045- target_option_val ! ( os_family , "target-family" ) ;
2051+ target_option_val ! ( families , "target-family" ) ;
20462052 target_option_val ! ( abi_return_struct_as_int) ;
20472053 target_option_val ! ( is_like_osx) ;
20482054 target_option_val ! ( is_like_solaris) ;
0 commit comments