| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 print "Unknown os %s" % os_name | 102 print "Unknown os %s" % os_name |
| 103 return False | 103 return False |
| 104 if os_name != HOST_OS: | 104 if os_name != HOST_OS: |
| 105 if os_name != 'android': | 105 if os_name != 'android': |
| 106 print "Unsupported target os %s" % os_name | 106 print "Unsupported target os %s" % os_name |
| 107 return False | 107 return False |
| 108 if not HOST_OS in ['linux']: | 108 if not HOST_OS in ['linux']: |
| 109 print ("Cross-compilation to %s is not supported on host os %s." | 109 print ("Cross-compilation to %s is not supported on host os %s." |
| 110 % (os_name, HOST_OS)) | 110 % (os_name, HOST_OS)) |
| 111 return False | 111 return False |
| 112 if not arch in ['ia32', 'arm', 'mips']: | 112 if not arch in ['ia32', 'arm', 'arm64', 'mips']: |
| 113 print ("Cross-compilation to %s is not supported for architecture %s." | 113 print ("Cross-compilation to %s is not supported for architecture %s." |
| 114 % (os_name, arch)) | 114 % (os_name, arch)) |
| 115 return False | 115 return False |
| 116 # We have not yet tweaked the v8 dart build to work with the Android | 116 # We have not yet tweaked the v8 dart build to work with the Android |
| 117 # NDK/SDK, so don't try to build it. | 117 # NDK/SDK, so don't try to build it. |
| 118 if not args: | 118 if not args: |
| 119 print "For android builds you must specify a target, such as 'runtime'." | 119 print "For android builds you must specify a target, such as 'runtime'." |
| 120 return False | 120 return False |
| 121 return True | 121 return True |
| 122 | 122 |
| 123 | 123 |
| 124 def GetToolchainPrefix(target_os, arch, options): | 124 def GetToolchainPrefix(target_os, arch, options): |
| 125 if options.toolchain != None: | 125 if options.toolchain != None: |
| 126 return options.toolchain | 126 return options.toolchain |
| 127 | 127 |
| 128 if target_os == 'android': | 128 if target_os == 'android': |
| 129 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) | 129 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) |
| 130 if arch == 'arm': | 130 if arch == 'arm': |
| 131 return os.path.join(android_toolchain, 'arm-linux-androideabi') | 131 return os.path.join(android_toolchain, 'arm-linux-androideabi') |
| 132 if arch == 'arm64': |
| 133 return os.path.join(android_toolchain, 'aarch64-linux-android') |
| 132 if arch == 'ia32': | 134 if arch == 'ia32': |
| 133 return os.path.join(android_toolchain, 'i686-linux-android') | 135 return os.path.join(android_toolchain, 'i686-linux-android') |
| 134 | 136 |
| 135 # If no cross compiler is specified, only try to figure one out on Linux. | 137 # If no cross compiler is specified, only try to figure one out on Linux. |
| 136 if not HOST_OS in ['linux']: | 138 if not HOST_OS in ['linux']: |
| 137 raise Exception('Unless --toolchain is used cross-building is only ' | 139 raise Exception('Unless --toolchain is used cross-building is only ' |
| 138 'supported on Linux.') | 140 'supported on Linux.') |
| 139 | 141 |
| 140 # For ARM Linux, by default use the Linux distribution's cross-compiler. | 142 # For ARM Linux, by default use the Linux distribution's cross-compiler. |
| 141 if arch == 'arm': | 143 if arch == 'arm': |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 def CheckDirExists(path, docstring): | 175 def CheckDirExists(path, docstring): |
| 174 if not os.path.isdir(path): | 176 if not os.path.isdir(path): |
| 175 raise Exception('Could not find %s directory %s' | 177 raise Exception('Could not find %s directory %s' |
| 176 % (docstring, path)) | 178 % (docstring, path)) |
| 177 | 179 |
| 178 | 180 |
| 179 def GetAndroidToolchainDir(host_os, target_arch): | 181 def GetAndroidToolchainDir(host_os, target_arch): |
| 180 global THIRD_PARTY_ROOT | 182 global THIRD_PARTY_ROOT |
| 181 if host_os not in ['linux']: | 183 if host_os not in ['linux']: |
| 182 raise Exception('Unsupported host os %s' % host_os) | 184 raise Exception('Unsupported host os %s' % host_os) |
| 183 if target_arch not in ['ia32', 'arm']: | 185 if target_arch not in ['ia32', 'arm', 'arm64']: |
| 184 raise Exception('Unsupported target architecture %s' % target_arch) | 186 raise Exception('Unsupported target architecture %s' % target_arch) |
| 185 | 187 |
| 186 # Set up path to the Android NDK. | 188 # Set up path to the Android NDK. |
| 187 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') | 189 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') |
| 188 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') | 190 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') |
| 189 CheckDirExists(android_tools, 'Android tools') | 191 CheckDirExists(android_tools, 'Android tools') |
| 190 android_ndk_root = os.path.join(android_tools, 'ndk') | 192 android_ndk_root = os.path.join(android_tools, 'ndk') |
| 191 CheckDirExists(android_ndk_root, 'Android NDK') | 193 CheckDirExists(android_ndk_root, 'Android NDK') |
| 192 | 194 |
| 193 # Set up the directory of the Android NDK cross-compiler toolchain. | 195 # Set up the directory of the Android NDK cross-compiler toolchain. |
| 194 toolchain_arch = 'arm-linux-androideabi-4.6' | 196 toolchain_arch = 'arm-linux-androideabi-4.6' |
| 197 if target_arch == 'arm64': |
| 198 toolchain_arch = 'aarch64-linux-android-4.9' |
| 195 if target_arch == 'ia32': | 199 if target_arch == 'ia32': |
| 196 toolchain_arch = 'x86-4.6' | 200 toolchain_arch = 'x86-4.6' |
| 197 toolchain_dir = 'linux-x86_64' | 201 toolchain_dir = 'linux-x86_64' |
| 198 android_toolchain = os.path.join(android_ndk_root, | 202 android_toolchain = os.path.join(android_ndk_root, |
| 199 'toolchains', toolchain_arch, | 203 'toolchains', toolchain_arch, |
| 200 'prebuilt', toolchain_dir, 'bin') | 204 'prebuilt', toolchain_dir, 'bin') |
| 201 CheckDirExists(android_toolchain, 'Android toolchain') | 205 CheckDirExists(android_toolchain, 'Android toolchain') |
| 202 | 206 |
| 203 return android_toolchain | 207 return android_toolchain |
| 204 | 208 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 else: | 539 else: |
| 536 if BuildOneConfig(options, target, target_os, | 540 if BuildOneConfig(options, target, target_os, |
| 537 mode, arch, cross_build) != 0: | 541 mode, arch, cross_build) != 0: |
| 538 return 1 | 542 return 1 |
| 539 | 543 |
| 540 return 0 | 544 return 0 |
| 541 | 545 |
| 542 | 546 |
| 543 if __name__ == '__main__': | 547 if __name__ == '__main__': |
| 544 sys.exit(Main()) | 548 sys.exit(Main()) |
| OLD | NEW |