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

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

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 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
« no previous file with comments | « build/mac/edit_xibs.sh ('k') | build/mac/make_more_helpers.sh » ('j') | 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 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
7 # for details. All rights reserved. Use of this source code is governed by a
8 # BSD-style license that can be found in the LICENSE file.
9
10 # This file is a copy of Chromium's src/build/mac/find_sdk.py.
11 # Revision 180337.
12
13 import os
14 import re
15 import subprocess
16 import sys
17
18 """Prints the lowest locally available SDK version greater than or equal to a 6 """Prints the lowest locally available SDK version greater than or equal to a
19 given minimum sdk version to standard output. 7 given minimum sdk version to standard output.
20 8
21 Usage: 9 Usage:
22 python find_sdk.py 10.6 # Ignores SDKs < 10.6 10 python find_sdk.py 10.6 # Ignores SDKs < 10.6
23 """ 11 """
24 12
13 import os
14 import re
15 import subprocess
16 import sys
17
18
25 from optparse import OptionParser 19 from optparse import OptionParser
26 20
27 21
28 def parse_version(version_str): 22 def parse_version(version_str):
29 """'10.6' => [10, 6]""" 23 """'10.6' => [10, 6]"""
30 return map(int, re.findall(r'(\d+)', version_str)) 24 return map(int, re.findall(r'(\d+)', version_str))
31 25
32 26
33 def main(): 27 def main():
34 parser = OptionParser() 28 parser = OptionParser()
35 parser.add_option("--verify", 29 parser.add_option("--verify",
36 action="store_true", dest="verify", default=False, 30 action="store_true", dest="verify", default=False,
37 help="return the sdk argument and warn if it doesn't exist") 31 help="return the sdk argument and warn if it doesn't exist")
38 parser.add_option("--sdk_path", 32 parser.add_option("--sdk_path",
39 action="store", type="string", dest="sdk_path", default="", 33 action="store", type="string", dest="sdk_path", default="",
40 help="user-specified SDK path; bypasses verification") 34 help="user-specified SDK path; bypasses verification")
35 parser.add_option("--print_sdk_path",
36 action="store_true", dest="print_sdk_path", default=False,
37 help="Additionaly print the path the SDK (appears first).")
41 (options, args) = parser.parse_args() 38 (options, args) = parser.parse_args()
42 min_sdk_version = args[0] 39 min_sdk_version = args[0]
43 40
44 job = subprocess.Popen(['xcode-select', '-print-path'], 41 job = subprocess.Popen(['xcode-select', '-print-path'],
45 stdout=subprocess.PIPE, 42 stdout=subprocess.PIPE,
46 stderr=subprocess.STDOUT) 43 stderr=subprocess.STDOUT)
47 out, err = job.communicate() 44 out, err = job.communicate()
48 if job.returncode != 0: 45 if job.returncode != 0:
49 print >>sys.stderr, out 46 print >> sys.stderr, out
50 print >>sys.stderr, err 47 print >> sys.stderr, err
51 raise Exception(('Error %d running xcode-select, you might have to run ' 48 raise Exception(('Error %d running xcode-select, you might have to run '
52 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' 49 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
53 'if you are using Xcode 4.') % job.returncode) 50 'if you are using Xcode 4.') % job.returncode)
54 # The Developer folder moved in Xcode 4.3. 51 # The Developer folder moved in Xcode 4.3.
55 xcode43_sdk_path = os.path.join( 52 xcode43_sdk_path = os.path.join(
56 out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs') 53 out.rstrip(), 'Platforms/MacOSX.platform/Developer/SDKs')
57 if os.path.isdir(xcode43_sdk_path): 54 if os.path.isdir(xcode43_sdk_path):
58 sdk_dir = xcode43_sdk_path 55 sdk_dir = xcode43_sdk_path
59 else: 56 else:
60 sdk_dir = os.path.join(out.rstrip(), 'SDKs') 57 sdk_dir = os.path.join(out.rstrip(), 'SDKs')
61 sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)] 58 sdks = [re.findall('^MacOSX(10\.\d+)\.sdk$', s) for s in os.listdir(sdk_dir)]
62 sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6'] 59 sdks = [s[0] for s in sdks if s] # [['10.5'], ['10.6']] => ['10.5', '10.6']
63 sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6'] 60 sdks = [s for s in sdks # ['10.5', '10.6'] => ['10.6']
64 if parse_version(s) >= parse_version(min_sdk_version)] 61 if parse_version(s) >= parse_version(min_sdk_version)]
65 if not sdks: 62 if not sdks:
66 raise Exception('No %s+ SDK found' % min_sdk_version) 63 raise Exception('No %s+ SDK found' % min_sdk_version)
67 best_sdk = sorted(sdks, key=parse_version)[0] 64 best_sdk = sorted(sdks, key=parse_version)[0]
68 65
69 if options.verify and best_sdk != min_sdk_version and not options.sdk_path: 66 if options.verify and best_sdk != min_sdk_version and not options.sdk_path:
70 print >>sys.stderr, '' 67 print >> sys.stderr, ''
71 print >>sys.stderr, ' vvvvvvv' 68 print >> sys.stderr, ' vvvvvvv'
72 print >>sys.stderr, '' 69 print >> sys.stderr, ''
73 print >>sys.stderr, \ 70 print >> sys.stderr, \
74 'This build requires the %s SDK, but it was not found on your system.' \ 71 'This build requires the %s SDK, but it was not found on your system.' \
75 % min_sdk_version 72 % min_sdk_version
76 print >>sys.stderr, \ 73 print >> sys.stderr, \
77 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.' 74 'Either install it, or explicitly set mac_sdk in your GYP_DEFINES.'
78 print >>sys.stderr, '' 75 print >> sys.stderr, ''
79 print >>sys.stderr, ' ^^^^^^^' 76 print >> sys.stderr, ' ^^^^^^^'
80 print >>sys.stderr, '' 77 print >> sys.stderr, ''
81 return min_sdk_version 78 return min_sdk_version
82 79
80 if options.print_sdk_path:
81 print subprocess.check_output(['xcodebuild', '-version', '-sdk',
82 'macosx' + best_sdk, 'Path']).strip()
83
83 return best_sdk 84 return best_sdk
84 85
85 86
86 if __name__ == '__main__': 87 if __name__ == '__main__':
87 if sys.platform != 'darwin': 88 if sys.platform != 'darwin':
88 raise Exception("This script only runs on Mac") 89 raise Exception("This script only runs on Mac")
89 print main() 90 print main()
OLDNEW
« no previous file with comments | « build/mac/edit_xibs.sh ('k') | build/mac/make_more_helpers.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698