| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 return codename | 406 return codename |
| 407 | 407 |
| 408 | 408 |
| 409 def common_make_settings( | 409 def common_make_settings( |
| 410 command, options, env, crosstool=None, compiler=None): | 410 command, options, env, crosstool=None, compiler=None): |
| 411 """ | 411 """ |
| 412 Sets desirable environment variables and command-line options | 412 Sets desirable environment variables and command-line options |
| 413 that are common to the Make and SCons builds. Used on Linux | 413 that are common to the Make and SCons builds. Used on Linux |
| 414 and for the mac make build. | 414 and for the mac make build. |
| 415 """ | 415 """ |
| 416 # TODO(thakis): Add goma-clang support to the make build. | 416 assert compiler in (None, 'clang', 'goma', 'goma-clang', 'asan', 'tsan_gcc') |
| 417 assert compiler in (None, 'clang', 'goma', 'asan', 'tsan_gcc') | |
| 418 if options.mode == 'google_chrome' or options.mode == 'official': | 417 if options.mode == 'google_chrome' or options.mode == 'official': |
| 419 env['CHROMIUM_BUILD'] = '_google_chrome' | 418 env['CHROMIUM_BUILD'] = '_google_chrome' |
| 420 | 419 |
| 421 if options.mode == 'official': | 420 if options.mode == 'official': |
| 422 # Official builds are always Google Chrome. | 421 # Official builds are always Google Chrome. |
| 423 env['OFFICIAL_BUILD'] = '1' | 422 env['OFFICIAL_BUILD'] = '1' |
| 424 env['CHROME_BUILD_TYPE'] = '_official' | 423 env['CHROME_BUILD_TYPE'] = '_official' |
| 425 | 424 |
| 426 # Don't stop at the first error. | 425 # Don't stop at the first error. |
| 427 command.append('-k') | 426 command.append('-k') |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 env['CXX'] = ccache + crosstool + '-g++' | 464 env['CXX'] = ccache + crosstool + '-g++' |
| 466 env['LD'] = crosstool + '-ld' | 465 env['LD'] = crosstool + '-ld' |
| 467 env['RANLIB'] = crosstool + '-ranlib' | 466 env['RANLIB'] = crosstool + '-ranlib' |
| 468 command.append('-j%d' % jobs) | 467 command.append('-j%d' % jobs) |
| 469 # Don't use build-in rules. | 468 # Don't use build-in rules. |
| 470 command.append('-r') | 469 command.append('-r') |
| 471 # For now only build chrome, as other things will break. | 470 # For now only build chrome, as other things will break. |
| 472 command.append('chrome') | 471 command.append('chrome') |
| 473 return | 472 return |
| 474 | 473 |
| 475 if compiler == 'goma': | 474 if compiler in ('goma', 'goma-clang'): |
| 476 print 'using goma' | 475 print 'using', compiler |
| 477 env['CC'] = 'gcc' | 476 if compiler == 'goma': |
| 478 env['CXX'] = 'g++' | 477 env['CC'] = 'gcc' |
| 479 env['PATH'] = options.goma_dir + ':' + env['PATH'] | 478 env['CXX'] = 'g++' |
| 480 goma_jobs = 100 | 479 env['PATH'] = ':'.join([options.goma_dir, env['PATH']]) |
| 480 else: # goma-clang |
| 481 env['CC'] = 'clang' |
| 482 env['CXX'] = 'clang++' |
| 483 clang_dir = os.path.abspath(os.path.join( |
| 484 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', |
| 485 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) |
| 486 env['PATH'] = ':'.join([options.goma_dir, clang_dir, env['PATH']]) |
| 487 |
| 488 command.append('CC.host=' + env['CC']) |
| 489 command.append('CXX.host=' + env['CXX']) |
| 490 |
| 491 if chromium_utils.IsMac(): |
| 492 # The default process limit on 10.6 is 266 (`sysctl kern.maxprocperuid`), |
| 493 # and about 100 processes are used by the system. The webkit bindings |
| 494 # generation scripts open a preprocessor child process, so building at |
| 495 # -j100 runs into the process limit. For now, just build with -j50. |
| 496 goma_jobs = 50 |
| 497 else: |
| 498 goma_jobs = 100 |
| 481 if jobs < goma_jobs: | 499 if jobs < goma_jobs: |
| 482 jobs = goma_jobs | 500 jobs = goma_jobs |
| 483 command.append('-j%d' % jobs) | 501 command.append('-j%d' % jobs) |
| 484 return | 502 return |
| 485 | 503 |
| 486 if compiler == 'clang': | 504 if compiler == 'clang': |
| 487 clang_dir = os.path.abspath(os.path.join( | 505 clang_dir = os.path.abspath(os.path.join( |
| 488 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', | 506 slave_utils.SlaveBaseDir(options.build_dir), 'build', 'src', |
| 489 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) | 507 'third_party', 'llvm-build', 'Release+Asserts', 'bin')) |
| 490 env['CC'] = os.path.join(clang_dir, 'clang') | 508 env['CC'] = os.path.join(clang_dir, 'clang') |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 | 633 |
| 616 # V=1 prints the actual executed command | 634 # V=1 prints the actual executed command |
| 617 if options.verbose: | 635 if options.verbose: |
| 618 command.extend(['V=1']) | 636 command.extend(['V=1']) |
| 619 command.extend(options.build_args + args) | 637 command.extend(options.build_args + args) |
| 620 | 638 |
| 621 # If using the Goma compiler, first call goma_ctl with ensure_start | 639 # If using the Goma compiler, first call goma_ctl with ensure_start |
| 622 # (or restart in clobber mode) to ensure the proxy is available. | 640 # (or restart in clobber mode) to ensure the proxy is available. |
| 623 goma_ctl_cmd = [os.path.join(options.goma_dir, 'goma_ctl.sh')] | 641 goma_ctl_cmd = [os.path.join(options.goma_dir, 'goma_ctl.sh')] |
| 624 | 642 |
| 625 if options.compiler == 'goma': | 643 if options.compiler in ('goma', 'goma-clang'): |
| 626 goma_key = os.path.join(options.goma_dir, 'goma.key') | 644 goma_key = os.path.join(options.goma_dir, 'goma.key') |
| 627 env['GOMA_COMPILER_PROXY_DAEMON_MODE'] = 'true' | 645 env['GOMA_COMPILER_PROXY_DAEMON_MODE'] = 'true' |
| 628 if os.path.exists(goma_key): | 646 if os.path.exists(goma_key): |
| 629 env['GOMA_API_KEY_FILE'] = goma_key | 647 env['GOMA_API_KEY_FILE'] = goma_key |
| 630 if options.clobber: | 648 if options.clobber: |
| 631 chromium_utils.RunCommand(goma_ctl_cmd + ['restart'], env=env) | 649 chromium_utils.RunCommand(goma_ctl_cmd + ['restart'], env=env) |
| 632 else: | 650 else: |
| 633 chromium_utils.RunCommand(goma_ctl_cmd + ['ensure_start'], env=env) | 651 chromium_utils.RunCommand(goma_ctl_cmd + ['ensure_start'], env=env) |
| 634 | 652 |
| 635 # Run the build. | 653 # Run the build. |
| 636 result = chromium_utils.RunCommand(command, env=env) | 654 result = chromium_utils.RunCommand(command, env=env) |
| 637 | 655 |
| 638 if options.compiler == 'goma': | 656 if options.compiler in ('goma', 'goma-clang'): |
| 639 # Always stop the proxy for now to allow in-place update. | 657 # Always stop the proxy for now to allow in-place update. |
| 640 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) | 658 chromium_utils.RunCommand(goma_ctl_cmd + ['stop'], env=env) |
| 641 | 659 |
| 642 return result | 660 return result |
| 643 | 661 |
| 644 | 662 |
| 645 def main_scons(options, args): | 663 def main_scons(options, args): |
| 646 """Interprets options, clobbers object files, and calls scons. | 664 """Interprets options, clobbers object files, and calls scons. |
| 647 """ | 665 """ |
| 648 options.build_dir = os.path.abspath(options.build_dir) | 666 options.build_dir = os.path.abspath(options.build_dir) |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 main = build_tool_map.get(options.build_tool) | 970 main = build_tool_map.get(options.build_tool) |
| 953 if not main: | 971 if not main: |
| 954 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) | 972 sys.stderr.write('Unknown build tool %s.\n' % repr(options.build_tool)) |
| 955 return 2 | 973 return 2 |
| 956 | 974 |
| 957 return main(options, args) | 975 return main(options, args) |
| 958 | 976 |
| 959 | 977 |
| 960 if '__main__' == __name__: | 978 if '__main__' == __name__: |
| 961 sys.exit(real_main()) | 979 sys.exit(real_main()) |
| OLD | NEW |