Bug 867966 - Add --jobs,-j option to 'mach build' r=gps

--HG--
extra : rebase_source : a1c1e0b371c11446a45025e03332a165699c78bf
This commit is contained in:
James Willcox 2013-05-02 17:05:24 -04:00
parent 42771dcfef
commit cead435e43
2 changed files with 10 additions and 5 deletions

View File

@ -202,7 +202,7 @@ class MozbuildObject(ProcessExecutionMixin):
srcdir=False, allow_parallel=True, line_handler=None,
append_env=None, explicit_env=None, ignore_errors=False,
ensure_exit_code=0, silent=True, print_directory=True,
pass_thru=False):
pass_thru=False, num_jobs=0):
"""Invoke make.
directory -- Relative directory to look for Makefile in.
@ -226,7 +226,10 @@ class MozbuildObject(ProcessExecutionMixin):
args.extend(['-f', filename])
if allow_parallel:
args.append('-j%d' % multiprocessing.cpu_count())
if num_jobs > 0:
args.append('-j%d' % num_jobs)
else:
args.append('-j%d' % multiprocessing.cpu_count())
if ignore_errors:
args.append('-k')

View File

@ -47,11 +47,13 @@ class Build(MachCommandBase):
"""Interface to build the tree."""
@Command('build', help='Build the tree.')
@CommandArgument('--jobs', '-j', default='0', metavar='jobs', type=int,
help='Number of concurrent jobs to run. Default is the number of CPUs.')
@CommandArgument('what', default=None, nargs='*', help=BUILD_WHAT_HELP)
@CommandArgument('-X', '--disable-extra-make-dependencies',
default=False, action='store_true',
help='Do not add extra make dependencies.')
def build(self, what=None, disable_extra_make_dependencies=None):
def build(self, what=None, disable_extra_make_dependencies=None, jobs=0):
# This code is only meant to be temporary until the more robust tree
# building code in bug 780329 lands.
from mozbuild.compilation.warnings import WarningsCollector
@ -125,14 +127,14 @@ class Build(MachCommandBase):
for make_dir, make_target in target_pairs:
status = self._run_make(directory=make_dir, target=make_target,
line_handler=on_line, log=False, print_directory=False,
ensure_exit_code=False)
ensure_exit_code=False, num_jobs=jobs)
if status != 0:
break
else:
status = self._run_make(srcdir=True, filename='client.mk',
line_handler=on_line, log=False, print_directory=False,
allow_parallel=False, ensure_exit_code=False)
allow_parallel=False, ensure_exit_code=False, num_jobs=jobs)
self.log(logging.WARNING, 'warning_summary',
{'count': len(warnings_collector.database)},