OLD | NEW |
---|---|
(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 best locally available SDK version to standard output.""" | |
12 | |
13 | |
14 def main(): | |
15 job = subprocess.Popen(['xcode-select', '-print-path'], | |
Mark Mentovai
2012/07/27 03:31:30
Didn’t we find that xcode-select wouldn’t be initi
| |
16 stdout=subprocess.PIPE, | |
17 stderr=subprocess.STDOUT) | |
18 out, err = job.communicate() | |
19 if job.returncode != 0: | |
20 print out | |
Mark Mentovai
2012/07/27 03:31:30
Wouldn’t you especially want to print err (to stde
Nico
2012/07/27 18:01:05
Done.
| |
21 raise Exception('Error %d running xcode-select' % job.returncode) | |
22 # The Developer folder moved in Xcode 4.3. | |
23 xcode43_sdk_path = os.path.join( | |
24 out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs') | |
25 if os.path.isdir(xcode43_sdk_path): | |
26 sdk_dir = xcode43_sdk_path | |
27 else: | |
28 sdk_dir = os.path.join(out.rstrip(), 'SDKs') | |
29 sdks = [re.findall('MacOSX(10\.\d+)\.sdk', s) for s in os.listdir(sdk_dir)] | |
Mark Mentovai
2012/07/27 03:31:30
Do you want to anchor the RE at the front and back
Mark Mentovai
2012/07/27 03:31:30
Something in os.listdir(sdk_dir) that doesn’t matc
Nico
2012/07/27 18:01:05
Done.
Nico
2012/07/27 18:01:05
Yes.
| |
30 sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6'] | |
31 sdks = [s for s in sdks if s >= '10.6'] # ['10.5', '10.6'] => ['10.6] | |
Mark Mentovai
2012/07/27 03:31:30
Missing a ' on ['10.6].
Mark Mentovai
2012/07/27 03:31:30
This isn’t really the greatest version comparison.
Nico
2012/07/27 18:01:05
Done.
Nico
2012/07/27 18:01:05
Done.
| |
32 if not sdks: | |
33 raise Exception('No 10.6+ SDK found') | |
34 print sdks[0] | |
Mark Mentovai
2012/07/27 03:31:30
Is there any guarantee of sortedness of SDKs? I do
Nico
2012/07/27 18:01:05
Done.
| |
35 | |
36 | |
37 if __name__ == '__main__': | |
38 if sys.platform == 'darwin': | |
Mark Mentovai
2012/07/27 03:31:30
If you’re going to be conditionalizing when you ca
Nico
2012/07/27 18:01:05
I think it's easier this way.
| |
39 main() | |
OLD | NEW |