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 """ 8 Verifies that setting SDKROOT works. 9 """ 10 11 import TestGyp 12 13 import os 14 import subprocess 15 import sys 16 17 if sys.platform == 'darwin': 18 test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode']) 19 20 # Make sure this works on the bots, which only have the 10.6 sdk, and on 21 # dev machines, who usually don't have the 10.6 sdk. 22 sdk = '10.6' 23 DEVNULL = open(os.devnull, 'wb') 24 proc = subprocess.Popen(['xcodebuild', '-version', '-sdk', 'macosx' + sdk], 25 stdout=DEVNULL, stderr=DEVNULL) 26 proc.communicate() 27 DEVNULL.close() 28 if proc.returncode: 29 sdk = '10.7' 30 31 proc = subprocess.Popen(['xcodebuild', '-version', 32 '-sdk', 'macosx' + sdk, 'Path'], 33 stdout=subprocess.PIPE) 34 sdk_path = proc.communicate()[0].rstrip('\n') 35 if proc.returncode != 0: 36 test.fail_test() 37 38 test.write('sdkroot/test.gyp', test.read('sdkroot/test.gyp') % sdk) 39 40 test.run_gyp('test.gyp', '-D', 'sdk_path=%s' % sdk_path, 41 chdir='sdkroot') 42 test.build('test.gyp', test.ALL, chdir='sdkroot') 43 test.pass_test() 44