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

Side by Side Diff: dart/tools/build.py

Issue 13470019: Parse output from xcodebuild to make it easier to spot problems with non-incremental builds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 years, 8 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 | « no previous file | no next file » | 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) 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 shutil 10 import shutil
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 with open(build_cookie_path, 'w') as f: 217 with open(build_cookie_path, 'w') as f:
218 f.write(target_os) 218 f.write(target_os)
219 GClientRunHooks() 219 GClientRunHooks()
220 220
221 221
222 def CurrentDirectoryBaseName(): 222 def CurrentDirectoryBaseName():
223 """Returns the name of the current directory""" 223 """Returns the name of the current directory"""
224 return os.path.relpath(os.curdir, start=os.pardir) 224 return os.path.relpath(os.curdir, start=os.pardir)
225 225
226 226
227 def ParseXcodebuild(args): 227 def FilterEmptyXcodebuildSections(process):
228 """ 228 """
229 Run xcodebuild and returns the process object. 229 Filter output from xcodebuild so empty sections are less verbose.
230 Output is parsed to filter out build actions that had no output. 230
231 The output from xcodebuild looks like this:
232
233 Build settings from command line:
234 SYMROOT = .../xcodebuild
235
236 === BUILD AGGREGATE TARGET samples OF PROJECT dart WITH CONFIGURATION ReleaseIA3 2 ===
kustermann 2013/04/05 15:31:01 You could abbreviate these lines with '...' so we
ahe 2013/04/05 15:45:44 Done.
237 Check dependencies
238
239
240 === BUILD AGGREGATE TARGET upload_sdk OF PROJECT dart WITH CONFIGURATION Release IA32 ===
241 Check dependencies
242
243 PhaseScriptExecution "Action \"upload_sdk_py\"" xcodebuild/dart.build/ReleaseIA3 2/upload_sdk.build/Script-822253BD7234630D393BA4AC.sh
244 cd ...
245 /bin/sh -c .../xcodebuild/dart.build/ReleaseIA32/upload_sdk.build/Script-822 253BD7234630D393BA4AC.sh
246
247
248 ** BUILD SUCCEEDED **
249
231 """ 250 """
232 251
233 def is_empty_chunk(chunk): 252 def is_empty_chunk(chunk):
234 empty_chunk = ['Check dependencies', '', ''] 253 empty_chunk = ['Check dependencies', '', '']
235 return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk) 254 return not chunk or (len(chunk) == 4 and chunk[1:] == empty_chunk)
236 255
237 process = subprocess.Popen(args, 256 def unbuffered(callable):
238 bufsize=0, 257 # Use iter to disable buffering in for-in.
239 stdin=None, 258 return iter(callable, b'')
kustermann 2013/04/05 15:31:01 The 'b' should not be necessary here.
ahe 2013/04/05 15:45:44 Done.
240 stdout=subprocess.PIPE, 259
241 stderr=subprocess.STDOUT)
242 section = None 260 section = None
243 chunk = [] 261 chunk = []
244 for line in process.stdout: 262 # Is stdout a terminal?
263 isatty = sys.stdout.isatty()
264 for line in unbuffered(process.stdout.readline):
245 line = line.rstrip() 265 line = line.rstrip()
246 if line.startswith('=== BUILD ') or line.startswith('** BUILD '): 266 if line.startswith('=== BUILD ') or line.startswith('** BUILD '):
247 if not is_empty_chunk(chunk): 267 if not is_empty_chunk(chunk):
248 print '\n'.join(chunk) 268 print '\n'.join(chunk)
249 section = line 269 section = line
270 if isatty:
271 # If stdout is a terminal, emit "progress" information.
272 print '%s[2K%s\r' % (chr(27), section),
250 chunk = [] 273 chunk = []
251 if not section: 274 if not section:
252 print line 275 print line
253 else: 276 else:
254 chunk.append(line) 277 chunk.append(line)
255 if not is_empty_chunk(chunk): 278 if not is_empty_chunk(chunk):
256 print '\n'.join(chunk) 279 print '\n'.join(chunk)
257 return process
258 280
259 281
260 def Main(): 282 def Main():
261 utils.ConfigureJava() 283 utils.ConfigureJava()
262 # Parse the options. 284 # Parse the options.
263 parser = BuildOptions() 285 parser = BuildOptions()
264 (options, args) = parser.parse_args() 286 (options, args) = parser.parse_args()
265 if not ProcessOptions(options, args): 287 if not ProcessOptions(options, args):
266 parser.print_help() 288 parser.print_help()
267 return 1 289 return 1
268 # Determine which targets to build. By default we build the "all" target. 290 # Determine which targets to build. By default we build the "all" target.
269 if len(args) == 0: 291 if len(args) == 0:
270 if HOST_OS == 'macos': 292 if HOST_OS == 'macos':
271 target = 'All' 293 target = 'All'
272 else: 294 else:
273 target = 'all' 295 target = 'all'
274 else: 296 else:
275 target = args[0] 297 target = args[0]
276 298
277 parse_xcodebuild = False 299 filter_xcodebuild_output = False
278 # Remember path 300 # Remember path
279 old_path = os.environ['PATH'] 301 old_path = os.environ['PATH']
280 # Build the targets for each requested configuration. 302 # Build the targets for each requested configuration.
281 for target_os in options.os: 303 for target_os in options.os:
282 for mode in options.mode: 304 for mode in options.mode:
283 for arch in options.arch: 305 for arch in options.arch:
284 build_config = utils.GetBuildConf(mode, arch) 306 build_config = utils.GetBuildConf(mode, arch)
285 if HOST_OS == 'macos': 307 if HOST_OS == 'macos':
286 parse_xcodebuild = True 308 filter_xcodebuild_output = True
287 project_file = 'dart.xcodeproj' 309 project_file = 'dart.xcodeproj'
288 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()): 310 if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
289 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName() 311 project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
290 args = ['xcodebuild', 312 args = ['xcodebuild',
291 '-project', 313 '-project',
292 project_file, 314 project_file,
293 '-target', 315 '-target',
294 target, 316 target,
295 '-configuration', 317 '-configuration',
296 build_config, 318 build_config,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 toolsOverride = SetTools(arch, toolchainprefix) 367 toolsOverride = SetTools(arch, toolchainprefix)
346 if toolsOverride: 368 if toolsOverride:
347 printToolOverrides = target_os != 'android' 369 printToolOverrides = target_os != 'android'
348 for k, v in toolsOverride.iteritems(): 370 for k, v in toolsOverride.iteritems():
349 args.append( k + "=" + v) 371 args.append( k + "=" + v)
350 if printToolOverrides: 372 if printToolOverrides:
351 print k + " = " + v 373 print k + " = " + v
352 374
353 print ' '.join(args) 375 print ' '.join(args)
354 process = None 376 process = None
355 if parse_xcodebuild: 377 if filter_xcodebuild_output:
356 process = ParseXcodebuild(args) 378 process = subprocess.Popen(args,
379 stdin=None,
380 bufsize=1, # Line buffered.
381 stdout=subprocess.PIPE,
382 stderr=subprocess.STDOUT)
383 FilterEmptyXcodebuildSections(process)
357 else: 384 else:
358 process = subprocess.Popen(args, stdin=None) 385 process = subprocess.Popen(args, stdin=None)
359 process.wait() 386 process.wait()
360 if process.returncode != 0: 387 if process.returncode != 0:
361 print "BUILD FAILED" 388 print "BUILD FAILED"
362 return 1 389 return 1
363 390
364 return 0 391 return 0
365 392
366 393
367 if __name__ == '__main__': 394 if __name__ == '__main__':
368 sys.exit(Main()) 395 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698