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) 2014, 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 |
| 11 import shutil | |
| 12 import subprocess | 11 import subprocess |
| 13 import sys | 12 import sys |
| 14 import time | 13 import time |
| 15 import utils | 14 import utils |
| 16 | 15 |
| 17 HOST_OS = utils.GuessOS() | 16 HOST_OS = utils.GuessOS() |
| 18 HOST_CPUS = utils.GuessCpus() | 17 HOST_CPUS = utils.GuessCpus() |
| 19 SCRIPT_DIR = os.path.dirname(sys.argv[0]) | 18 SCRIPT_DIR = os.path.dirname(sys.argv[0]) |
| 20 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) | 19 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) |
| 21 THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party') | 20 THIRD_PARTY_ROOT = os.path.join(DART_ROOT, 'third_party') |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 result.add_option("--devenv", | 61 result.add_option("--devenv", |
| 63 help='Path containing devenv.com on Windows', | 62 help='Path containing devenv.com on Windows', |
| 64 default=vs_directory) | 63 default=vs_directory) |
| 65 result.add_option("--executable", | 64 result.add_option("--executable", |
| 66 help='Name of the devenv.com/msbuild executable on Windows (varies for ' | 65 help='Name of the devenv.com/msbuild executable on Windows (varies for ' |
| 67 'different versions of Visual Studio)', | 66 'different versions of Visual Studio)', |
| 68 default=vs_executable) | 67 default=vs_executable) |
| 69 return result | 68 return result |
| 70 | 69 |
| 71 | 70 |
| 72 def ProcessOsOption(os): | 71 def ProcessOsOption(os_name): |
| 73 if os == 'host': | 72 if os_name == 'host': |
| 74 return HOST_OS | 73 return HOST_OS |
| 75 return os | 74 return os_name |
| 76 | 75 |
| 77 | 76 |
| 78 def ProcessOptions(options, args): | 77 def ProcessOptions(options, args): |
| 78 global arch | |
|
ricow1
2014/06/27 07:35:34
I don't think we need this
| |
| 79 if options.arch == 'all': | 79 if options.arch == 'all': |
| 80 options.arch = 'ia32,x64,simarm,simmips,simarm64' | 80 options.arch = 'ia32,x64,simarm,simmips,simarm64' |
| 81 if options.mode == 'all': | 81 if options.mode == 'all': |
| 82 options.mode = 'release,debug' | 82 options.mode = 'release,debug' |
| 83 if options.os == 'all': | 83 if options.os == 'all': |
| 84 options.os = 'host,android' | 84 options.os = 'host,android' |
| 85 options.mode = options.mode.split(',') | 85 options.mode = options.mode.split(',') |
| 86 options.arch = options.arch.split(',') | 86 options.arch = options.arch.split(',') |
| 87 options.os = options.os.split(',') | 87 options.os = options.os.split(',') |
| 88 for mode in options.mode: | 88 for mode in options.mode: |
| 89 if not mode in ['debug', 'release']: | 89 if not mode in ['debug', 'release']: |
| 90 print "Unknown mode %s" % mode | 90 print "Unknown mode %s" % mode |
| 91 return False | 91 return False |
| 92 for arch in options.arch: | 92 for arch in options.arch: |
| 93 archs = ['ia32', 'x64', 'simarm', 'arm', 'simmips', 'mips', | 93 archs = ['ia32', 'x64', 'simarm', 'arm', 'simmips', 'mips', |
| 94 'simarm64', 'arm64',] | 94 'simarm64', 'arm64',] |
| 95 if not arch in archs: | 95 if not arch in archs: |
| 96 print "Unknown arch %s" % arch | 96 print "Unknown arch %s" % arch |
| 97 return False | 97 return False |
| 98 options.os = [ProcessOsOption(os) for os in options.os] | 98 options.os = [ProcessOsOption(os_name) for os_name in options.os] |
| 99 for os in options.os: | 99 for os_name in options.os: |
| 100 if not os in ['android', 'freebsd', 'linux', 'macos', 'win32']: | 100 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']: |
| 101 print "Unknown os %s" % os | 101 print "Unknown os %s" % os_name |
| 102 return False | 102 return False |
| 103 if os != HOST_OS: | 103 if os_name != HOST_OS: |
| 104 if os != 'android': | 104 if os_name != 'android': |
| 105 print "Unsupported target os %s" % os | 105 print "Unsupported target os %s" % os_name |
| 106 return False | 106 return False |
| 107 if not HOST_OS in ['linux']: | 107 if not HOST_OS in ['linux']: |
| 108 print ("Cross-compilation to %s is not supported on host os %s." | 108 print ("Cross-compilation to %s is not supported on host os %s." |
| 109 % (os, HOST_OS)) | 109 % (os_name, HOST_OS)) |
| 110 return False | 110 return False |
| 111 if not arch in ['ia32', 'arm', 'mips']: | 111 if not arch in ['ia32', 'arm', 'mips']: |
| 112 print ("Cross-compilation to %s is not supported for architecture %s." | 112 print ("Cross-compilation to %s is not supported for architecture %s." |
| 113 % (os, arch)) | 113 % (os_name, arch)) |
| 114 return False | 114 return False |
| 115 # We have not yet tweaked the v8 dart build to work with the Android | 115 # We have not yet tweaked the v8 dart build to work with the Android |
| 116 # NDK/SDK, so don't try to build it. | 116 # NDK/SDK, so don't try to build it. |
| 117 if args == []: | 117 if not args: |
| 118 print "For android builds you must specify a target, such as 'runtime'." | 118 print "For android builds you must specify a target, such as 'runtime'." |
| 119 return False | 119 return False |
| 120 return True | 120 return True |
| 121 | 121 |
| 122 | 122 |
| 123 def SetTools(arch, target_os, toolchainprefix): | 123 def SetTools(sys_arch, target_os, toolchainprefix): |
| 124 toolsOverride = None | 124 toolsOverride = None |
| 125 | 125 |
| 126 # For Android, by default use the toolchain from third_party/android_tools. | 126 # For Android, by default use the toolchain from third_party/android_tools. |
| 127 if target_os == 'android' and toolchainprefix == None: | 127 if target_os == 'android' and toolchainprefix is None: |
| 128 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) | 128 android_toolchain = GetAndroidToolchainDir(HOST_OS, sys_arch) |
| 129 if arch == 'arm': | 129 if sys_arch == 'arm': |
| 130 toolchainprefix = os.path.join( | 130 toolchainprefix = os.path.join( |
| 131 android_toolchain, 'arm-linux-androideabi') | 131 android_toolchain, 'arm-linux-androideabi') |
| 132 if arch == 'ia32': | 132 if sys_arch == 'ia32': |
| 133 toolchainprefix = os.path.join( | 133 toolchainprefix = os.path.join( |
| 134 android_toolchain, 'i686-linux-android') | 134 android_toolchain, 'i686-linux-android') |
| 135 | 135 |
| 136 # For ARM Linux, by default use the Linux distribution's cross-compiler. | 136 # For ARM Linux, by default use the Linux distribution's cross-compiler. |
| 137 if arch == 'arm' and toolchainprefix == None: | 137 if sys_arch == 'arm' and toolchainprefix is None: |
| 138 # We specify the hf compiler. If this changes, we must also remove | 138 # We specify the hf compiler. If this changes, we must also remove |
| 139 # the ARM_FLOAT_ABI_HARD define in configurations_make.gypi. | 139 # the ARM_FLOAT_ABI_HARD define in configurations_make.gypi. |
| 140 toolchainprefix = (DEFAULT_ARM_CROSS_COMPILER_PATH + | 140 toolchainprefix = (DEFAULT_ARM_CROSS_COMPILER_PATH + |
| 141 "/arm-linux-gnueabihf") | 141 "/arm-linux-gnueabihf") |
| 142 | 142 |
| 143 # TODO(zra): Find a default MIPS Linux cross-compiler? | 143 # TODO(zra): Find a default MIPS Linux cross-compiler? |
| 144 | 144 |
| 145 # Override the Android toolchain's linker to handle some complexity in the | 145 # Override the Android toolchain's linker to handle some complexity in the |
| 146 # linker arguments that gyp has trouble with. | 146 # linker arguments that gyp has trouble with. |
| 147 linker = "" | 147 linker = "" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 168 | 168 |
| 169 | 169 |
| 170 def GetAndroidToolchainDir(host_os, target_arch): | 170 def GetAndroidToolchainDir(host_os, target_arch): |
| 171 global THIRD_PARTY_ROOT | 171 global THIRD_PARTY_ROOT |
| 172 if host_os not in ['linux']: | 172 if host_os not in ['linux']: |
| 173 raise Exception('Unsupported host os %s' % host_os) | 173 raise Exception('Unsupported host os %s' % host_os) |
| 174 if target_arch not in ['ia32', 'arm']: | 174 if target_arch not in ['ia32', 'arm']: |
| 175 raise Exception('Unsupported target architecture %s' % target_arch) | 175 raise Exception('Unsupported target architecture %s' % target_arch) |
| 176 | 176 |
| 177 # Set up path to the Android NDK. | 177 # Set up path to the Android NDK. |
| 178 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools'); | 178 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools') |
| 179 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') | 179 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') |
| 180 CheckDirExists(android_tools, 'Android tools') | 180 CheckDirExists(android_tools, 'Android tools') |
| 181 android_ndk_root = os.path.join(android_tools, 'ndk') | 181 android_ndk_root = os.path.join(android_tools, 'ndk') |
| 182 CheckDirExists(android_ndk_root, 'Android NDK') | 182 CheckDirExists(android_ndk_root, 'Android NDK') |
| 183 | 183 |
| 184 # Set up the directory of the Android NDK cross-compiler toolchain. | 184 # Set up the directory of the Android NDK cross-compiler toolchain. |
| 185 toolchain_arch = 'arm-linux-androideabi-4.6' | 185 toolchain_arch = 'arm-linux-androideabi-4.6' |
| 186 if target_arch == 'ia32': | 186 if target_arch == 'ia32': |
| 187 toolchain_arch = 'x86-4.6' | 187 toolchain_arch = 'x86-4.6' |
| 188 toolchain_dir = 'linux-x86_64' | 188 toolchain_dir = 'linux-x86_64' |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 | 225 |
| 226 PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/... | 226 PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/... |
| 227 cd ... | 227 cd ... |
| 228 /bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/... | 228 /bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/... |
| 229 | 229 |
| 230 | 230 |
| 231 ** BUILD SUCCEEDED ** | 231 ** BUILD SUCCEEDED ** |
| 232 | 232 |
| 233 """ | 233 """ |
| 234 | 234 |
| 235 def is_empty_chunk(chunk): | 235 def is_empty_chunk(input): |
| 236 empty_chunk = ['', 'Check dependencies', ''] | 236 empty_chunk = ['', 'Check dependencies', ''] |
| 237 return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk) | 237 return not input or (len(input) == 4 and input[1:] == empty_chunk) |
| 238 | 238 |
| 239 def unbuffered(callable): | 239 def unbuffered(callable): |
| 240 # Use iter to disable buffering in for-in. | 240 # Use iter to disable buffering in for-in. |
| 241 return iter(callable, '') | 241 return iter(callable, '') |
| 242 | 242 |
| 243 section = None | 243 section = None |
| 244 chunk = [] | 244 chunk = [] |
| 245 # Is stdout a terminal which supports colors? | 245 # Is stdout a terminal which supports colors? |
| 246 is_fancy_tty = False | 246 is_fancy_tty = False |
| 247 clr_eol = None | 247 clr_eol = None |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 | 305 |
| 306 | 306 |
| 307 def NotifyBuildDone(build_config, success, start): | 307 def NotifyBuildDone(build_config, success, start): |
| 308 if not success: | 308 if not success: |
| 309 print "BUILD FAILED" | 309 print "BUILD FAILED" |
| 310 | 310 |
| 311 sys.stdout.flush() | 311 sys.stdout.flush() |
| 312 | 312 |
| 313 # Display a notification if build time exceeded DART_BUILD_NOTIFICATION_DELAY. | 313 # Display a notification if build time exceeded DART_BUILD_NOTIFICATION_DELAY. |
| 314 notification_delay = float( | 314 notification_delay = float( |
| 315 os.getenv('DART_BUILD_NOTIFICATION_DELAY', default=sys.float_info.max)) | 315 os.getenv('DART_BUILD_NOTIFICATION_DELAY', sys.float_info.max)) |
| 316 if (time.time() - start) < notification_delay: | 316 if (time.time() - start) < notification_delay: |
| 317 return | 317 return |
| 318 | 318 |
| 319 if success: | 319 if success: |
| 320 message = 'Build succeeded.' | 320 message = 'Build succeeded.' |
| 321 else: | 321 else: |
| 322 message = 'Build failed.' | 322 message = 'Build failed.' |
| 323 title = build_config | 323 title = build_config |
| 324 | 324 |
| 325 command = None | 325 command = None |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 if HOST_OS == 'freebsd': | 429 if HOST_OS == 'freebsd': |
| 430 make = 'gmake' | 430 make = 'gmake' |
| 431 # work around lack of flock | 431 # work around lack of flock |
| 432 os.environ['LINK'] = '$(CXX)' | 432 os.environ['LINK'] = '$(CXX)' |
| 433 args = [make, | 433 args = [make, |
| 434 '-j', | 434 '-j', |
| 435 options.j, | 435 options.j, |
| 436 'BUILDTYPE=' + build_config, | 436 'BUILDTYPE=' + build_config, |
| 437 ] | 437 ] |
| 438 if target_os != HOST_OS: | 438 if target_os != HOST_OS: |
| 439 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS, target_os)] | 439 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS)] |
| 440 if options.verbose: | 440 if options.verbose: |
| 441 args += ['V=1'] | 441 args += ['V=1'] |
| 442 | 442 |
| 443 args += [target] | 443 args += [target] |
| 444 | 444 |
| 445 toolchainprefix = options.toolchain | 445 toolchainprefix = options.toolchain |
| 446 toolsOverride = SetTools(arch, target_os, toolchainprefix) | 446 toolsOverride = SetTools(arch, target_os, toolchainprefix) |
| 447 if toolsOverride: | 447 if toolsOverride: |
| 448 for k, v in toolsOverride.iteritems(): | 448 for k, v in toolsOverride.iteritems(): |
| 449 args.append( k + "=" + v) | 449 args.append( k + "=" + v) |
| 450 if options.verbose: | 450 if options.verbose: |
| 451 print k + " = " + v | 451 print k + " = " + v |
| 452 if not os.path.isfile(toolsOverride['CC.target']): | 452 if not os.path.isfile(toolsOverride['CC.target']): |
| 453 if arch == 'arm': | 453 if arch == 'arm': |
| 454 print arm_cc_error | 454 print arm_cc_error |
| 455 else: | 455 else: |
| 456 print "Couldn't find compiler: %s" % toolsOverride['CC.target'] | 456 print "Couldn't find compiler: %s" % toolsOverride['CC.target'] |
| 457 return 1 | 457 return 1 |
| 458 | 458 |
| 459 | 459 |
| 460 print ' '.join(args) | 460 print ' '.join(args) |
| 461 process = None | |
| 462 if filter_xcodebuild_output: | 461 if filter_xcodebuild_output: |
| 463 process = subprocess.Popen(args, | 462 process = subprocess.Popen(args, |
| 464 stdin=None, | 463 stdin=None, |
| 465 bufsize=1, # Line buffered. | 464 bufsize=1, # Line buffered. |
| 466 stdout=subprocess.PIPE, | 465 stdout=subprocess.PIPE, |
| 467 stderr=subprocess.STDOUT) | 466 stderr=subprocess.STDOUT) |
| 468 FilterEmptyXcodebuildSections(process) | 467 FilterEmptyXcodebuildSections(process) |
| 469 else: | 468 else: |
| 470 process = subprocess.Popen(args, stdin=None) | 469 process = subprocess.Popen(args, stdin=None) |
| 471 process.wait() | 470 process.wait() |
| 472 if process.returncode != 0: | 471 if process.returncode != 0: |
| 473 NotifyBuildDone(build_config, success=False, start=start_time) | 472 NotifyBuildDone(build_config, success=False, start=start_time) |
| 474 return 1 | 473 return 1 |
| 475 else: | 474 else: |
| 476 NotifyBuildDone(build_config, success=True, start=start_time) | 475 NotifyBuildDone(build_config, success=True, start=start_time) |
| 477 | 476 |
| 478 return 0 | 477 return 0 |
| 479 | 478 |
| 480 | 479 |
| 481 if __name__ == '__main__': | 480 if __name__ == '__main__': |
| 482 sys.exit(Main()) | 481 sys.exit(Main()) |
| OLD | NEW |