Skip to content

Commit

Permalink
fix gyp to work on macOS without XCode
Browse files Browse the repository at this point in the history
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: nodejs/node#1325
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

Change-Id: I89ce12a8c92db6172f2f13d168233504d6de57ab
  • Loading branch information
refack committed May 1, 2017
1 parent a478c1a commit 52f9f07
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pylib/gyp/xcode_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 52f9f07

Please sign in to comment.