OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
6 # | 6 # |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
(...skipping 11 matching lines...) Expand all Loading... |
22 help='Build variants (comma-separated).', | 22 help='Build variants (comma-separated).', |
23 metavar='[all,debug,release]', | 23 metavar='[all,debug,release]', |
24 default='debug') | 24 default='debug') |
25 result.add_option("-v", "--verbose", | 25 result.add_option("-v", "--verbose", |
26 help='Verbose output.', | 26 help='Verbose output.', |
27 default=False, action="store_true") | 27 default=False, action="store_true") |
28 result.add_option("--arch", | 28 result.add_option("--arch", |
29 help='Target architectures (comma-separated).', | 29 help='Target architectures (comma-separated).', |
30 metavar='[all,ia32,x64,simarm,arm]', | 30 metavar='[all,ia32,x64,simarm,arm]', |
31 default=utils.GuessArchitecture()) | 31 default=utils.GuessArchitecture()) |
| 32 result.add_option("--toolchainprefix", |
| 33 help='Target toolchain prefix') |
32 result.add_option("-j", | 34 result.add_option("-j", |
33 help='The number of parallel jobs to run.', | 35 help='The number of parallel jobs to run.', |
34 metavar=HOST_CPUS, | 36 metavar=HOST_CPUS, |
35 default=str(HOST_CPUS)) | 37 default=str(HOST_CPUS)) |
36 result.add_option("--devenv", | 38 result.add_option("--devenv", |
37 help='Path containing devenv.com on Windows', | 39 help='Path containing devenv.com on Windows', |
38 default='C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\ID
E') | 40 default='C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\ID
E') |
39 return result | 41 return result |
40 | 42 |
41 | 43 |
42 def ProcessOptions(options): | 44 def ProcessOptions(options): |
43 if options.arch == 'all': | 45 if options.arch == 'all': |
44 options.arch = 'ia32,x64' | 46 options.arch = 'ia32,x64' |
45 if options.mode == 'all': | 47 if options.mode == 'all': |
46 options.mode = 'release,debug' | 48 options.mode = 'release,debug' |
47 options.mode = options.mode.split(',') | 49 options.mode = options.mode.split(',') |
48 options.arch = options.arch.split(',') | 50 options.arch = options.arch.split(',') |
49 for mode in options.mode: | 51 for mode in options.mode: |
50 if not mode in ['debug', 'release']: | 52 if not mode in ['debug', 'release']: |
51 print "Unknown mode %s" % mode | 53 print "Unknown mode %s" % mode |
52 return False | 54 return False |
53 for arch in options.arch: | 55 for arch in options.arch: |
54 if not arch in ['ia32', 'x64', 'simarm', 'arm']: | 56 if not arch in ['ia32', 'x64', 'simarm', 'arm']: |
55 print "Unknown arch %s" % arch | 57 print "Unknown arch %s" % arch |
56 return False | 58 return False |
57 return True | 59 return True |
58 | 60 |
59 | 61 |
60 def setTools(arch): | 62 def setTools(arch, toolchainprefix): |
61 if arch == 'arm': | 63 if arch == 'arm': |
62 toolsOverride = { | 64 toolsOverride = { |
63 "CC" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-gcc", | 65 "CC" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-gcc", |
64 "CXX" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-g++", | 66 "CXX" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-g++", |
65 "AR" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-ar", | 67 "AR" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-ar", |
66 "LINK": armcompilerlocation + "/bin/arm-none-linux-gnueabi-g++", | 68 "LINK": armcompilerlocation + "/bin/arm-none-linux-gnueabi-g++", |
67 "NM" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-nm", | 69 "NM" : armcompilerlocation + "/bin/arm-none-linux-gnueabi-nm", |
68 } | 70 } |
69 return toolsOverride | 71 return toolsOverride |
70 | 72 if toolchainprefix: |
| 73 toolsOverride = { |
| 74 "CC" : toolchainprefix + "-gcc", |
| 75 "CXX" : toolchainprefix + "-g++", |
| 76 "AR" : toolchainprefix + "-ar", |
| 77 "LINK": toolchainprefix + "-g++", |
| 78 "NM" : toolchainprefix + "-nm", |
| 79 } |
| 80 return toolsOverride |
71 | 81 |
72 def Execute(args): | 82 def Execute(args): |
73 print "#" + ' '.join(args) | 83 print "#" + ' '.join(args) |
74 process = subprocess.Popen(args) | 84 process = subprocess.Popen(args) |
75 process.wait() | 85 process.wait() |
76 if process.returncode != 0: | 86 if process.returncode != 0: |
77 raise Error(args[0] + " failed") | 87 raise Error(args[0] + " failed") |
78 | 88 |
79 | 89 |
80 def CurrentDirectoryBaseName(): | 90 def CurrentDirectoryBaseName(): |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 args = [make, | 152 args = [make, |
143 '-j', | 153 '-j', |
144 options.j, | 154 options.j, |
145 'BUILDTYPE=' + build_config, | 155 'BUILDTYPE=' + build_config, |
146 ] | 156 ] |
147 if options.verbose: | 157 if options.verbose: |
148 args += ['V=1'] | 158 args += ['V=1'] |
149 | 159 |
150 args += [target] | 160 args += [target] |
151 | 161 |
152 toolsOverride = setTools(arch) | 162 toolsOverride = setTools(arch, options.toolchainprefix) |
153 if toolsOverride: | 163 if toolsOverride: |
154 for k, v in toolsOverride.iteritems(): | 164 for k, v in toolsOverride.iteritems(): |
155 args.append( k + "=" + v) | 165 args.append( k + "=" + v) |
156 print k + " = " + v | 166 print k + " = " + v |
157 | 167 |
158 print ' '.join(args) | 168 print ' '.join(args) |
159 process = subprocess.Popen(args) | 169 process = subprocess.Popen(args) |
160 process.wait() | 170 process.wait() |
161 if process.returncode != 0: | 171 if process.returncode != 0: |
162 print "BUILD FAILED" | 172 print "BUILD FAILED" |
163 return 1 | 173 return 1 |
164 | 174 |
165 return 0 | 175 return 0 |
166 | 176 |
167 | 177 |
168 if __name__ == '__main__': | 178 if __name__ == '__main__': |
169 sys.exit(Main()) | 179 sys.exit(Main()) |
OLD | NEW |