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

Side by Side Diff: scripts/slave/compile.py

Issue 2089333003: compile.py: Simplify --build-tool logic. It's always ninja now. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build@master
Patch Set: Created 4 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
« 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A tool to build chrome, executed by buildbot. 6 """A tool to build chrome, executed by buildbot.
7 7
8 When this is run, the current directory (cwd) should be the outer build 8 When this is run, the current directory (cwd) should be the outer build
9 directory (e.g., chrome-release/build/). 9 directory (e.g., chrome-release/build/).
10 10
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if options.gsutil_py_path: 447 if options.gsutil_py_path:
448 override_gsutil = [sys.executable, options.gsutil_py_path] 448 override_gsutil = [sys.executable, options.gsutil_py_path]
449 449
450 goma_utils.UploadNinjaLog( 450 goma_utils.UploadNinjaLog(
451 options.target_output_dir, options.compiler, command, exit_status, 451 options.target_output_dir, options.compiler, command, exit_status,
452 override_gsutil=override_gsutil) 452 override_gsutil=override_gsutil)
453 453
454 454
455 def get_target_build_dir(args, options): 455 def get_target_build_dir(args, options):
456 """Keep this function in sync with src/build/landmines.py""" 456 """Keep this function in sync with src/build/landmines.py"""
457 assert options.build_tool == 'ninja'
458 if chromium_utils.IsLinux() and options.cros_board: 457 if chromium_utils.IsLinux() and options.cros_board:
459 # When building ChromeOS's Simple Chrome workflow, the output directory 458 # When building ChromeOS's Simple Chrome workflow, the output directory
460 # has a CROS board name suffix. 459 # has a CROS board name suffix.
461 outdir = 'out_%s' % (options.cros_board,) 460 outdir = 'out_%s' % (options.cros_board,)
462 elif options.out_dir: 461 elif options.out_dir:
463 outdir = options.out_dir 462 outdir = options.out_dir
464 else: 463 else:
465 outdir = 'out' 464 outdir = 'out'
466 return os.path.abspath(os.path.join(options.src_dir, outdir, options.target)) 465 return os.path.abspath(os.path.join(options.src_dir, outdir, options.target))
467 466
468 467
469 def real_main(): 468 def real_main():
470 option_parser = optparse.OptionParser() 469 option_parser = optparse.OptionParser()
471 option_parser.add_option('--clobber', action='store_true', default=False, 470 option_parser.add_option('--clobber', action='store_true', default=False,
472 help='delete the output directory before compiling') 471 help='delete the output directory before compiling')
473 option_parser.add_option('--target', default='Release', 472 option_parser.add_option('--target', default='Release',
474 help='build target (Debug or Release)') 473 help='build target (Debug or Release)')
475 option_parser.add_option('--src-dir', default=None, 474 option_parser.add_option('--src-dir', default=None,
476 help='path to the root of the source tree') 475 help='path to the root of the source tree')
477 option_parser.add_option('--mode', default='dev', 476 option_parser.add_option('--mode', default='dev',
478 help='build mode (dev or official) controlling ' 477 help='build mode (dev or official) controlling '
479 'environment variables set during build') 478 'environment variables set during build')
479 # TODO(thakis): Remove this once bots no longer pass it in.
480 option_parser.add_option('--build-tool', default=None, help='ignored') 480 option_parser.add_option('--build-tool', default=None, help='ignored')
481 option_parser.add_option('--build-args', action='append', default=[], 481 option_parser.add_option('--build-args', action='append', default=[],
482 help='arguments to pass to the build tool') 482 help='arguments to pass to the build tool')
483 option_parser.add_option('--build-data-dir', action='store', 483 option_parser.add_option('--build-data-dir', action='store',
484 help='specify a build data directory.') 484 help='specify a build data directory.')
485 option_parser.add_option('--compiler', default=None, 485 option_parser.add_option('--compiler', default=None,
486 help='specify alternative compiler (e.g. clang)') 486 help='specify alternative compiler (e.g. clang)')
487 if chromium_utils.IsLinux(): 487 if chromium_utils.IsLinux():
488 option_parser.add_option('--cros-board', action='store', 488 option_parser.add_option('--cros-board', action='store',
489 help='If building for the ChromeOS Simple Chrome ' 489 help='If building for the ChromeOS Simple Chrome '
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 help='Checks the output of the ninja builder to ' 523 help='Checks the output of the ninja builder to '
524 'confirm that a second compile immediately ' 524 'confirm that a second compile immediately '
525 'the first is a no-op.') 525 'the first is a no-op.')
526 526
527 options, args = option_parser.parse_args() 527 options, args = option_parser.parse_args()
528 528
529 if not options.src_dir: 529 if not options.src_dir:
530 options.src_dir = 'src' 530 options.src_dir = 'src'
531 options.src_dir = os.path.abspath(options.src_dir) 531 options.src_dir = os.path.abspath(options.src_dir)
532 532
533 options.build_dir = os.path.abspath(build_directory.GetBuildOutputDirectory(
534 os.path.basename(options.src_dir)))
535
536 if options.build_tool is None:
537 if chromium_utils.IsWindows():
538 main = main_ninja
539 options.build_tool = 'ninja'
540 # TODO(thakis): Merge this with the branch below and simplify.
541 elif chromium_utils.IsLinux() or chromium_utils.IsMac():
542 main = main_ninja
543 options.build_tool = 'ninja'
544 else:
545 print 'Please specify --build-tool.'
546 return 1
547 else:
548 build_tool_map = { 'ninja' : main_ninja }
549 main = build_tool_map.get(options.build_tool)
550 if not main:
551 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool))
552 return 2
553
554 options.target_output_dir = get_target_build_dir(args, options) 533 options.target_output_dir = get_target_build_dir(args, options)
555 534
556 return main(options, args) 535 assert options.build_tool in (None, 'ninja')
536 return main_ninja(options, args)
557 537
558 538
559 if '__main__' == __name__: 539 if '__main__' == __name__:
560 sys.exit(real_main()) 540 sys.exit(real_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