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

Side by Side Diff: tools/build.py

Issue 2620113002: Make build.py ensure that goma is started if it is enabled (Closed)
Patch Set: Better error handling Created 3 years, 11 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
« 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 re 10 import re
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 def ShouldRunGN(out_dir): 420 def ShouldRunGN(out_dir):
421 return (not os.path.exists(out_dir) or 421 return (not os.path.exists(out_dir) or
422 not os.path.isfile(os.path.join(out_dir, 'args.gn'))) 422 not os.path.isfile(os.path.join(out_dir, 'args.gn')))
423 423
424 424
425 def UseGoma(out_dir): 425 def UseGoma(out_dir):
426 args_gn = os.path.join(out_dir, 'args.gn') 426 args_gn = os.path.join(out_dir, 'args.gn')
427 return 'use_goma = true' in open(args_gn, 'r').read() 427 return 'use_goma = true' in open(args_gn, 'r').read()
428 428
429 429
430 # Try to start goma, but don't bail out if we can't. Instead print an error
431 # message, and let the build fail with its own error messages as well.
432 def EnsureGomaStarted(out_dir):
433 args_gn_path = os.path.join(out_dir, 'args.gn')
434 goma_dir = None
435 with open(args_gn_path, 'r') as fp:
436 for line in fp:
437 if 'goma_dir' in line:
438 words = line.split()
439 goma_dir = words[2][1:-1] # goma_dir = "/path/to/goma"
440 if not goma_dir:
441 print 'Could not find goma for ' + out_dir
442 return False
443 if not os.path.exists(goma_dir) or not os.path.isdir(goma_dir):
444 print 'Could not find goma at ' + goma_dir
445 return False
446 goma_ctl = os.path.join(goma_dir, 'goma_ctl.py')
447 goma_ctl_command = [
448 'python',
449 goma_ctl,
450 'ensure_start',
451 ]
452 process = subprocess.Popen(goma_ctl_command)
453 process.wait()
454 if process.returncode != 0:
455 print ("Tried to run goma_ctl.py, but it failed. Try running it manually: "
456 + "\n\t" + ' '.join(goma_ctl_command))
457 return False
458 return True
459
460
461
430 def BuildNinjaCommand(options, target, target_os, mode, arch): 462 def BuildNinjaCommand(options, target, target_os, mode, arch):
431 out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os) 463 out_dir = utils.GetBuildRoot(HOST_OS, mode, arch, target_os)
432 if ShouldRunGN(out_dir): 464 if ShouldRunGN(out_dir):
433 RunGN(target_os, mode, arch) 465 RunGN(target_os, mode, arch)
434 command = ['ninja', '-C', out_dir] 466 command = ['ninja', '-C', out_dir]
435 if options.verbose: 467 if options.verbose:
436 command += ['-v'] 468 command += ['-v']
437 if UseGoma(out_dir): 469 if UseGoma(out_dir):
438 command += ['-j1000'] 470 if EnsureGomaStarted(out_dir):
471 command += ['-j1000']
472 else:
473 # If we couldn't ensure that goma is started, let the build start, but
474 # slowly so we can see any helpful error messages that pop out.
475 command += ['-j1']
439 command += [target] 476 command += [target]
440 return command 477 return command
441 478
442 479
443 filter_xcodebuild_output = False 480 filter_xcodebuild_output = False
444 def BuildOneConfig(options, target, target_os, mode, arch, override_tools): 481 def BuildOneConfig(options, target, target_os, mode, arch, override_tools):
445 global filter_xcodebuild_output 482 global filter_xcodebuild_output
446 start_time = time.time() 483 start_time = time.time()
447 args = [] 484 args = []
448 build_config = utils.GetBuildConf(mode, arch, target_os) 485 build_config = utils.GetBuildConf(mode, arch, target_os)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 else: 645 else:
609 if BuildOneConfig(options, target, target_os, 646 if BuildOneConfig(options, target, target_os,
610 mode, arch, cross_build) != 0: 647 mode, arch, cross_build) != 0:
611 return 1 648 return 1
612 649
613 return 0 650 return 0
614 651
615 652
616 if __name__ == '__main__': 653 if __name__ == '__main__':
617 sys.exit(Main()) 654 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