1+
12use crate :: spec:: { LinkArgs , LinkerFlavor , TargetOptions } ;
23use std:: env;
34use std:: io;
45use std:: path:: Path ;
56use std:: process:: Command ;
67
78use Arch :: * ;
8-
99#[ allow( non_camel_case_types) ]
1010#[ derive( Copy , Clone ) ]
1111pub enum Arch {
@@ -17,6 +17,13 @@ pub enum Arch {
1717 X86_64_macabi ,
1818}
1919
20+ #[ allow( non_camel_case_types) ]
21+ #[ derive( Copy , Clone ) ]
22+ pub enum AppleOS {
23+ tvOS,
24+ iOS,
25+ }
26+
2027impl Arch {
2128 pub fn to_string ( self ) -> & ' static str {
2229 match self {
@@ -41,6 +48,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
4148 let p = Path :: new ( & sdkroot) ;
4249 match sdk_name {
4350 // Ignore `SDKROOT` if it's clearly set for the wrong platform.
51+ "appletvos"
52+ if sdkroot. contains ( "TVSimulator.platform" )
53+ || sdkroot. contains ( "MacOSX.platform" ) =>
54+ {
55+ ( )
56+ }
57+ "appletvsimulator"
58+ if sdkroot. contains ( "TVOS.platform" ) || sdkroot. contains ( "MacOSX.platform" ) =>
59+ {
60+ ( )
61+ }
4462 "iphoneos"
4563 if sdkroot. contains ( "iPhoneSimulator.platform" )
4664 || sdkroot. contains ( "MacOSX.platform" ) =>
@@ -82,11 +100,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
82100 }
83101}
84102
85- fn build_pre_link_args ( arch : Arch ) -> Result < LinkArgs , String > {
86- let sdk_name = match arch {
87- Armv7 | Armv7s | Arm64 => "iphoneos" ,
88- I386 | X86_64 => "iphonesimulator" ,
89- X86_64_macabi => "macosx10.15" ,
103+ fn build_pre_link_args ( arch : Arch , os : AppleOS ) -> Result < LinkArgs , String > {
104+ let sdk_name = match ( arch, os) {
105+ ( Arm64 , AppleOS :: tvOS) => "appletvos" ,
106+ ( X86_64 , AppleOS :: tvOS) => "appletvsimulator" ,
107+ ( Armv7 , AppleOS :: iOS) => "iphoneos" ,
108+ ( Armv7s , AppleOS :: iOS) => "iphoneos" ,
109+ ( Arm64 , AppleOS :: iOS) => "iphoneos" ,
110+ ( I386 , AppleOS :: iOS) => "iphonesimulator" ,
111+ ( X86_64 , AppleOS :: iOS) => "iphonesimulator" ,
112+ ( X86_64_macabi , AppleOS :: iOS) => "macosx10.15" ,
113+ _ => unreachable ! ( ) ,
90114 } ;
91115
92116 let arch_name = arch. to_string ( ) ;
@@ -121,15 +145,16 @@ fn target_cpu(arch: Arch) -> String {
121145 . to_string ( )
122146}
123147
148+
124149fn link_env_remove ( arch : Arch ) -> Vec < String > {
125150 match arch {
126151 Armv7 | Armv7s | Arm64 | I386 | X86_64 => vec ! [ "MACOSX_DEPLOYMENT_TARGET" . to_string( ) ] ,
127- X86_64_macabi => vec ! [ "IPHONEOS_DEPLOYMENT_TARGET" . to_string( ) ] ,
152+ X86_64_macabi => vec ! [ "IPHONEOS_DEPLOYMENT_TARGET" . to_string( ) , ] ,
128153 }
129154}
130155
131- pub fn opts ( arch : Arch ) -> Result < TargetOptions , String > {
132- let pre_link_args = build_pre_link_args ( arch) ?;
156+ pub fn opts ( arch : Arch , os : AppleOS ) -> Result < TargetOptions , String > {
157+ let pre_link_args = build_pre_link_args ( arch, os ) ?;
133158 Ok ( TargetOptions {
134159 cpu : target_cpu ( arch) ,
135160 dynamic_linking : false ,
0 commit comments