Chromium Code Reviews| Index: scripts/slave/compile.py |
| diff --git a/scripts/slave/compile.py b/scripts/slave/compile.py |
| index d7310ec875da1963335f312b7520f5f561c74b47..808c1f30b29fcc1dc9ed2de57e8229195e605ac3 100755 |
| --- a/scripts/slave/compile.py |
| +++ b/scripts/slave/compile.py |
| @@ -71,7 +71,7 @@ class EchoDict(dict): |
| fh.write(' %s (removed)\n' % k) |
| fh.write('\n') |
| - |
| +# TODO(tikuta): move to goma_utils.py |
|
shinyak
2016/07/21 02:53:07
nit: Two blank lines between top-level definitions
tikuta
2016/07/21 03:34:35
Done.
|
| def goma_setup(options, env): |
| """Sets up goma if necessary. |
| @@ -222,7 +222,7 @@ def goma_setup(options, env): |
| env['GOMA_DISABLED'] = '1' |
| return False, None |
| - |
| +# TODO(tikuta): move to goma_utils.py |
|
shinyak
2016/07/21 02:53:07
ditto
tikuta
2016/07/21 03:34:35
Done.
|
| def goma_teardown(options, env, exit_status, cloudtail_proc): |
| """Tears down goma if necessary. """ |
| if (options.compiler in ('goma', 'goma-clang') and |
| @@ -345,21 +345,21 @@ def UpdateWindowsEnvironment(envfile_dir, env): |
| f.write(nul * 2) |
| -def main_ninja(options, args): |
| - """Interprets options, clobbers object files, and calls ninja.""" |
| +def main_ninja(options, args, env): |
| + """This function calls ninja. |
| - # Prepare environment. |
| - env = EchoDict(os.environ) |
| - goma_ready, goma_cloudtail = goma_setup(options, env) |
| - exit_status = -1 |
| - try: |
| - if not goma_ready: |
| - assert options.compiler not in ('goma', 'goma-clang') |
| - assert options.goma_dir is None |
| + Args: |
| + options (Option): options for ninja command. |
| + args (str): extra args for ninja command. |
| + env (dict): Used when ninja command executes. |
| - # ninja is different from all the other build systems in that it requires |
| - # most configuration to be done at gyp time. This is why this function does |
| - # less than the other comparable functions in this file. |
| + Returns: |
| + (int, str): first element for ninja command exit status. |
| + second element is actual command to run ninja. |
| + |
| + """ |
| + |
| + try: |
| print 'chdir to %s' % options.src_dir |
| os.chdir(options.src_dir) |
| @@ -427,14 +427,17 @@ def main_ninja(options, args): |
| if hostname in ( |
| ['build14-m1', 'build48-m1'] + |
| # Also increasing cpus for v8/blink trybots. |
| - ['build%d-m4' % x for x in xrange(45, 48)] + |
| + ['build%d-m4' % x for x in range(45, 48)] + |
| # Also increasing cpus for LTO buildbots. |
| ['slave%d-c1' % x for x in [20, 33] + range(78, 108)]): |
| return min(10 * number_of_processors, 200) |
| return 50 |
| - goma_jobs = determine_goma_jobs() |
| + if not options.goma_jobs: |
| + goma_jobs = determine_goma_jobs() |
| + else: |
| + goma_jobs = options.goma_jobs |
| command.append('-j%d' % goma_jobs) |
| # Run the build. |
| @@ -455,8 +458,6 @@ def main_ninja(options, args): |
| return 1 |
| return exit_status |
| finally: |
| - goma_teardown(options, env, exit_status, goma_cloudtail) |
| - |
| override_gsutil = None |
| if options.gsutil_py_path: |
| override_gsutil = [sys.executable, options.gsutil_py_path] |
| @@ -479,7 +480,7 @@ def get_target_build_dir(args, options): |
| return os.path.abspath(os.path.join(options.src_dir, outdir, options.target)) |
| -def real_main(): |
| +def get_parsed_options(): |
| option_parser = optparse.OptionParser() |
| option_parser.add_option('--clobber', action='store_true', default=False, |
| help='delete the output directory before compiling') |
| @@ -528,6 +529,8 @@ def real_main(): |
| option_parser.add_option('--goma-service-account-json-file', |
| help='Specify a file containing goma service account' |
| ' credentials') |
| + option_parser.add_option('--goma-jobs', default=None, |
| + help='The number of jobs for ninja -j.') |
| option_parser.add_option('--gsutil-py-path', |
| help='Specify path to gsutil.py script.') |
| option_parser.add_option('--ninja-path', default='ninja', |
| @@ -546,7 +549,29 @@ def real_main(): |
| options.target_output_dir = get_target_build_dir(args, options) |
| assert options.build_tool in (None, 'ninja') |
| - return main_ninja(options, args) |
| + return options, args |
| + |
| + |
| +def real_main(): |
| + options, args = get_parsed_options() |
| + |
| + # Prepare environment. |
| + env = EchoDict(os.environ) |
| + |
| + # start goma |
| + goma_ready, goma_cloudtail = goma_setup(options, env) |
| + |
| + if not goma_ready: |
| + assert options.compiler not in ('goma', 'goma-clang') |
| + assert options.goma_dir is None |
| + |
| + # build |
| + exit_status = main_ninja(options, args, env) |
| + |
| + # stop goma |
| + goma_teardown(options, env, exit_status, goma_cloudtail) |
| + |
| + return exit_status |
| if '__main__' == __name__: |