| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 'simdbc', 'simdbc64'] |
| 107 if not arch in archs: | 107 if not arch in archs: |
| 108 print "Unknown arch %s" % arch | 108 print "Unknown arch %s" % arch |
| 109 return False | 109 return False |
| 110 options.os = [ProcessOsOption(os_name) for os_name in options.os] | 110 options.os = [ProcessOsOption(os_name) for os_name in options.os] |
| 111 for os_name in options.os: | 111 for os_name in options.os: |
| 112 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: | 112 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: |
| 113 print "Unknown os %s" % os_name | 113 print "Unknown os %s" % os_name |
| 114 return False | 114 return False |
| 115 if os_name != HOST_OS: | 115 if os_name != HOST_OS: |
| 116 if os_name != 'android': | 116 if os_name != 'android': |
| 117 print "Unsupported target os %s" % os_name | 117 print "Unsupported target os %s" % os_name |
| 118 return False | 118 return False |
| 119 if not HOST_OS in ['linux']: | 119 if not HOST_OS in ['linux']: |
| 120 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." |
| 121 % (os_name, HOST_OS)) | 121 % (os_name, HOST_OS)) |
| 122 return False | 122 return False |
| 123 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',]: | 124 'simdbc', 'simdbc64']: |
| 125 print ("Cross-compilation to %s is not supported for architecture %s." | 125 print ("Cross-compilation to %s is not supported for architecture %s." |
| 126 % (os_name, arch)) | 126 % (os_name, arch)) |
| 127 return False | 127 return False |
| 128 # 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 |
| 129 # NDK/SDK, so don't try to build it. | 129 # NDK/SDK, so don't try to build it. |
| 130 if not args: | 130 if not args: |
| 131 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'." |
| 132 return False | 132 return False |
| 133 return True | 133 return True |
| 134 | 134 |
| 135 | 135 |
| 136 def GetToolchainPrefix(target_os, arch, options): | 136 def GetToolchainPrefix(target_os, arch, options): |
| 137 if options.toolchain != None: | 137 if options.toolchain != None: |
| 138 return options.toolchain | 138 return options.toolchain |
| 139 | 139 |
| 140 if target_os == 'android': | 140 if target_os == 'android': |
| 141 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) | 141 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) |
| 142 if arch == 'arm' or arch == 'simdbc': | 142 if arch == 'arm' or arch == 'simdbc': |
| 143 return os.path.join(android_toolchain, 'arm-linux-androideabi') | 143 return os.path.join(android_toolchain, 'arm-linux-androideabi') |
| 144 if arch == 'arm64': | 144 if arch == 'arm64' or arch == 'simdbc64': |
| 145 return os.path.join(android_toolchain, 'aarch64-linux-android') | 145 return os.path.join(android_toolchain, 'aarch64-linux-android') |
| 146 if arch == 'ia32': | 146 if arch == 'ia32': |
| 147 return os.path.join(android_toolchain, 'i686-linux-android') | 147 return os.path.join(android_toolchain, 'i686-linux-android') |
| 148 if arch == 'x64': | 148 if arch == 'x64': |
| 149 return os.path.join(android_toolchain, 'x86_64-linux-android') | 149 return os.path.join(android_toolchain, 'x86_64-linux-android') |
| 150 | 150 |
| 151 # 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. |
| 152 if not HOST_OS in ['linux']: | 152 if not HOST_OS in ['linux']: |
| 153 raise Exception('Unless --toolchain is used cross-building is only ' | 153 raise Exception('Unless --toolchain is used cross-building is only ' |
| 154 'supported on Linux.') | 154 'supported on Linux.') |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 def CheckDirExists(path, docstring): | 192 def CheckDirExists(path, docstring): |
| 193 if not os.path.isdir(path): | 193 if not os.path.isdir(path): |
| 194 raise Exception('Could not find %s directory %s' | 194 raise Exception('Could not find %s directory %s' |
| 195 % (docstring, path)) | 195 % (docstring, path)) |
| 196 | 196 |
| 197 | 197 |
| 198 def GetAndroidToolchainDir(host_os, target_arch): | 198 def GetAndroidToolchainDir(host_os, target_arch): |
| 199 global THIRD_PARTY_ROOT | 199 global THIRD_PARTY_ROOT |
| 200 if host_os not in ['linux']: | 200 if host_os not in ['linux']: |
| 201 raise Exception('Unsupported host os %s' % host_os) | 201 raise Exception('Unsupported host os %s' % host_os) |
| 202 if target_arch not in ['ia32', 'x64', 'arm', 'arm64', 'simdbc']: | 202 if target_arch not in ['ia32', 'x64', 'arm', 'arm64', 'simdbc', 'simdbc64']: |
| 203 raise Exception('Unsupported target architecture %s' % target_arch) | 203 raise Exception('Unsupported target architecture %s' % target_arch) |
| 204 | 204 |
| 205 # Set up path to the Android NDK. | 205 # Set up path to the Android NDK. |
| 206 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') | 206 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') |
| 207 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') | 207 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') |
| 208 CheckDirExists(android_tools, 'Android tools') | 208 CheckDirExists(android_tools, 'Android tools') |
| 209 android_ndk_root = os.path.join(android_tools, 'ndk') | 209 android_ndk_root = os.path.join(android_tools, 'ndk') |
| 210 CheckDirExists(android_ndk_root, 'Android NDK') | 210 CheckDirExists(android_ndk_root, 'Android NDK') |
| 211 | 211 |
| 212 # Set up the directory of the Android NDK cross-compiler toolchain. | 212 # Set up the directory of the Android NDK cross-compiler toolchain. |
| 213 toolchain_arch = 'arm-linux-androideabi-4.9' | 213 toolchain_arch = 'arm-linux-androideabi-4.9' |
| 214 if target_arch == 'arm64': | 214 if target_arch == 'arm64' or target_arch == 'simdbc64': |
| 215 toolchain_arch = 'aarch64-linux-android-4.9' | 215 toolchain_arch = 'aarch64-linux-android-4.9' |
| 216 if target_arch == 'ia32': | 216 if target_arch == 'ia32': |
| 217 toolchain_arch = 'x86-4.9' | 217 toolchain_arch = 'x86-4.9' |
| 218 if target_arch == 'x64': | 218 if target_arch == 'x64': |
| 219 toolchain_arch = 'x86_64-4.9' | 219 toolchain_arch = 'x86_64-4.9' |
| 220 toolchain_dir = 'linux-x86_64' | 220 toolchain_dir = 'linux-x86_64' |
| 221 android_toolchain = os.path.join(android_ndk_root, | 221 android_toolchain = os.path.join(android_ndk_root, |
| 222 'toolchains', toolchain_arch, | 222 'toolchains', toolchain_arch, |
| 223 'prebuilt', toolchain_dir, 'bin') | 223 'prebuilt', toolchain_dir, 'bin') |
| 224 CheckDirExists(android_toolchain, 'Android toolchain') | 224 CheckDirExists(android_toolchain, 'Android toolchain') |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 else: | 558 else: |
| 559 if BuildOneConfig(options, target, target_os, | 559 if BuildOneConfig(options, target, target_os, |
| 560 mode, arch, cross_build) != 0: | 560 mode, arch, cross_build) != 0: |
| 561 return 1 | 561 return 1 |
| 562 | 562 |
| 563 return 0 | 563 return 0 |
| 564 | 564 |
| 565 | 565 |
| 566 if __name__ == '__main__': | 566 if __name__ == '__main__': |
| 567 sys.exit(Main()) | 567 sys.exit(Main()) |
| OLD | NEW |