diff options
author | Alexandru Croitor <placinta@gmail.com> | 2018-08-24 02:03:57 +0200 |
---|---|---|
committer | Alexandru Croitor <placinta@gmail.com> | 2018-08-27 18:01:05 +0200 |
commit | 362464463015fa4e6690e5733fa3ee0be11fa32f (patch) | |
tree | d82c34e17c0d32e5c9c844d85a92c8952a4a8d35 /platform/osx | |
parent | 9df5ddae296fcdf4788e525f6898f4faa0cd36dd (diff) |
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 'platform/osx')
-rw-r--r-- | platform/osx/detect.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 8a0883eca3..72a57b4e87 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -1,5 +1,6 @@ import os import sys +from methods import detect_darwin_sdk_path def is_active(): @@ -23,6 +24,7 @@ def get_opts(): return [ ('osxcross_sdk', 'OSXCross SDK version', 'darwin14'), + ('MACOS_SDK_PATH', 'Path to the macOS SDK', ''), EnumVariable('debug_symbols', 'Add debugging symbols to release builds', 'yes', ('yes', 'no', 'full')), BoolVariable('separate_debug_symbols', 'Create a separate file containing debugging symbols', False), ] @@ -84,6 +86,10 @@ def configure(env): env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" env.Append(CCFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define + detect_darwin_sdk_path('osx', env) + env.Append(CPPFLAGS=['-isysroot', '$MACOS_SDK_PATH']) + env.Append(LINKFLAGS=['-isysroot', '$MACOS_SDK_PATH']) + else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" |