Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Side by Side Diff: build/mac/find_sdk.py

Issue 10876003: mac: Print an error when doing a branded build and the 10.6 sdk is not around (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: doh Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 10
11 """Prints the lowest locally available SDK version greater than or equal to a 11 """Prints the lowest locally available SDK version greater than or equal to a
12 given minimum sdk version to standard output. 12 given minimum sdk version to standard output.
13 13
14 Usage: 14 Usage:
15 python find_sdk.py 10.6 # Ignores SDKs < 10.6 15 python find_sdk.py 10.6 # Ignores SDKs < 10.6
16 """ 16 """
17 17
18 from optparse import OptionParser
19
20
18 def parse_version(version_str): 21 def parse_version(version_str):
19 """'10.6' => [10, 6]""" 22 """'10.6' => [10, 6]"""
20 return map(int, re.findall(r'(\d+)', version_str)) 23 return map(int, re.findall(r'(\d+)', version_str))
21 24
22 25
23 def main(min_sdk_version): 26 def main():
27 parser = OptionParser()
28 parser.add_option("--verify",
29 action="store_true", dest="verify", default=False,
30 help="return the sdk argument and warn if it doesn't exist")
31 (options, args) = parser.parse_args()
32 min_sdk_version = args[0]
33
24 job = subprocess.Popen(['xcode-select', '-print-path'], 34 job = subprocess.Popen(['xcode-select', '-print-path'],
25 stdout=subprocess.PIPE, 35 stdout=subprocess.PIPE,
26 stderr=subprocess.STDOUT) 36 stderr=subprocess.STDOUT)
27 out, err = job.communicate() 37 out, err = job.communicate()
28 if job.returncode != 0: 38 if job.returncode != 0:
29 print >>sys.stderr, out 39 print >>sys.stderr, out
30 print >>sys.stderr, err 40 print >>sys.stderr, err
31 raise Exception(('Error %d running xcode-select, you might have to run ' 41 raise Exception(('Error %d running xcode-select, you might have to run '
32 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' 42 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
33 'if you are using Xcode 4.') % job.returncode) 43 'if you are using Xcode 4.') % job.returncode)
34 # The Developer folder moved in Xcode 4.3. 44 # The Developer folder moved in Xcode 4.3.
35 xcode43_sdk_path = os.path.join( 45 xcode43_sdk_path = os.path.join(
36 out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs') 46 out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
37 if os.path.isdir(xcode43_sdk_path): 47 if os.path.isdir(xcode43_sdk_path):
38 sdk_dir = xcode43_sdk_path 48 sdk_dir = xcode43_sdk_path
39 else: 49 else:
40 sdk_dir = os.path.join(out.rstrip(), 'SDKs') 50 sdk_dir = os.path.join(out.rstrip(), 'SDKs')
41 sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)] 51 sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)]
42 sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6'] 52 sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
43 sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6'] 53 sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
44 if parse_version(s) >= parse_version(min_sdk_version)] 54 if parse_version(s) >= parse_version(min_sdk_version)]
45 if not sdks: 55 if not sdks:
46 raise Exception('No %s+ SDK found' % min_sdk_version) 56 raise Exception('No %s+ SDK found' % min_sdk_version)
47 print sorted(sdks, key=parse_version)[0] 57 best_sdk = sorted(sdks, key=parse_version)[0]
58
59 if options.verify and best_sdk != min_sdk_version:
60 print >>sys.stderr, ''
61 print >>sys.stderr, ' vvvvvvv'
62 print >>sys.stderr, ''
63 print >>sys.stderr, \
64 'This build requires the %s SDK, but it was not found on your system.' \
65 % min_sdk_version
66 print >>sys.stderr, \
67 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.'
68 print >>sys.stderr, ''
69 print >>sys.stderr, ' ^^^^^^^'
70 print >>sys.stderr, ''
71 return min_sdk_version
72
73 return best_sdk
48 74
49 75
50 if __name__ == '__main__': 76 if __name__ == '__main__':
51 if sys.platform != 'darwin': 77 if sys.platform != 'darwin':
52 raise Exception("This script only runs on Mac") 78 raise Exception("This script only runs on Mac")
53 main(min_sdk_version=sys.argv[1]) 79 print main()
OLDNEW
« no previous file with comments | « build/common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698