@@ -1774,7 +1774,10 @@ impl Build {
17741774 cmd. push_opt_unless_duplicate ( "-DANDROID" . into ( ) ) ;
17751775 }
17761776
1777- if !target. contains ( "apple-ios" ) && !target. contains ( "apple-watchos" ) {
1777+ if !target. contains ( "apple-ios" )
1778+ && !target. contains ( "apple-watchos" )
1779+ && !target. contains ( "apple-tvos" )
1780+ {
17781781 cmd. push_cc_arg ( "-ffunction-sections" . into ( ) ) ;
17791782 cmd. push_cc_arg ( "-fdata-sections" . into ( ) ) ;
17801783 }
@@ -1856,6 +1859,20 @@ impl Build {
18561859 . into ( ) ,
18571860 ) ;
18581861 }
1862+ } else if target. contains ( "x86_64-apple-tvos" ) {
1863+ if let Some ( arch) =
1864+ map_darwin_target_from_rust_to_compiler_architecture ( target)
1865+ {
1866+ let deployment_target =
1867+ self . apple_deployment_version ( AppleOs :: TvOs , target, None ) ;
1868+ cmd. args . push (
1869+ format ! (
1870+ "--target={}-apple-tvos{}-simulator" ,
1871+ arch, deployment_target
1872+ )
1873+ . into ( ) ,
1874+ ) ;
1875+ }
18591876 } else if target. starts_with ( "riscv64gc-" ) {
18601877 cmd. args . push (
18611878 format ! ( "--target={}" , target. replace( "riscv64gc" , "riscv64" ) ) . into ( ) ,
@@ -2382,6 +2399,8 @@ impl Build {
23822399 AppleOs :: MacOs
23832400 } else if target. contains ( "-watchos" ) {
23842401 AppleOs :: WatchOs
2402+ } else if target. contains ( "-tvos" ) {
2403+ AppleOs :: TvOs
23852404 } else {
23862405 AppleOs :: Ios
23872406 } ;
@@ -2402,7 +2421,7 @@ impl Build {
24022421 None => false ,
24032422 } ;
24042423
2405- let is_sim = match target. split ( '-' ) . nth ( 3 ) {
2424+ let is_arm_sim = match target. split ( '-' ) . nth ( 3 ) {
24062425 Some ( v) => v == "sim" ,
24072426 None => false ,
24082427 } ;
@@ -2430,14 +2449,14 @@ impl Build {
24302449 ) ) ;
24312450 }
24322451 }
2433- } else if is_sim {
2452+ } else if is_arm_sim {
24342453 match arch_str {
24352454 "arm64" | "aarch64" => ArchSpec :: Simulator ( "arm64" ) ,
24362455 "x86_64" | "x86_64h" => ArchSpec :: Simulator ( "-m64" ) ,
24372456 _ => {
24382457 return Err ( Error :: new (
24392458 ErrorKind :: ArchitectureInvalid ,
2440- "Unknown architecture for iOS simulator target." ,
2459+ "Unknown architecture for simulator target." ,
24412460 ) ) ;
24422461 }
24432462 }
@@ -2465,6 +2484,7 @@ impl Build {
24652484 AppleOs :: MacOs => ( "macosx" , "" ) ,
24662485 AppleOs :: Ios => ( "iphone" , "ios-" ) ,
24672486 AppleOs :: WatchOs => ( "watch" , "watch" ) ,
2487+ AppleOs :: TvOs => ( "appletv" , "appletv" ) ,
24682488 } ;
24692489
24702490 let sdk = match arch {
@@ -3468,6 +3488,10 @@ impl Build {
34683488 . ok ( )
34693489 . or_else ( || rustc_provided_target ( rustc, target) )
34703490 . unwrap_or_else ( || "5.0" . into ( ) ) ,
3491+ AppleOs :: TvOs => env:: var ( "TVOS_DEPLOYMENT_TARGET" )
3492+ . ok ( )
3493+ . or_else ( || rustc_provided_target ( rustc, target) )
3494+ . unwrap_or_else ( || "9.0" . into ( ) ) ,
34713495 }
34723496 }
34733497
@@ -3863,13 +3887,15 @@ enum AppleOs {
38633887 MacOs ,
38643888 Ios ,
38653889 WatchOs ,
3890+ TvOs ,
38663891}
38673892impl std:: fmt:: Debug for AppleOs {
38683893 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
38693894 match self {
38703895 AppleOs :: MacOs => f. write_str ( "macOS" ) ,
38713896 AppleOs :: Ios => f. write_str ( "iOS" ) ,
38723897 AppleOs :: WatchOs => f. write_str ( "WatchOS" ) ,
3898+ AppleOs :: TvOs => f. write_str ( "AppleTVOS" ) ,
38733899 }
38743900 }
38753901}
0 commit comments