From 67f17a0fda6e08554c88a8784d1782fc8040fac1 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Wed, 15 Oct 2014 18:56:37 -0700 Subject: [PATCH] Fix SDK detection to work with modern versions of Xcode. This finds the the OS X SDK directory by using xcrun and known fallbacks; users shouldn't be symlinking /Developer. --- ext/toolchain/commands1.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ext/toolchain/commands1.py b/ext/toolchain/commands1.py index 1eee3a41..5374bcd2 100644 --- a/ext/toolchain/commands1.py +++ b/ext/toolchain/commands1.py @@ -554,7 +554,24 @@ class InternalCommands: return (major, minor, rev) def getMacSdkDir(self): - return "/Developer/SDKs/MacOSX" + self.macSdk + ".sdk" + sdkName = "macosx" + self.macSdk + + # Ideally we'll use xcrun (which is influenced by $DEVELOPER_DIR), then try a couple + # fallbacks to known paths if xcrun is not available + status, sdkPath = commands.getstatusoutput("xcrun --show-sdk-path --sdk " + sdkName) + if status == 0 and sdkPath: + return sdkPath + + developerDir = os.getenv("DEVELOPER_DIR") + if not developerDir: + developerDir = "/Applications/Xcode.app/Contents/Developer" + + sdkDirName = sdkName.replace("macosx", "MacOSX") + sdkPath = developerDir + "/Platforms/MacOSX.platform/Developer/SDKs/" + sdkDirName + ".sdk" + if os.path.exists(sdkPath): + return sdkPath + + return "/Developer/SDKs/" + sdkDirName + ".sdk" # http://tinyurl.com/cs2rxxb def fixCmakeEclipseBug(self):