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

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

Issue 10824055: mac: Let mac_sdk default to the oldest available SDK that's at least 10.6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: totally 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
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 import os
7 import re
8 import subprocess
9 import sys
10
11 """Prints the lowest locally available SDK version greater than or equal to a
12 given minimum sdk version to standard output.
13
14 Usage:
15 python find_sdk.py 10.6 # Ignores SDKs < 10.6
16 """
17
18 def parse_version(version_str):
19 """'10.6' => [10, 6]"""
20 return map(int, re.findall(r'(\d+)', version_str))
21
22
23 def main(min_sdk_version):
24 job = subprocess.Popen(['xcode-select', '-print-path'],
25 stdout=subprocess.PIPE,
26 stderr=subprocess.STDOUT)
27 out, err = job.communicate()
28 if job.returncode != 0:
29 print >>sys.stderr, out
30 print >>sys.stderr, err
31 raise Exception(('Error %d running xcode-select, you might have to run '
32 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
33 'if you are using Xcode 4.') % job.returncode)
34 # The Developer folder moved in Xcode 4.3.
35 xcode43_sdk_path = os.path.join(
36 out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
37 if os.path.isdir(xcode43_sdk_path):
38 sdk_dir = xcode43_sdk_path
39 else:
40 sdk_dir = os.path.join(out.rstrip(), 'SDKs')
41 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']
43 sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
44 if parse_version(s) >= parse_version(min_sdk_version)]
45 if not sdks:
46 raise Exception('No %s+ SDK found' % min_sdk_version)
47 print sorted(sdks, key=parse_version)[0]
48
49
50 if __name__ == '__main__':
51 if sys.platform != 'darwin':
52 raise Exception("This script only runs on Mac")
53 main(min_sdk_version=sys.argv[1])
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