| Index: test/mac/gyptest-sdkroot.py
|
| diff --git a/test/mac/gyptest-sdkroot.py b/test/mac/gyptest-sdkroot.py
|
| index 20edd365d99312686599d3a67fe93938774553ab..711726ed87c5b2cfc52ac220dea1f281a9fc6044 100644
|
| --- a/test/mac/gyptest-sdkroot.py
|
| +++ b/test/mac/gyptest-sdkroot.py
|
| @@ -17,22 +17,29 @@ import sys
|
| if sys.platform == 'darwin':
|
| test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
|
|
|
| + def GetSDKPath(sdk):
|
| + """Return SDKROOT if the SDK version |sdk| is installed or empty string."""
|
| + DEVNULL = open(os.devnull, 'wb')
|
| + try:
|
| + proc = subprocess.Popen(
|
| + ['xcodebuild', '-version', '-sdk', 'macosx' + sdk, 'Path'],
|
| + stdout=subprocess.PIPE, stderr=DEVNULL)
|
| + return proc.communicate()[0].rstrip('\n')
|
| + finally:
|
| + DEVNULL.close()
|
| +
|
| + def SelectSDK():
|
| + """Select the oldest SDK installed (greater than 10.6)."""
|
| + for sdk in ['10.6', '10.7', '10.8', '10.9']:
|
| + path = GetSDKPath(sdk)
|
| + if path:
|
| + return True, sdk, path
|
| + return False, '', ''
|
| +
|
| # Make sure this works on the bots, which only have the 10.6 sdk, and on
|
| - # dev machines, which usually don't have the 10.6 sdk.
|
| - sdk = '10.6'
|
| - DEVNULL = open(os.devnull, 'wb')
|
| - proc = subprocess.Popen(['xcodebuild', '-version', '-sdk', 'macosx' + sdk],
|
| - stdout=DEVNULL, stderr=DEVNULL)
|
| - proc.communicate()
|
| - DEVNULL.close()
|
| - if proc.returncode:
|
| - sdk = '10.7'
|
| -
|
| - proc = subprocess.Popen(['xcodebuild', '-version',
|
| - '-sdk', 'macosx' + sdk, 'Path'],
|
| - stdout=subprocess.PIPE)
|
| - sdk_path = proc.communicate()[0].rstrip('\n')
|
| - if proc.returncode != 0:
|
| + # dev machines which usually don't have the 10.6 sdk.
|
| + sdk_found, sdk, sdk_path = SelectSDK()
|
| + if not sdk_found:
|
| test.fail_test()
|
|
|
| test.write('sdkroot/test.gyp', test.read('sdkroot/test.gyp') % sdk)
|
|
|