1#!/usr/bin/env python 2 3# Copyright (c) 2012 Google Inc. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7""" 8Verifies that setting SDKROOT works. 9""" 10 11import TestGyp 12 13import os 14import subprocess 15import sys 16 17 18if sys.platform == 'darwin': 19 print "This test is currently disabled: https://crbug.com/483696." 20 sys.exit(0) 21 22 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 23 24 def GetSDKPath(sdk): 25 """Return SDKROOT if the SDK version |sdk| is installed or empty string.""" 26 DEVNULL = open(os.devnull, 'wb') 27 try: 28 proc = subprocess.Popen( 29 ['xcodebuild', '-version', '-sdk', 'macosx' + sdk, 'Path'], 30 stdout=subprocess.PIPE, stderr=DEVNULL) 31 return proc.communicate()[0].rstrip('\n') 32 finally: 33 DEVNULL.close() 34 35 def SelectSDK(): 36 """Select the oldest SDK installed (greater than 10.6).""" 37 for sdk in ['10.6', '10.7', '10.8', '10.9']: 38 path = GetSDKPath(sdk) 39 if path: 40 return True, sdk, path 41 return False, '', '' 42 43 # Make sure this works on the bots, which only have the 10.6 sdk, and on 44 # dev machines which usually don't have the 10.6 sdk. 45 sdk_found, sdk, sdk_path = SelectSDK() 46 if not sdk_found: 47 test.fail_test() 48 49 test.write('sdkroot/test.gyp', test.read('sdkroot/test.gyp') % sdk) 50 51 test.run_gyp('test.gyp', '-D', 'sdk_path=%s' % sdk_path, 52 chdir='sdkroot') 53 test.build('test.gyp', test.ALL, chdir='sdkroot') 54 test.pass_test() 55