Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: tools/build.py

Issue 350483003: Build Tools Cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more fixes as reviewed by ricow Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/archive_crash.py ('k') | tools/compile_java/compile_java.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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):
79 if options.arch == 'all': 78 if options.arch == 'all':
80 options.arch = 'ia32,x64,simarm,simmips,simarm64' 79 options.arch = 'ia32,x64,simarm,simmips,simarm64'
81 if options.mode == 'all': 80 if options.mode == 'all':
82 options.mode = 'release,debug' 81 options.mode = 'release,debug'
83 if options.os == 'all': 82 if options.os == 'all':
84 options.os = 'host,android' 83 options.os = 'host,android'
85 options.mode = options.mode.split(',') 84 options.mode = options.mode.split(',')
86 options.arch = options.arch.split(',') 85 options.arch = options.arch.split(',')
87 options.os = options.os.split(',') 86 options.os = options.os.split(',')
88 for mode in options.mode: 87 for mode in options.mode:
89 if not mode in ['debug', 'release']: 88 if not mode in ['debug', 'release']:
90 print "Unknown mode %s" % mode 89 print "Unknown mode %s" % mode
91 return False 90 return False
92 for arch in options.arch: 91 for arch in options.arch:
93 archs = ['ia32', 'x64', 'simarm', 'arm', 'simmips', 'mips', 92 archs = ['ia32', 'x64', 'simarm', 'arm', 'simmips', 'mips',
94 'simarm64', 'arm64',] 93 'simarm64', 'arm64',]
95 if not arch in archs: 94 if not arch in archs:
96 print "Unknown arch %s" % arch 95 print "Unknown arch %s" % arch
97 return False 96 return False
98 options.os = [ProcessOsOption(os) for os in options.os] 97 options.os = [ProcessOsOption(os_name) for os_name in options.os]
99 for os in options.os: 98 for os_name in options.os:
100 if not os in ['android', 'freebsd', 'linux', 'macos', 'win32']: 99 if not os_name in ['android', 'freebsd', 'linux', 'macos', 'win32']:
101 print "Unknown os %s" % os 100 print "Unknown os %s" % os_name
102 return False 101 return False
103 if os != HOST_OS: 102 if os_name != HOST_OS:
104 if os != 'android': 103 if os_name != 'android':
105 print "Unsupported target os %s" % os 104 print "Unsupported target os %s" % os_name
106 return False 105 return False
107 if not HOST_OS in ['linux']: 106 if not HOST_OS in ['linux']:
108 print ("Cross-compilation to %s is not supported on host os %s." 107 print ("Cross-compilation to %s is not supported on host os %s."
109 % (os, HOST_OS)) 108 % (os_name, HOST_OS))
110 return False 109 return False
111 if not arch in ['ia32', 'arm', 'mips']: 110 if not arch in ['ia32', 'arm', 'mips']:
112 print ("Cross-compilation to %s is not supported for architecture %s." 111 print ("Cross-compilation to %s is not supported for architecture %s."
113 % (os, arch)) 112 % (os_name, arch))
114 return False 113 return False
115 # We have not yet tweaked the v8 dart build to work with the Android 114 # We have not yet tweaked the v8 dart build to work with the Android
116 # NDK/SDK, so don't try to build it. 115 # NDK/SDK, so don't try to build it.
117 if args == []: 116 if not args:
118 print "For android builds you must specify a target, such as 'runtime'." 117 print "For android builds you must specify a target, such as 'runtime'."
119 return False 118 return False
120 return True 119 return True
121 120
122 121
123 def SetTools(arch, target_os, toolchainprefix): 122 def SetTools(sys_arch, target_os, toolchainprefix):
124 toolsOverride = None 123 toolsOverride = None
125 124
126 # For Android, by default use the toolchain from third_party/android_tools. 125 # For Android, by default use the toolchain from third_party/android_tools.
127 if target_os == 'android' and toolchainprefix == None: 126 if target_os == 'android' and toolchainprefix is None:
128 android_toolchain = GetAndroidToolchainDir(HOST_OS, arch) 127 android_toolchain = GetAndroidToolchainDir(HOST_OS, sys_arch)
129 if arch == 'arm': 128 if sys_arch == 'arm':
130 toolchainprefix = os.path.join( 129 toolchainprefix = os.path.join(
131 android_toolchain, 'arm-linux-androideabi') 130 android_toolchain, 'arm-linux-androideabi')
132 if arch == 'ia32': 131 if sys_arch == 'ia32':
133 toolchainprefix = os.path.join( 132 toolchainprefix = os.path.join(
134 android_toolchain, 'i686-linux-android') 133 android_toolchain, 'i686-linux-android')
135 134
136 # For ARM Linux, by default use the Linux distribution's cross-compiler. 135 # For ARM Linux, by default use the Linux distribution's cross-compiler.
137 if arch == 'arm' and toolchainprefix == None: 136 if sys_arch == 'arm' and toolchainprefix is None:
138 # We specify the hf compiler. If this changes, we must also remove 137 # We specify the hf compiler. If this changes, we must also remove
139 # the ARM_FLOAT_ABI_HARD define in configurations_make.gypi. 138 # the ARM_FLOAT_ABI_HARD define in configurations_make.gypi.
140 toolchainprefix = (DEFAULT_ARM_CROSS_COMPILER_PATH + 139 toolchainprefix = (DEFAULT_ARM_CROSS_COMPILER_PATH +
141 "/arm-linux-gnueabihf") 140 "/arm-linux-gnueabihf")
142 141
143 # TODO(zra): Find a default MIPS Linux cross-compiler? 142 # TODO(zra): Find a default MIPS Linux cross-compiler?
144 143
145 # Override the Android toolchain's linker to handle some complexity in the 144 # Override the Android toolchain's linker to handle some complexity in the
146 # linker arguments that gyp has trouble with. 145 # linker arguments that gyp has trouble with.
147 linker = "" 146 linker = ""
(...skipping 20 matching lines...) Expand all
168 167
169 168
170 def GetAndroidToolchainDir(host_os, target_arch): 169 def GetAndroidToolchainDir(host_os, target_arch):
171 global THIRD_PARTY_ROOT 170 global THIRD_PARTY_ROOT
172 if host_os not in ['linux']: 171 if host_os not in ['linux']:
173 raise Exception('Unsupported host os %s' % host_os) 172 raise Exception('Unsupported host os %s' % host_os)
174 if target_arch not in ['ia32', 'arm']: 173 if target_arch not in ['ia32', 'arm']:
175 raise Exception('Unsupported target architecture %s' % target_arch) 174 raise Exception('Unsupported target architecture %s' % target_arch)
176 175
177 # Set up path to the Android NDK. 176 # Set up path to the Android NDK.
178 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools'); 177 CheckDirExists(THIRD_PARTY_ROOT, 'third party tools')
179 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools') 178 android_tools = os.path.join(THIRD_PARTY_ROOT, 'android_tools')
180 CheckDirExists(android_tools, 'Android tools') 179 CheckDirExists(android_tools, 'Android tools')
181 android_ndk_root = os.path.join(android_tools, 'ndk') 180 android_ndk_root = os.path.join(android_tools, 'ndk')
182 CheckDirExists(android_ndk_root, 'Android NDK') 181 CheckDirExists(android_ndk_root, 'Android NDK')
183 182
184 # Set up the directory of the Android NDK cross-compiler toolchain. 183 # Set up the directory of the Android NDK cross-compiler toolchain.
185 toolchain_arch = 'arm-linux-androideabi-4.6' 184 toolchain_arch = 'arm-linux-androideabi-4.6'
186 if target_arch == 'ia32': 185 if target_arch == 'ia32':
187 toolchain_arch = 'x86-4.6' 186 toolchain_arch = 'x86-4.6'
188 toolchain_dir = 'linux-x86_64' 187 toolchain_dir = 'linux-x86_64'
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 224
226 PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/... 225 PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/...
227 cd ... 226 cd ...
228 /bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/... 227 /bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/...
229 228
230 229
231 ** BUILD SUCCEEDED ** 230 ** BUILD SUCCEEDED **
232 231
233 """ 232 """
234 233
235 def is_empty_chunk(chunk): 234 def is_empty_chunk(input):
236 empty_chunk = ['', 'Check dependencies', ''] 235 empty_chunk = ['', 'Check dependencies', '']
237 return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk) 236 return not input or (len(input) == 4 and input[1:] == empty_chunk)
238 237
239 def unbuffered(callable): 238 def unbuffered(callable):
240 # Use iter to disable buffering in for-in. 239 # Use iter to disable buffering in for-in.
241 return iter(callable, '') 240 return iter(callable, '')
242 241
243 section = None 242 section = None
244 chunk = [] 243 chunk = []
245 # Is stdout a terminal which supports colors? 244 # Is stdout a terminal which supports colors?
246 is_fancy_tty = False 245 is_fancy_tty = False
247 clr_eol = None 246 clr_eol = None
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 304
306 305
307 def NotifyBuildDone(build_config, success, start): 306 def NotifyBuildDone(build_config, success, start):
308 if not success: 307 if not success:
309 print "BUILD FAILED" 308 print "BUILD FAILED"
310 309
311 sys.stdout.flush() 310 sys.stdout.flush()
312 311
313 # Display a notification if build time exceeded DART_BUILD_NOTIFICATION_DELAY. 312 # Display a notification if build time exceeded DART_BUILD_NOTIFICATION_DELAY.
314 notification_delay = float( 313 notification_delay = float(
315 os.getenv('DART_BUILD_NOTIFICATION_DELAY', default=sys.float_info.max)) 314 os.getenv('DART_BUILD_NOTIFICATION_DELAY', sys.float_info.max))
316 if (time.time() - start) < notification_delay: 315 if (time.time() - start) < notification_delay:
317 return 316 return
318 317
319 if success: 318 if success:
320 message = 'Build succeeded.' 319 message = 'Build succeeded.'
321 else: 320 else:
322 message = 'Build failed.' 321 message = 'Build failed.'
323 title = build_config 322 title = build_config
324 323
325 command = None 324 command = None
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 if HOST_OS == 'freebsd': 428 if HOST_OS == 'freebsd':
430 make = 'gmake' 429 make = 'gmake'
431 # work around lack of flock 430 # work around lack of flock
432 os.environ['LINK'] = '$(CXX)' 431 os.environ['LINK'] = '$(CXX)'
433 args = [make, 432 args = [make,
434 '-j', 433 '-j',
435 options.j, 434 options.j,
436 'BUILDTYPE=' + build_config, 435 'BUILDTYPE=' + build_config,
437 ] 436 ]
438 if target_os != HOST_OS: 437 if target_os != HOST_OS:
439 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS, target_os)] 438 args += ['builddir_name=' + utils.GetBuildDir(HOST_OS)]
440 if options.verbose: 439 if options.verbose:
441 args += ['V=1'] 440 args += ['V=1']
442 441
443 args += [target] 442 args += [target]
444 443
445 toolchainprefix = options.toolchain 444 toolchainprefix = options.toolchain
446 toolsOverride = SetTools(arch, target_os, toolchainprefix) 445 toolsOverride = SetTools(arch, target_os, toolchainprefix)
447 if toolsOverride: 446 if toolsOverride:
448 for k, v in toolsOverride.iteritems(): 447 for k, v in toolsOverride.iteritems():
449 args.append( k + "=" + v) 448 args.append( k + "=" + v)
450 if options.verbose: 449 if options.verbose:
451 print k + " = " + v 450 print k + " = " + v
452 if not os.path.isfile(toolsOverride['CC.target']): 451 if not os.path.isfile(toolsOverride['CC.target']):
453 if arch == 'arm': 452 if arch == 'arm':
454 print arm_cc_error 453 print arm_cc_error
455 else: 454 else:
456 print "Couldn't find compiler: %s" % toolsOverride['CC.target'] 455 print "Couldn't find compiler: %s" % toolsOverride['CC.target']
457 return 1 456 return 1
458 457
459 458
460 print ' '.join(args) 459 print ' '.join(args)
461 process = None
462 if filter_xcodebuild_output: 460 if filter_xcodebuild_output:
463 process = subprocess.Popen(args, 461 process = subprocess.Popen(args,
464 stdin=None, 462 stdin=None,
465 bufsize=1, # Line buffered. 463 bufsize=1, # Line buffered.
466 stdout=subprocess.PIPE, 464 stdout=subprocess.PIPE,
467 stderr=subprocess.STDOUT) 465 stderr=subprocess.STDOUT)
468 FilterEmptyXcodebuildSections(process) 466 FilterEmptyXcodebuildSections(process)
469 else: 467 else:
470 process = subprocess.Popen(args, stdin=None) 468 process = subprocess.Popen(args, stdin=None)
471 process.wait() 469 process.wait()
472 if process.returncode != 0: 470 if process.returncode != 0:
473 NotifyBuildDone(build_config, success=False, start=start_time) 471 NotifyBuildDone(build_config, success=False, start=start_time)
474 return 1 472 return 1
475 else: 473 else:
476 NotifyBuildDone(build_config, success=True, start=start_time) 474 NotifyBuildDone(build_config, success=True, start=start_time)
477 475
478 return 0 476 return 0
479 477
480 478
481 if __name__ == '__main__': 479 if __name__ == '__main__':
482 sys.exit(Main()) 480 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/archive_crash.py ('k') | tools/compile_java/compile_java.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698