OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 re | 10 import re |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 result.add_option("-m", "--mode", | 49 result.add_option("-m", "--mode", |
50 help='Build variants (comma-separated).', | 50 help='Build variants (comma-separated).', |
51 metavar='[all,debug,release,product]', | 51 metavar='[all,debug,release,product]', |
52 default='debug') | 52 default='debug') |
53 result.add_option("-v", "--verbose", | 53 result.add_option("-v", "--verbose", |
54 help='Verbose output.', | 54 help='Verbose output.', |
55 default=False, action="store_true") | 55 default=False, action="store_true") |
56 result.add_option("-a", "--arch", | 56 result.add_option("-a", "--arch", |
57 help='Target architectures (comma-separated).', | 57 help='Target architectures (comma-separated).', |
58 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,' | 58 metavar='[all,ia32,x64,simarm,arm,simarmv6,armv6,simarmv5te,armv5te,' |
59 'simmips,mips,simarm64,arm64,]', | 59 'simmips,mips,simarm64,arm64,simdbc,]', |
60 default=utils.GuessArchitecture()) | 60 default=utils.GuessArchitecture()) |
61 result.add_option("--os", | 61 result.add_option("--os", |
62 help='Target OSs (comma-separated).', | 62 help='Target OSs (comma-separated).', |
63 metavar='[all,host,android]', | 63 metavar='[all,host,android]', |
64 default='host') | 64 default='host') |
65 result.add_option("-t", "--toolchain", | 65 result.add_option("-t", "--toolchain", |
66 help='Cross-compiler toolchain path', | 66 help='Cross-compiler toolchain path', |
67 default=None) | 67 default=None) |
68 result.add_option("-j", | 68 result.add_option("-j", |
69 help='The number of parallel jobs to run.', | 69 help='The number of parallel jobs to run.', |
(...skipping 25 matching lines...) Expand all Loading... |
95 options.os = 'host,android' | 95 options.os = 'host,android' |
96 options.mode = options.mode.split(',') | 96 options.mode = options.mode.split(',') |
97 options.arch = options.arch.split(',') | 97 options.arch = options.arch.split(',') |
98 options.os = options.os.split(',') | 98 options.os = options.os.split(',') |
99 for mode in options.mode: | 99 for mode in options.mode: |
100 if not mode in ['debug', 'release', 'product']: | 100 if not mode in ['debug', 'release', 'product']: |
101 print "Unknown mode %s" % mode | 101 print "Unknown mode %s" % mode |
102 return False | 102 return False |
103 for arch in options.arch: | 103 for arch in options.arch: |
104 archs = ['ia32', 'x64', 'simarm', 'arm', 'simarmv6', 'armv6', | 104 archs = ['ia32', 'x64', 'simarm', 'arm', 'simarmv6', 'armv6', |
105 'simarmv5te', 'armv5te', 'simmips', 'mips', 'simarm64', 'arm64',] | 105 'simarmv5te', 'armv5te', 'simmips', 'mips', 'simarm64', 'arm64', |
| 106 'simdbc',] |
106 if not arch in archs: | 107 if not arch in archs: |
107 print "Unknown arch %s" % arch | 108 print "Unknown arch %s" % arch |
108 return False | 109 return False |
109 options.os = [ProcessOsOption(os_name) for os_name in options.os] | 110 options.os = [ProcessOsOption(os_name) for os_name in options.os] |
110 for os_name in options.os: | 111 for os_name in options.os: |
111 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: | 112 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: |
112 print "Unknown os %s" % os_name | 113 print "Unknown os %s" % os_name |
113 return False | 114 return False |
114 if os_name != HOST_OS: | 115 if os_name != HOST_OS: |
115 if os_name != 'android': | 116 if os_name != 'android': |
116 print "Unsupported target os %s" % os_name | 117 print "Unsupported target os %s" % os_name |
117 return False | 118 return False |
118 if not HOST_OS in ['linux']: | 119 if not HOST_OS in ['linux']: |
119 print ("Cross-compilation to %s is not supported on host os %s." | 120 print ("Cross-compilation to %s is not supported on host os %s." |
120 % (os_name, HOST_OS)) | 121 % (os_name, HOST_OS)) |
121 return False | 122 return False |
122 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips']
: | 123 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips', |
| 124 'simdbc',]: |
123 print ("Cross-compilation to %s is not supported for architecture %s." | 125 print ("Cross-compilation to %s is not supported for architecture %s." |
124 % (os_name, arch)) | 126 % (os_name, arch)) |
125 return False | 127 return False |
126 # We have not yet tweaked the v8 dart build to work with the Android | 128 # We have not yet tweaked the v8 dart build to work with the Android |
127 # NDK/SDK, so don't try to build it. | 129 # NDK/SDK, so don't try to build it. |
128 if not args: | 130 if not args: |
129 print "For android builds you must specify a target, such as 'runtime'." | 131 print "For android builds you must specify a target, such as 'runtime'." |
130 return False | 132 return False |
131 return True | 133 return True |
132 | 134 |
133 | 135 |
134 def GetToolchainPrefix(target_os, arch, options): | 136 def GetToolchainPrefix(target_os, arch, options): |
135 if options.toolchain != None: | 137 if options.toolchain != None: |
136 return options.toolchain | 138 return options.toolchain |
137 | 139 |
138 if target_os == 'android': | 140 if target_os == 'android': |
139 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) | 141 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) |
140 if arch == 'arm': | 142 if arch == 'arm' or arch == 'simdbc': |
141 return os.path.join(android_toolchain, 'arm-linux-androideabi') | 143 return os.path.join(android_toolchain, 'arm-linux-androideabi') |
142 if arch == 'arm64': | 144 if arch == 'arm64': |
143 return os.path.join(android_toolchain, 'aarch64-linux-android') | 145 return os.path.join(android_toolchain, 'aarch64-linux-android') |
144 if arch == 'ia32': | 146 if arch == 'ia32': |
145 return os.path.join(android_toolchain, 'i686-linux-android') | 147 return os.path.join(android_toolchain, 'i686-linux-android') |
146 if arch == 'x64': | 148 if arch == 'x64': |
147 return os.path.join(android_toolchain, 'x86_64-linux-android') | 149 return os.path.join(android_toolchain, 'x86_64-linux-android') |
148 | 150 |
149 # If no cross compiler is specified, only try to figure one out on Linux. | 151 # If no cross compiler is specified, only try to figure one out on Linux. |
150 if not HOST_OS in ['linux']: | 152 if not HOST_OS in ['linux']: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 def CheckDirExists(path, docstring): | 192 def CheckDirExists(path, docstring): |
191 if not os.path.isdir(path): | 193 if not os.path.isdir(path): |
192 raise Exception('Could not find %s directory %s' | 194 raise Exception('Could not find %s directory %s' |
193 % (docstring, path)) | 195 % (docstring, path)) |
194 | 196 |
195 | 197 |
196 def GetAndroidToolchainDir(host_os, target_arch): | 198 def GetAndroidToolchainDir(host_os, target_arch): |
197 global THIRD_PARTY_ROOT | 199 global THIRD_PARTY_ROOT |
198 if host_os not in ['linux']: | 200 if host_os not in ['linux']: |
199 raise Exception('Unsupported host os %s' % host_os) | 201 raise Exception('Unsupported host os %s' % host_os) |
200 if target_arch not in ['ia32', 'x64', 'arm', 'arm64']: | 202 if target_arch not in ['ia32', 'x64', 'arm', 'arm64', 'simdbc']: |
201 raise Exception('Unsupported target architecture %s' % target_arch) | 203 raise Exception('Unsupported target architecture %s' % target_arch) |
202 | 204 |
203 # Set up path to the Android NDK. | 205 # Set up path to the Android NDK. |
204 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') | 206 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') |
205 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') | 207 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') |
206 CheckDirExists(android_tools, 'Android tools') | 208 CheckDirExists(android_tools, 'Android tools') |
207 android_ndk_root = os.path.join(android_tools, 'ndk') | 209 android_ndk_root = os.path.join(android_tools, 'ndk') |
208 CheckDirExists(android_ndk_root, 'Android NDK') | 210 CheckDirExists(android_ndk_root, 'Android NDK') |
209 | 211 |
210 # Set up the directory of the Android NDK cross-compiler toolchain. | 212 # Set up the directory of the Android NDK cross-compiler toolchain. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 else: | 558 else: |
557 if BuildOneConfig(options, target, target_os, | 559 if BuildOneConfig(options, target, target_os, |
558 mode, arch, cross_build) != 0: | 560 mode, arch, cross_build) != 0: |
559 return 1 | 561 return 1 |
560 | 562 |
561 return 0 | 563 return 0 |
562 | 564 |
563 | 565 |
564 if __name__ == '__main__': | 566 if __name__ == '__main__': |
565 sys.exit(Main()) | 567 sys.exit(Main()) |
OLD | NEW |