summaryrefslogtreecommitdiffstats
path: root/methods.py
diff options
context:
space:
mode:
authorAlexandru Croitor <placinta@gmail.com>2018-08-24 02:03:57 +0200
committerAlexandru Croitor <placinta@gmail.com>2018-08-27 18:01:05 +0200
commit362464463015fa4e6690e5733fa3ee0be11fa32f (patch)
treed82c34e17c0d32e5c9c844d85a92c8952a4a8d35 /methods.py
parent9df5ddae296fcdf4788e525f6898f4faa0cd36dd (diff)
downloadredot-engine-362464463015fa4e6690e5733fa3ee0be11fa32f.tar.gz
Pass -isysroot to compiler / linker when doing a macOS build
Previously the compiler would use system headers located at /System/Library/Frameworks, which could result in compilation failures due to the headers not always being up-to-date in regards to the latest installed macOS SDK headers that come with Xcode. Fix the issue by passing the SDK path via the -isysroot option to the compiler and linker invocations. If no custom SDK path is given, the build system queries the SDK path via xcrun --show-sdk-path, which returns something similar to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/ /Developer/SDKs/MacOSX.sdk/ Querying via xcrun is now also done for iphone (and simulator) platforms as well. Here is an example of a compilation failure message due to outdated headers: platform/osx/os_osx.mm:1421:41: error: use of undeclared identifier 'NSAppKitVersionNumber10_12'; did you mean 'NSAppKitVersionNumber'? if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ NSAppKitVersionNumber /System/Library/Frameworks/AppKit.framework/Headers/NSApplication.h:26:28: note: 'NSAppKitVersionNumber' declared here
Diffstat (limited to 'methods.py')
-rw-r--r--methods.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/methods.py b/methods.py
index e9450d95e2..23761b521a 100644
--- a/methods.py
+++ b/methods.py
@@ -613,3 +613,27 @@ def CommandNoCache(env, target, sources, command, **args):
result = env.Command(target, sources, command, **args)
env.NoCache(result)
return result
+
+def detect_darwin_sdk_path(platform, env):
+ sdk_name = ''
+ if platform == 'osx':
+ sdk_name = 'macosx'
+ var_name = 'MACOS_SDK_PATH'
+ elif platform == 'iphone':
+ sdk_name = 'iphoneos'
+ var_name = 'IPHONESDK'
+ elif platform == 'iphonesimulator':
+ sdk_name = 'iphonesimulator'
+ var_name = 'IPHONESDK'
+ else:
+ raise Exception("Invalid platform argument passed to detect_darwin_sdk_path")
+
+ if not env[var_name]:
+ try:
+ sdk_path = subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip()
+ if sdk_path:
+ env[var_name] = sdk_path
+ except (subprocess.CalledProcessError, OSError) as e:
+ print("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
+ raise
+