Skip to content

Commit 6d19513

Browse files
committed
[SCons] Merge OSXCross tools into platofrm ones
1 parent 3162be2 commit 6d19513

File tree

4 files changed

+54
-65
lines changed

4 files changed

+54
-65
lines changed

tools/ios.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import sys
33
import subprocess
4-
import ios_osxcross
54
from SCons.Variables import *
65

76
if sys.version_info < (3,):
@@ -16,6 +15,10 @@ def decode_utf8(x):
1615
return codecs.utf_8_decode(x)[0]
1716

1817

18+
def has_ios_osxcross():
19+
return "OSXCROSS_IOS" in os.environ
20+
21+
1922
def options(opts):
2023
opts.Add(BoolVariable("ios_simulator", "Target iOS Simulator", False))
2124
opts.Add("ios_min_version", "Target minimum iphoneos/iphonesimulator version", "10.0")
@@ -25,17 +28,18 @@ def options(opts):
2528
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain",
2629
)
2730
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", "")
2934

3035

3136
def exists(env):
32-
return sys.platform == "darwin" or ios_osxcross.exists(env)
37+
return sys.platform == "darwin" or has_ios_osxcross()
3338

3439

3540
def generate(env):
3641
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.")
3943

4044
if env["ios_simulator"]:
4145
sdk_name = "iphonesimulator"
@@ -64,7 +68,26 @@ def generate(env):
6468
env["ENV"]["PATH"] = env["IOS_TOOLCHAIN_PATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"]
6569

6670
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)
6891

6992
if env["arch"] == "universal":
7093
if env["ios_simulator"]:

tools/ios_osxcross.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

tools/macos.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import os
22
import sys
3-
import macos_osxcross
3+
4+
5+
def has_osxcross():
6+
return "OSXCROSS_ROOT" in os.environ
47

58

69
def options(opts):
710
opts.Add("macos_deployment_target", "macOS deployment target", "default")
811
opts.Add("macos_sdk_path", "macOS SDK path", "")
9-
macos_osxcross.options(opts)
12+
if has_osxcross():
13+
opts.Add("osxcross_sdk", "OSXCross SDK version", "darwin16")
1014

1115

1216
def exists(env):
13-
return sys.platform == "darwin" or macos_osxcross.exists(env)
17+
return sys.platform == "darwin" or has_osxcross()
1418

1519

1620
def generate(env):
@@ -23,9 +27,25 @@ def generate(env):
2327
env["CXX"] = "clang++"
2428
env["CC"] = "clang"
2529
else:
26-
# Use osxcross
27-
macos_osxcross.generate(env)
30+
# OSXCross
31+
root = os.environ.get("OSXCROSS_ROOT", "")
32+
if env["arch"] == "arm64":
33+
basecmd = root + "/target/bin/arm64-apple-" + env["osxcross_sdk"] + "-"
34+
else:
35+
basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"
36+
37+
env["CC"] = basecmd + "clang"
38+
env["CXX"] = basecmd + "clang++"
39+
env["AR"] = basecmd + "ar"
40+
env["RANLIB"] = basecmd + "ranlib"
41+
env["AS"] = basecmd + "as"
42+
43+
binpath = os.path.join(root, "target", "bin")
44+
if binpath not in env["ENV"]["PATH"]:
45+
# Add OSXCROSS bin folder to PATH (required for linking).
46+
env.PrependENVPath("PATH", binpath)
2847

48+
# Common flags
2949
if env["arch"] == "universal":
3050
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
3151
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])

tools/macos_osxcross.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)