@@ -1774,7 +1774,10 @@ impl Build {
1774
1774
cmd. push_opt_unless_duplicate ( "-DANDROID" . into ( ) ) ;
1775
1775
}
1776
1776
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
+ {
1778
1781
cmd. push_cc_arg ( "-ffunction-sections" . into ( ) ) ;
1779
1782
cmd. push_cc_arg ( "-fdata-sections" . into ( ) ) ;
1780
1783
}
@@ -1856,6 +1859,20 @@ impl Build {
1856
1859
. into ( ) ,
1857
1860
) ;
1858
1861
}
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
+ }
1859
1876
} else if target. starts_with ( "riscv64gc-" ) {
1860
1877
cmd. args . push (
1861
1878
format ! ( "--target={}" , target. replace( "riscv64gc" , "riscv64" ) ) . into ( ) ,
@@ -2382,6 +2399,8 @@ impl Build {
2382
2399
AppleOs :: MacOs
2383
2400
} else if target. contains ( "-watchos" ) {
2384
2401
AppleOs :: WatchOs
2402
+ } else if target. contains ( "-tvos" ) {
2403
+ AppleOs :: TvOs
2385
2404
} else {
2386
2405
AppleOs :: Ios
2387
2406
} ;
@@ -2402,7 +2421,7 @@ impl Build {
2402
2421
None => false ,
2403
2422
} ;
2404
2423
2405
- let is_sim = match target. split ( '-' ) . nth ( 3 ) {
2424
+ let is_arm_sim = match target. split ( '-' ) . nth ( 3 ) {
2406
2425
Some ( v) => v == "sim" ,
2407
2426
None => false ,
2408
2427
} ;
@@ -2430,14 +2449,14 @@ impl Build {
2430
2449
) ) ;
2431
2450
}
2432
2451
}
2433
- } else if is_sim {
2452
+ } else if is_arm_sim {
2434
2453
match arch_str {
2435
2454
"arm64" | "aarch64" => ArchSpec :: Simulator ( "arm64" ) ,
2436
2455
"x86_64" | "x86_64h" => ArchSpec :: Simulator ( "-m64" ) ,
2437
2456
_ => {
2438
2457
return Err ( Error :: new (
2439
2458
ErrorKind :: ArchitectureInvalid ,
2440
- "Unknown architecture for iOS simulator target." ,
2459
+ "Unknown architecture for simulator target." ,
2441
2460
) ) ;
2442
2461
}
2443
2462
}
@@ -2465,6 +2484,7 @@ impl Build {
2465
2484
AppleOs :: MacOs => ( "macosx" , "" ) ,
2466
2485
AppleOs :: Ios => ( "iphone" , "ios-" ) ,
2467
2486
AppleOs :: WatchOs => ( "watch" , "watch" ) ,
2487
+ AppleOs :: TvOs => ( "appletv" , "appletv" ) ,
2468
2488
} ;
2469
2489
2470
2490
let sdk = match arch {
@@ -3468,6 +3488,10 @@ impl Build {
3468
3488
. ok ( )
3469
3489
. or_else ( || rustc_provided_target ( rustc, target) )
3470
3490
. 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 ( ) ) ,
3471
3495
}
3472
3496
}
3473
3497
@@ -3863,13 +3887,15 @@ enum AppleOs {
3863
3887
MacOs ,
3864
3888
Ios ,
3865
3889
WatchOs ,
3890
+ TvOs ,
3866
3891
}
3867
3892
impl std:: fmt:: Debug for AppleOs {
3868
3893
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
3869
3894
match self {
3870
3895
AppleOs :: MacOs => f. write_str ( "macOS" ) ,
3871
3896
AppleOs :: Ios => f. write_str ( "iOS" ) ,
3872
3897
AppleOs :: WatchOs => f. write_str ( "WatchOS" ) ,
3898
+ AppleOs :: TvOs => f. write_str ( "AppleTVOS" ) ,
3873
3899
}
3874
3900
}
3875
3901
}
0 commit comments