| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 print "Unknown os %s" % os_name | 112 print "Unknown os %s" % os_name |
| 113 return False | 113 return False |
| 114 if os_name != HOST_OS: | 114 if os_name != HOST_OS: |
| 115 if os_name != 'android': | 115 if os_name != 'android': |
| 116 print "Unsupported target os %s" % os_name | 116 print "Unsupported target os %s" % os_name |
| 117 return False | 117 return False |
| 118 if not HOST_OS in ['linux']: | 118 if not HOST_OS in ['linux']: |
| 119 print ("Cross-compilation to %s is not supported on host os %s." | 119 print ("Cross-compilation to %s is not supported on host os %s." |
| 120 % (os_name, HOST_OS)) | 120 % (os_name, HOST_OS)) |
| 121 return False | 121 return False |
| 122 if not arch in ['ia32', 'arm', 'armv6', 'armv5te', 'arm64', 'mips']: | 122 if not arch in ['ia32', 'x64', 'arm', 'armv6', 'armv5te', 'arm64', 'mips']
: |
| 123 print ("Cross-compilation to %s is not supported for architecture %s." | 123 print ("Cross-compilation to %s is not supported for architecture %s." |
| 124 % (os_name, arch)) | 124 % (os_name, arch)) |
| 125 return False | 125 return False |
| 126 # We have not yet tweaked the v8 dart build to work with the Android | 126 # We have not yet tweaked the v8 dart build to work with the Android |
| 127 # NDK/SDK, so don't try to build it. | 127 # NDK/SDK, so don't try to build it. |
| 128 if not args: | 128 if not args: |
| 129 print "For android builds you must specify a target, such as 'runtime'." | 129 print "For android builds you must specify a target, such as 'runtime'." |
| 130 return False | 130 return False |
| 131 return True | 131 return True |
| 132 | 132 |
| 133 | 133 |
| 134 def GetToolchainPrefix(target_os, arch, options): | 134 def GetToolchainPrefix(target_os, arch, options): |
| 135 if options.toolchain != None: | 135 if options.toolchain != None: |
| 136 return options.toolchain | 136 return options.toolchain |
| 137 | 137 |
| 138 if target_os == 'android': | 138 if target_os == 'android': |
| 139 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) | 139 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) |
| 140 if arch == 'arm': | 140 if arch == 'arm': |
| 141 return os.path.join(android_toolchain, 'arm-linux-androideabi') | 141 return os.path.join(android_toolchain, 'arm-linux-androideabi') |
| 142 if arch == 'arm64': | 142 if arch == 'arm64': |
| 143 return os.path.join(android_toolchain, 'aarch64-linux-android') | 143 return os.path.join(android_toolchain, 'aarch64-linux-android') |
| 144 if arch == 'ia32': | 144 if arch == 'ia32': |
| 145 return os.path.join(android_toolchain, 'i686-linux-android') | 145 return os.path.join(android_toolchain, 'i686-linux-android') |
| 146 if arch == 'x64': |
| 147 return os.path.join(android_toolchain, 'x86_64-linux-android') |
| 146 | 148 |
| 147 # If no cross compiler is specified, only try to figure one out on Linux. | 149 # If no cross compiler is specified, only try to figure one out on Linux. |
| 148 if not HOST_OS in ['linux']: | 150 if not HOST_OS in ['linux']: |
| 149 raise Exception('Unless --toolchain is used cross-building is only ' | 151 raise Exception('Unless --toolchain is used cross-building is only ' |
| 150 'supported on Linux.') | 152 'supported on Linux.') |
| 151 | 153 |
| 152 # For ARM Linux, by default use the Linux distribution's cross-compiler. | 154 # For ARM Linux, by default use the Linux distribution's cross-compiler. |
| 153 if arch == 'arm': | 155 if arch == 'arm': |
| 154 # To use a non-hf compiler, specify on the command line with --toolchain. | 156 # To use a non-hf compiler, specify on the command line with --toolchain. |
| 155 return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/arm-linux-gnueabihf") | 157 return (DEFAULT_ARM_CROSS_COMPILER_PATH + "/arm-linux-gnueabihf") |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 def CheckDirExists(path, docstring): | 190 def CheckDirExists(path, docstring): |
| 189 if not os.path.isdir(path): | 191 if not os.path.isdir(path): |
| 190 raise Exception('Could not find %s directory %s' | 192 raise Exception('Could not find %s directory %s' |
| 191 % (docstring, path)) | 193 % (docstring, path)) |
| 192 | 194 |
| 193 | 195 |
| 194 def GetAndroidToolchainDir(host_os, target_arch): | 196 def GetAndroidToolchainDir(host_os, target_arch): |
| 195 global THIRD_PARTY_ROOT | 197 global THIRD_PARTY_ROOT |
| 196 if host_os not in ['linux']: | 198 if host_os not in ['linux']: |
| 197 raise Exception('Unsupported host os %s' % host_os) | 199 raise Exception('Unsupported host os %s' % host_os) |
| 198 if target_arch not in ['ia32', 'arm', 'arm64']: | 200 if target_arch not in ['ia32', 'x64', 'arm', 'arm64']: |
| 199 raise Exception('Unsupported target architecture %s' % target_arch) | 201 raise Exception('Unsupported target architecture %s' % target_arch) |
| 200 | 202 |
| 201 # Set up path to the Android NDK. | 203 # Set up path to the Android NDK. |
| 202 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') | 204 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') |
| 203 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') | 205 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') |
| 204 CheckDirExists(android_tools, 'Android tools') | 206 CheckDirExists(android_tools, 'Android tools') |
| 205 android_ndk_root = os.path.join(android_tools, 'ndk') | 207 android_ndk_root = os.path.join(android_tools, 'ndk') |
| 206 CheckDirExists(android_ndk_root, 'Android NDK') | 208 CheckDirExists(android_ndk_root, 'Android NDK') |
| 207 | 209 |
| 208 # Set up the directory of the Android NDK cross-compiler toolchain. | 210 # Set up the directory of the Android NDK cross-compiler toolchain. |
| 209 toolchain_arch = 'arm-linux-androideabi-4.9' | 211 toolchain_arch = 'arm-linux-androideabi-4.9' |
| 210 if target_arch == 'arm64': | 212 if target_arch == 'arm64': |
| 211 toolchain_arch = 'aarch64-linux-android-4.9' | 213 toolchain_arch = 'aarch64-linux-android-4.9' |
| 212 if target_arch == 'ia32': | 214 if target_arch == 'ia32': |
| 213 toolchain_arch = 'x86-4.9' | 215 toolchain_arch = 'x86-4.9' |
| 216 if target_arch == 'x64': |
| 217 toolchain_arch = 'x86_64-4.9' |
| 214 toolchain_dir = 'linux-x86_64' | 218 toolchain_dir = 'linux-x86_64' |
| 215 android_toolchain = os.path.join(android_ndk_root, | 219 android_toolchain = os.path.join(android_ndk_root, |
| 216 'toolchains', toolchain_arch, | 220 'toolchains', toolchain_arch, |
| 217 'prebuilt', toolchain_dir, 'bin') | 221 'prebuilt', toolchain_dir, 'bin') |
| 218 CheckDirExists(android_toolchain, 'Android toolchain') | 222 CheckDirExists(android_toolchain, 'Android toolchain') |
| 219 | 223 |
| 220 return android_toolchain | 224 return android_toolchain |
| 221 | 225 |
| 222 | 226 |
| 223 def Execute(args): | 227 def Execute(args): |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 else: | 556 else: |
| 553 if BuildOneConfig(options, target, target_os, | 557 if BuildOneConfig(options, target, target_os, |
| 554 mode, arch, cross_build) != 0: | 558 mode, arch, cross_build) != 0: |
| 555 return 1 | 559 return 1 |
| 556 | 560 |
| 557 return 0 | 561 return 0 |
| 558 | 562 |
| 559 | 563 |
| 560 if __name__ == '__main__': | 564 if __name__ == '__main__': |
| 561 sys.exit(Main()) | 565 sys.exit(Main()) |
| OLD | NEW |