1
+
1
2
use crate :: spec:: { LinkArgs , LinkerFlavor , TargetOptions } ;
2
3
use std:: env;
3
4
use std:: io;
4
5
use std:: path:: Path ;
5
6
use std:: process:: Command ;
6
7
7
8
use Arch :: * ;
8
-
9
9
#[ allow( non_camel_case_types) ]
10
10
#[ derive( Copy , Clone ) ]
11
11
pub enum Arch {
@@ -17,6 +17,13 @@ pub enum Arch {
17
17
X86_64_macabi ,
18
18
}
19
19
20
+ #[ allow( non_camel_case_types) ]
21
+ #[ derive( Copy , Clone ) ]
22
+ pub enum AppleOS {
23
+ tvOS,
24
+ iOS,
25
+ }
26
+
20
27
impl Arch {
21
28
pub fn to_string ( self ) -> & ' static str {
22
29
match self {
@@ -41,6 +48,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
41
48
let p = Path :: new ( & sdkroot) ;
42
49
match sdk_name {
43
50
// 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
+ }
44
62
"iphoneos"
45
63
if sdkroot. contains ( "iPhoneSimulator.platform" )
46
64
|| sdkroot. contains ( "MacOSX.platform" ) =>
@@ -82,11 +100,17 @@ pub fn get_sdk_root(sdk_name: &str) -> Result<String, String> {
82
100
}
83
101
}
84
102
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 ! ( ) ,
90
114
} ;
91
115
92
116
let arch_name = arch. to_string ( ) ;
@@ -121,15 +145,16 @@ fn target_cpu(arch: Arch) -> String {
121
145
. to_string ( )
122
146
}
123
147
148
+
124
149
fn link_env_remove ( arch : Arch ) -> Vec < String > {
125
150
match arch {
126
151
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( ) , ] ,
128
153
}
129
154
}
130
155
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 ) ?;
133
158
Ok ( TargetOptions {
134
159
cpu : target_cpu ( arch) ,
135
160
dynamic_linking : false ,
0 commit comments