Chromium Code Reviews| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 print "Unknown os %s" % os | 94 print "Unknown os %s" % os |
| 95 return False | 95 return False |
| 96 if os != HOST_OS: | 96 if os != HOST_OS: |
| 97 if os != 'android': | 97 if os != 'android': |
| 98 print "Unsupported target os %s" % os | 98 print "Unsupported target os %s" % os |
| 99 return False | 99 return False |
| 100 if not HOST_OS in ['linux']: | 100 if not HOST_OS in ['linux']: |
| 101 print ("Cross-compilation to %s is not supported on host os %s." | 101 print ("Cross-compilation to %s is not supported on host os %s." |
| 102 % (os, HOST_OS)) | 102 % (os, HOST_OS)) |
| 103 return False | 103 return False |
| 104 if not arch in ['ia32']: | 104 if not arch in ['ia32', 'arm']: |
| 105 print ("Cross-compilation to %s is not supported for architecture %s." | 105 print ("Cross-compilation to %s is not supported for architecture %s." |
| 106 % (os, arch)) | 106 % (os, arch)) |
| 107 return False | 107 return False |
| 108 # We have not yet tweaked the v8 dart build to work with the Android | 108 # We have not yet tweaked the v8 dart build to work with the Android |
| 109 # NDK/SDK, so don't try to build it. | 109 # NDK/SDK, so don't try to build it. |
| 110 if args == []: | 110 if args == []: |
| 111 print "For android builds you must specify a target, such as 'samples'." | 111 print "For android builds you must specify a target, such as 'samples'." |
| 112 return False | 112 return False |
| 113 if 'v8' in args: | 113 if 'v8' in args: |
| 114 print "The v8 target is not supported for android builds." | 114 print "The v8 target is not supported for android builds." |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 137 raise Exception('Could not find %s directory %s' | 137 raise Exception('Could not find %s directory %s' |
| 138 % (docstring, path)) | 138 % (docstring, path)) |
| 139 | 139 |
| 140 | 140 |
| 141 def SetCrossCompilationEnvironment(host_os, target_os, target_arch, old_path): | 141 def SetCrossCompilationEnvironment(host_os, target_os, target_arch, old_path): |
| 142 global THIRD_PARTY_ROOT | 142 global THIRD_PARTY_ROOT |
| 143 if host_os not in ['linux']: | 143 if host_os not in ['linux']: |
| 144 raise Exception('Unsupported host os %s' % host_os) | 144 raise Exception('Unsupported host os %s' % host_os) |
| 145 if target_os not in ['android']: | 145 if target_os not in ['android']: |
| 146 raise Exception('Unsupported target os %s' % target_os) | 146 raise Exception('Unsupported target os %s' % target_os) |
| 147 if target_arch not in ['ia32']: | 147 if target_arch not in ['ia32', 'arm']: |
| 148 raise Exception('Unsupported target architecture %s' % target_arch) | 148 raise Exception('Unsupported target architecture %s' % target_arch) |
| 149 | 149 |
| 150 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools'); | 150 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools'); |
| 151 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') | 151 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') |
| 152 CheckDirExists(android_tools, 'Android tools') | 152 CheckDirExists(android_tools, 'Android tools') |
| 153 android_ndk_root = os.path.join(android_tools, 'ndk') | 153 android_ndk_root = os.path.join(android_tools, 'ndk') |
| 154 CheckDirExists(android_ndk_root, 'Android NDK') | 154 CheckDirExists(android_ndk_root, 'Android NDK') |
| 155 android_sdk_root = os.path.join(android_tools, 'sdk') | 155 android_sdk_root = os.path.join(android_tools, 'sdk') |
| 156 CheckDirExists(android_sdk_root, 'Android SDK') | 156 CheckDirExists(android_sdk_root, 'Android SDK') |
| 157 | 157 |
| 158 os.environ['ANDROID_NDK_ROOT'] = android_ndk_root | 158 os.environ['ANDROID_NDK_ROOT'] = android_ndk_root |
| 159 os.environ['ANDROID_SDK_ROOT'] = android_sdk_root | 159 os.environ['ANDROID_SDK_ROOT'] = android_sdk_root |
| 160 | 160 |
| 161 toolchain_arch = 'x86-4.4.3' | 161 if target_arch == 'arm': |
| 162 toolchain_arch = 'arm-linux-androideabi-4.6' | |
| 163 else: | |
| 164 toolchain_arch = 'x86-4.4.3' | |
| 162 toolchain_dir = 'linux-x86' | 165 toolchain_dir = 'linux-x86' |
| 163 android_toolchain = os.path.join(android_ndk_root, | 166 android_toolchain = os.path.join(android_ndk_root, |
| 164 'toolchains', toolchain_arch, | 167 'toolchains', toolchain_arch, |
| 165 'prebuilt', toolchain_dir, 'bin') | 168 'prebuilt', toolchain_dir, 'bin') |
| 166 CheckDirExists(android_toolchain, 'Android toolchain') | 169 CheckDirExists(android_toolchain, 'Android toolchain') |
| 167 | 170 |
| 168 os.environ['ANDROID_TOOLCHAIN'] = android_toolchain | 171 os.environ['ANDROID_TOOLCHAIN'] = android_toolchain |
| 169 | 172 |
| 170 android_sdk_version = 15 | 173 android_sdk_version = 15 |
| 171 | 174 |
| 172 android_sdk_tools = os.path.join(android_sdk_root, 'tools') | 175 android_sdk_tools = os.path.join(android_sdk_root, 'tools') |
| 173 CheckDirExists(android_sdk_tools, 'Android SDK tools') | 176 CheckDirExists(android_sdk_tools, 'Android SDK tools') |
| 174 | 177 |
| 175 android_sdk_platform_tools = os.path.join(android_sdk_root, 'platform-tools') | 178 android_sdk_platform_tools = os.path.join(android_sdk_root, 'platform-tools') |
| 176 CheckDirExists(android_sdk_platform_tools, 'Android SDK platform tools') | 179 CheckDirExists(android_sdk_platform_tools, 'Android SDK platform tools') |
| 177 | 180 |
| 178 pathList = [old_path, | 181 pathList = [old_path, |
| 179 android_ndk_root, | 182 android_ndk_root, |
| 180 android_sdk_tools, | 183 android_sdk_tools, |
| 181 android_sdk_platform_tools, | 184 android_sdk_platform_tools, |
| 182 # for Ninja - maybe don't need? | 185 # for Ninja - maybe don't need? |
| 183 android_toolchain | 186 android_toolchain |
| 184 ] | 187 ] |
| 185 os.environ['PATH'] = ':'.join(pathList) | 188 os.environ['PATH'] = ':'.join(pathList) |
| 186 | 189 |
| 190 android_target_arch = target_arch | |
| 191 if target_arch == 'ia32': | |
| 192 android_target_arch = 'x86' | |
| 193 | |
| 187 gypDefinesList = [ | 194 gypDefinesList = [ |
| 188 'target_arch=ia32', | 195 'target_arch=%s' % target_arch, |
| 196 'android_target_arch=%s' % android_target_arch, | |
| 189 'OS=%s' % target_os, | 197 'OS=%s' % target_os, |
| 190 'android_build_type=0', | 198 'android_build_type=0', |
| 191 'host_os=%s' % host_os, | 199 'host_os=%s' % host_os, |
| 192 'linux_fpic=1', | 200 'linux_fpic=1', |
| 193 'release_optimize=s', | 201 'release_optimize=s', |
| 194 'linux_use_tcmalloc=0', | 202 'linux_use_tcmalloc=0', |
| 195 'android_sdk=%s', os.path.join(android_sdk_root, 'platforms', | 203 'android_sdk=%s', os.path.join(android_sdk_root, 'platforms', |
| 196 'android-%d' % android_sdk_version), | 204 'android-%d' % android_sdk_version), |
| 197 'android_sdk_tools=%s' % android_sdk_platform_tools | 205 'android_sdk_tools=%s' % android_sdk_platform_tools |
| 198 ] | 206 ] |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 | 418 |
| 411 args += [target] | 419 args += [target] |
| 412 | 420 |
| 413 if target_os != HOST_OS: | 421 if target_os != HOST_OS: |
| 414 SetCrossCompilationEnvironment( | 422 SetCrossCompilationEnvironment( |
| 415 HOST_OS, target_os, arch, old_path) | 423 HOST_OS, target_os, arch, old_path) |
| 416 | 424 |
| 417 RunhooksIfNeeded(HOST_OS, mode, arch, target_os) | 425 RunhooksIfNeeded(HOST_OS, mode, arch, target_os) |
| 418 | 426 |
| 419 toolchainprefix = None | 427 toolchainprefix = None |
| 420 if target_os == 'android': | 428 if target_os == 'android' and arch == 'ia32': |
|
vsm
2013/09/06 23:25:30
nit: I think
if target_os == 'android':
if a
zra
2013/09/13 23:28:45
Done.
| |
| 421 toolchainprefix = ('%s/i686-linux-android' | 429 toolchainprefix = ('%s/i686-linux-android' |
| 422 % os.environ['ANDROID_TOOLCHAIN']) | 430 % os.environ['ANDROID_TOOLCHAIN']) |
| 431 elif target_os == 'android' and arch == 'arm': | |
| 432 toolchainprefix = ('%s/arm-linux-androideabi' | |
| 433 % os.environ['ANDROID_TOOLCHAIN']) | |
| 423 toolsOverride = SetTools(arch, toolchainprefix) | 434 toolsOverride = SetTools(arch, toolchainprefix) |
| 424 if toolsOverride: | 435 if toolsOverride: |
| 425 printToolOverrides = target_os != 'android' | 436 printToolOverrides = target_os != 'android' |
| 426 for k, v in toolsOverride.iteritems(): | 437 for k, v in toolsOverride.iteritems(): |
| 427 args.append( k + "=" + v) | 438 args.append( k + "=" + v) |
| 428 if printToolOverrides: | 439 if printToolOverrides: |
| 429 print k + " = " + v | 440 print k + " = " + v |
| 430 if not os.path.isfile(toolsOverride['CC.target']): | 441 if not os.path.isfile(toolsOverride['CC.target']): |
| 431 if arch == 'arm': | 442 if arch == 'arm': |
| 432 print arm_cc_error | 443 print arm_cc_error |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 449 process.wait() | 460 process.wait() |
| 450 if process.returncode != 0: | 461 if process.returncode != 0: |
| 451 print "BUILD FAILED" | 462 print "BUILD FAILED" |
| 452 return 1 | 463 return 1 |
| 453 | 464 |
| 454 return 0 | 465 return 0 |
| 455 | 466 |
| 456 | 467 |
| 457 if __name__ == '__main__': | 468 if __name__ == '__main__': |
| 458 sys.exit(Main()) | 469 sys.exit(Main()) |
| OLD | NEW |