1
1
import os
2
2
import sys
3
3
import subprocess
4
- import ios_osxcross
5
4
from SCons .Variables import *
6
5
7
6
if sys .version_info < (3 ,):
@@ -16,6 +15,10 @@ def decode_utf8(x):
16
15
return codecs .utf_8_decode (x )[0 ]
17
16
18
17
18
+ def has_ios_osxcross ():
19
+ return "OSXCROSS_IOS" in os .environ
20
+
21
+
19
22
def options (opts ):
20
23
opts .Add (BoolVariable ("ios_simulator" , "Target iOS Simulator" , False ))
21
24
opts .Add ("ios_min_version" , "Target minimum iphoneos/iphonesimulator version" , "10.0" )
@@ -25,17 +28,18 @@ def options(opts):
25
28
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain" ,
26
29
)
27
30
opts .Add ("IOS_SDK_PATH" , "Path to the iOS SDK" , "" )
28
- ios_osxcross .options (opts )
31
+
32
+ if has_ios_osxcross ():
33
+ opts .Add ("ios_triple" , "Triple for ios toolchain" , "" )
29
34
30
35
31
36
def exists (env ):
32
- return sys .platform == "darwin" or ios_osxcross . exists ( env )
37
+ return sys .platform == "darwin" or has_ios_osxcross ( )
33
38
34
39
35
40
def generate (env ):
36
41
if env ["arch" ] not in ("universal" , "arm64" , "x86_64" ):
37
- print ("Only universal, arm64, and x86_64 are supported on iOS. Exiting." )
38
- Exit ()
42
+ raise ValueError ("Only universal, arm64, and x86_64 are supported on iOS. Exiting." )
39
43
40
44
if env ["ios_simulator" ]:
41
45
sdk_name = "iphonesimulator"
@@ -64,7 +68,26 @@ def generate(env):
64
68
env ["ENV" ]["PATH" ] = env ["IOS_TOOLCHAIN_PATH" ] + "/Developer/usr/bin/:" + env ["ENV" ]["PATH" ]
65
69
66
70
else :
67
- ios_osxcross .generate (env )
71
+ # OSXCross
72
+ compiler_path = "$IOS_TOOLCHAIN_PATH/usr/bin/${ios_triple}"
73
+ env ["CC" ] = compiler_path + "clang"
74
+ env ["CXX" ] = compiler_path + "clang++"
75
+ env ["AR" ] = compiler_path + "ar"
76
+ env ["RANLIB" ] = compiler_path + "ranlib"
77
+ env ["SHLIBSUFFIX" ] = ".dylib"
78
+
79
+ env .Prepend (
80
+ CPPPATH = [
81
+ "$IOS_SDK_PATH/usr/include" ,
82
+ "$IOS_SDK_PATH/System/Library/Frameworks/AudioUnit.framework/Headers" ,
83
+ ]
84
+ )
85
+
86
+ env .Append (CCFLAGS = ["-stdlib=libc++" ])
87
+
88
+ binpath = os .path .join (env ["IOS_TOOLCHAIN_PATH" ], "usr" , "bin" )
89
+ if binpath not in env ["ENV" ]["PATH" ]:
90
+ env .PrependENVPath ("PATH" , binpath )
68
91
69
92
if env ["arch" ] == "universal" :
70
93
if env ["ios_simulator" ]:
0 commit comments