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 | |
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(the_chunk): |
ricow1
2014/06/24 07:41:55
the_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 the_chunk or (len(the_chunk) == 4 and the_chunk[1:] == empty_chun k) |
kustermann
2014/06/23 07:56:42
long line
| |
238 | 238 |
239 def unbuffered(callable): | 239 def unbuffered(the_callable): |
ricow1
2014/06/24 07:41:54
the_callable -> input or stream
ricow1
2014/06/24 07:41:55
the_callable -> input
| |
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(the_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 |
248 if sys.stdout.isatty(): | 248 if sys.stdout.isatty(): |
249 term = os.getenv('TERM', 'dumb') | 249 term = os.getenv('TERM', 'dumb') |
250 # The capability "clr_eol" means clear the line from cursor to end | 250 # The capability "clr_eol" means clear the line from cursor to end |
251 # of line. See man pages for tput and terminfo. | 251 # of line. See man pages for tput and terminfo. |
(...skipping 53 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 else: | 372 else: |
373 targets = ['all'] | 373 targets = ['all'] |
374 else: | 374 else: |
375 targets = args | 375 targets = args |
376 | 376 |
377 filter_xcodebuild_output = False | 377 filter_xcodebuild_output = False |
378 # Build all targets for each requested configuration. | 378 # Build all targets for each requested configuration. |
379 for target in targets: | 379 for target in targets: |
380 for target_os in options.os: | 380 for target_os in options.os: |
381 for mode in options.mode: | 381 for mode in options.mode: |
382 for arch in options.arch: | 382 for the_arch in options.arch: |
ricow1
2014/06/24 07:41:55
what is arch shadowing? Is this simply because you
| |
383 start_time = time.time() | 383 start_time = time.time() |
384 os.environ['DART_BUILD_MODE'] = mode | 384 os.environ['DART_BUILD_MODE'] = mode |
385 build_config = utils.GetBuildConf(mode, arch, target_os) | 385 build_config = utils.GetBuildConf(mode, the_arch, target_os) |
386 if HOST_OS == 'macos': | 386 if HOST_OS == 'macos': |
387 filter_xcodebuild_output = True | 387 filter_xcodebuild_output = True |
388 project_file = 'dart.xcodeproj' | 388 project_file = 'dart.xcodeproj' |
389 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | 389 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
390 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() | 390 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() |
391 args = ['xcodebuild', | 391 args = ['xcodebuild', |
392 '-project', | 392 '-project', |
393 project_file, | 393 project_file, |
394 '-target', | 394 '-target', |
395 target, | 395 target, |
396 '-configuration', | 396 '-configuration', |
397 build_config, | 397 build_config, |
398 'SYMROOT=%s' % os.path.abspath('xcodebuild') | 398 'SYMROOT=%s' % os.path.abspath('xcodebuild') |
399 ] | 399 ] |
400 elif HOST_OS == 'win32': | 400 elif HOST_OS == 'win32': |
401 project_file = 'dart.sln' | 401 project_file = 'dart.sln' |
402 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): | 402 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): |
403 project_file = 'dart-%s.sln' % CurrentDirectoryBaseName() | 403 project_file = 'dart-%s.sln' % CurrentDirectoryBaseName() |
404 # Select a platform suffix to pass to devenv. | 404 # Select a platform suffix to pass to devenv. |
405 if arch == 'ia32': | 405 if the_arch == 'ia32': |
406 platform_suffix = 'Win32' | 406 platform_suffix = 'Win32' |
407 elif arch == 'x64': | 407 elif the_arch == 'x64': |
408 platform_suffix = 'x64' | 408 platform_suffix = 'x64' |
409 else: | 409 else: |
410 print 'Unsupported arch for MSVC build: %s' % arch | 410 print 'Unsupported arch for MSVC build: %s' % the_arch |
411 return 1 | 411 return 1 |
412 config_name = '%s|%s' % (build_config, platform_suffix) | 412 config_name = '%s|%s' % (build_config, platform_suffix) |
413 if target == 'all': | 413 if target == 'all': |
414 args = [options.devenv + os.sep + options.executable, | 414 args = [options.devenv + os.sep + options.executable, |
415 '/build', | 415 '/build', |
416 config_name, | 416 config_name, |
417 project_file | 417 project_file |
418 ] | 418 ] |
419 else: | 419 else: |
420 args = [options.devenv + os.sep + options.executable, | 420 args = [options.devenv + os.sep + options.executable, |
421 '/build', | 421 '/build', |
422 config_name, | 422 config_name, |
423 '/project', | 423 '/project', |
424 target, | 424 target, |
425 project_file | 425 project_file |
426 ] | 426 ] |
427 else: | 427 else: |
428 make = 'make' | 428 make = 'make' |
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(the_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 the_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 |