From 52f9f07a04de927770015f985eb338f0a745bfcf Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Mon, 1 May 2017 15:51:13 -0400 Subject: [PATCH] fix gyp to work on macOS without XCode Most builds are possible with just the "Command Line Tools for XCode" nodejs has extensive experience with this scenario BUG=gyp:477 nodejs PR-URL: https://github.com/iojs/io.js/pull/1325 Reviewed-By: Fedor Indutny Reviewed-By: Ben Noordhuis Change-Id: I89ce12a8c92db6172f2f13d168233504d6de57ab --- pylib/gyp/xcode_emulation.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pylib/gyp/xcode_emulation.py b/pylib/gyp/xcode_emulation.py index dba8e769..06ed8efc 100644 --- a/pylib/gyp/xcode_emulation.py +++ b/pylib/gyp/xcode_emulation.py @@ -645,9 +645,10 @@ def GetCflags(self, configname, arch=None): cflags += self._Settings().get('WARNING_CFLAGS', []) - platform_root = self._XcodePlatformPath(configname) - if platform_root and self._IsXCTest(): - cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') + if self._IsXCTest(): + platform_root = self._XcodePlatformPath(configname) + if platform_root: + cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') if sdk_root: framework_root = sdk_root @@ -913,10 +914,11 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None): for directory in framework_dirs: ldflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root)) - platform_root = self._XcodePlatformPath(configname) - if sdk_root and platform_root and self._IsXCTest(): - ldflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') - ldflags.append('-framework XCTest') + if sdk_root: + platform_root = self._XcodePlatformPath(configname) + if platform_root and self._IsXCTest(): + ldflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') + ldflags.append('-framework XCTest') is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension() if sdk_root and is_extension: @@ -1448,7 +1450,6 @@ def GetStdout(cmdlist): job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE) out = job.communicate()[0] if job.returncode != 0: - sys.stderr.write(out + '\n') raise GypError('Error %d running %s' % (job.returncode, cmdlist[0])) return out.rstrip('\n') @@ -1662,6 +1663,8 @@ def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration, sdk_root = xcode_settings._SdkRoot(configuration) if not sdk_root: sdk_root = xcode_settings._XcodeSdkPath('') + if sdk_root is None: + sdk_root = '' env['SDKROOT'] = sdk_root if not additional_settings: