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

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

Issue 1840323002: Add mac toolchain script support to find_sdk script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create SetToolchainEnvironment method Created 4 years, 8 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/gyp_environment.py ('k') | build/mac_toolchain.py » ('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 """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
7 given minimum sdk version to standard output. 7 given minimum sdk version to standard output.
8 8
9 Usage: 9 Usage:
10 python find_sdk.py 10.6 # Ignores SDKs < 10.6 10 python find_sdk.py 10.6 # Ignores SDKs < 10.6
11 """ 11 """
12 12
13 import os 13 import os
14 import re 14 import re
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 17
18 sys.path.append(os.path.dirname(os.path.dirname(__file__)))
19 import mac_toolchain
18 20
19 from optparse import OptionParser 21 from optparse import OptionParser
20 22
21 23
22 def parse_version(version_str): 24 def parse_version(version_str):
23 """'10.6' => [10, 6]""" 25 """'10.6' => [10, 6]"""
24 return map(int, re.findall(r'(\d+)', version_str)) 26 return map(int, re.findall(r'(\d+)', version_str))
25 27
26 28
27 def main(): 29 def main():
28 parser = OptionParser() 30 parser = OptionParser()
29 parser.add_option("--verify", 31 parser.add_option("--verify",
30 action="store_true", dest="verify", default=False, 32 action="store_true", dest="verify", default=False,
31 help="return the sdk argument and warn if it doesn't exist") 33 help="return the sdk argument and warn if it doesn't exist")
32 parser.add_option("--sdk_path", 34 parser.add_option("--sdk_path",
33 action="store", type="string", dest="sdk_path", default="", 35 action="store", type="string", dest="sdk_path", default="",
34 help="user-specified SDK path; bypasses verification") 36 help="user-specified SDK path; bypasses verification")
35 parser.add_option("--print_sdk_path", 37 parser.add_option("--print_sdk_path",
36 action="store_true", dest="print_sdk_path", default=False, 38 action="store_true", dest="print_sdk_path", default=False,
37 help="Additionaly print the path the SDK (appears first).") 39 help="Additionaly print the path the SDK (appears first).")
38 options, args = parser.parse_args() 40 options, args = parser.parse_args()
39 if len(args) != 1: 41 if len(args) != 1:
40 parser.error('Please specify a minimum SDK version') 42 parser.error('Please specify a minimum SDK version')
41 min_sdk_version = args[0] 43 min_sdk_version = args[0]
42 44
45 # Try using the toolchain in mac_files.
46 mac_toolchain.SetToolchainEnvironment()
47
43 job = subprocess.Popen(['xcode-select', '-print-path'], 48 job = subprocess.Popen(['xcode-select', '-print-path'],
44 stdout=subprocess.PIPE, 49 stdout=subprocess.PIPE,
45 stderr=subprocess.STDOUT) 50 stderr=subprocess.STDOUT)
46 out, err = job.communicate() 51 out, err = job.communicate()
47 if job.returncode != 0: 52 if job.returncode != 0:
48 print >> sys.stderr, out 53 print >> sys.stderr, out
49 print >> sys.stderr, err 54 print >> sys.stderr, err
50 raise Exception(('Error %d running xcode-select, you might have to run ' 55 raise Exception(('Error %d running xcode-select, you might have to run '
51 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| ' 56 '|sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer| '
52 'if you are using Xcode 4.') % job.returncode) 57 'if you are using Xcode 4.') % job.returncode)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 'macosx' + best_sdk, 'Path']).strip() 89 'macosx' + best_sdk, 'Path']).strip()
85 90
86 return best_sdk 91 return best_sdk
87 92
88 93
89 if __name__ == '__main__': 94 if __name__ == '__main__':
90 if sys.platform != 'darwin': 95 if sys.platform != 'darwin':
91 raise Exception("This script only runs on Mac") 96 raise Exception("This script only runs on Mac")
92 print main() 97 print main()
93 sys.exit(0) 98 sys.exit(0)
OLDNEW
« no previous file with comments | « build/gyp_environment.py ('k') | build/mac_toolchain.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698