[jhbuild] Do parallel builds by default
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] Do parallel builds by default
- Date: Thu, 10 Nov 2011 19:06:04 +0000 (UTC)
commit d75e72a5fb5a0313b916db921116accd396fb89e
Author: Colin Walters <walters verbum org>
Date: Sat Jul 30 10:46:03 2011 -0400
Do parallel builds by default
Add a new "jobs" config option which specifies what to give to
"make -jX".
Also annotate nss as broken in this respect.
https://bugzilla.gnome.org/show_bug.cgi?id=654686
jhbuild/config.py | 2 +-
jhbuild/defaults.jhbuildrc | 12 ++++++++++
jhbuild/modtypes/__init__.py | 2 +
jhbuild/modtypes/autotools.py | 28 ++++++++++++++----------
jhbuild/modtypes/cmake.py | 5 ++++
jhbuild/modtypes/waf.py | 3 ++
modulesets/gnome-suites-core-deps-3.2.modules | 4 ++-
7 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/jhbuild/config.py b/jhbuild/config.py
index 27214e9..6894dd1 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -41,7 +41,7 @@ _default_jhbuildrc = os.path.join(os.environ['HOME'], '.jhbuildrc')
_known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
'partial_build', 'checkoutroot', 'buildroot', 'top_builddir',
- 'autogenargs', 'makeargs', 'nice_build',
+ 'autogenargs', 'makeargs', 'nice_build', 'jobs',
'installprog', 'repos', 'branches', 'noxvfb', 'xvfbargs',
'builddir_pattern', 'module_autogenargs', 'module_makeargs',
'interact', 'buildscript', 'nonetwork',
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 7ec43a7..3fa8e67 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -47,6 +47,18 @@ buildroot = None # if set, packages will be built with srcdir!=builddir
# substituted with the srcdir base component.
builddir_pattern = '%s'
+## @jobs: This value will be used as "X" in "make -jX" for modules
+## which support parallel builds. Note that if you set "makeargs"
+## to include a -j option, that will take precedence.
+try:
+ import multiprocessing
+ jobs = multiprocessing.cpu_count() * 2
+except ImportError, e:
+ try:
+ jobs = 2 * os.sysconf('SC_NPROCESSORS_ONLN')
+ except (OSError, AttributeError, ValueError):
+ jobs = 2
+
# override environment variables, command line arguments, etc
autogenargs = '--disable-static --disable-gtk-doc'
cmakeargs = ''
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 55576c8..dd75b98 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -155,6 +155,7 @@ class Package:
self.tags = []
self.moduleset_name = None
self.supports_install_destdir = False
+ self.supports_parallel_build = True
def __repr__(self):
return "<%s '%s'>" % (self.__class__.__name__, self.name)
@@ -418,6 +419,7 @@ them into the prefix."""
instance = cls(name)
instance.branch = get_branch(node, repositories, default_repo, config)
instance.dependencies, instance.after, instance.suggests = get_dependencies(node)
+ instance.supports_parallel_build = (node.getAttribute('supports-parallel-builds') != 'no')
pkg_config = find_first_child_node_content(node, 'pkg-config')
if pkg_config != '':
instance.pkg_config = pkg_config
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index df1800e..6fcdaba 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -69,6 +69,16 @@ class AutogenModule(Package, DownloadableModule):
self.supports_install_destdir = True
self.supports_static_analyzer = supports_static_analyzer
+ def _get_makeargs(self, buildscript):
+ makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
+ self.name, self.config.makeargs)
+ if self.supports_parallel_build:
+ # Propagate job count into makeargs, unless -j is already set
+ if ' -j' not in makeargs:
+ arg = '-j %s' % (buildscript.config.jobs, )
+ makeargs = makeargs + ' ' + arg
+ return makeargs.strip()
+
def get_srcdir(self, buildscript):
return self.branch.srcdir
@@ -199,8 +209,7 @@ class AutogenModule(Package, DownloadableModule):
def do_clean(self, buildscript):
buildscript.set_action(_('Cleaning'), self)
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
+ makeargs = self._get_makeargs(buildscript)
cmd = '%s %s clean' % (os.environ.get('MAKE', 'make'), makeargs)
buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
extra_env = self.extra_env)
@@ -209,8 +218,7 @@ class AutogenModule(Package, DownloadableModule):
def do_build(self, buildscript):
buildscript.set_action(_('Building'), self)
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
+ makeargs = self._get_makeargs(buildscript)
cmd = '%s%s %s' % (self.static_analyzer_pre_cmd(buildscript), os.environ.get('MAKE', 'make'), makeargs)
buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
extra_env = self.extra_env)
@@ -244,8 +252,7 @@ class AutogenModule(Package, DownloadableModule):
def do_check(self, buildscript):
buildscript.set_action(_('Checking'), self)
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
+ makeargs = self._get_makeargs(buildscript)
cmd = '%s%s %s check' % (self.static_analyzer_pre_cmd(buildscript), os.environ.get('MAKE', 'make'), makeargs)
try:
buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
@@ -258,8 +265,7 @@ class AutogenModule(Package, DownloadableModule):
def do_dist(self, buildscript):
buildscript.set_action(_('Creating tarball for'), self)
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
+ makeargs = self._get_makeargs(buildscript)
cmd = '%s %s dist' % (os.environ.get('MAKE', 'make'), makeargs)
buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
extra_env = self.extra_env)
@@ -268,8 +274,7 @@ class AutogenModule(Package, DownloadableModule):
def do_distcheck(self, buildscript):
buildscript.set_action(_('Dist checking'), self)
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
+ makeargs = self._get_makeargs(buildscript)
cmd = '%s %s distcheck' % (os.environ.get('MAKE', 'make'), makeargs)
buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
extra_env = self.extra_env)
@@ -294,8 +299,7 @@ class AutogenModule(Package, DownloadableModule):
def do_distclean(self, buildscript):
buildscript.set_action(_('Distcleaning'), self)
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
+ makeargs = self._get_makeargs(buildscript)
cmd = '%s %s distclean' % (os.environ.get('MAKE', 'make'), makeargs)
buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
extra_env = self.extra_env)
diff --git a/jhbuild/modtypes/cmake.py b/jhbuild/modtypes/cmake.py
index 6da1be7..d71b02b 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -76,6 +76,11 @@ class CMakeModule(Package, DownloadableModule):
args = '%s %s' % (self.makeargs,
self.config.module_makeargs.get(
self.name, self.config.makeargs))
+ if self.supports_parallel_build:
+ # Propagate job count into makeargs, unless -j is already set
+ if ' -j' not in args:
+ arg = '-j %s' % (self.config.jobs, )
+ args = args + ' ' + arg
return self.eval_args(args)
def skip_configure(self, buildscript, last_phase):
diff --git a/jhbuild/modtypes/waf.py b/jhbuild/modtypes/waf.py
index 071222b..c05222c 100644
--- a/jhbuild/modtypes/waf.py
+++ b/jhbuild/modtypes/waf.py
@@ -91,6 +91,9 @@ class WafModule(Package, DownloadableModule):
def do_build(self, buildscript):
buildscript.set_action(_('Building'), self)
cmd = [self.waf_cmd, 'build']
+ if self.supports_parallel_build:
+ cmd.append('-j')
+ cmd.append('%s' % (buildscript.config.jobs, ))
buildscript.execute(cmd, cwd=self.get_builddir(buildscript))
do_build.depends = [PHASE_CONFIGURE]
do_build.error_phases = [PHASE_FORCE_CHECKOUT, PHASE_CONFIGURE]
diff --git a/modulesets/gnome-suites-core-deps-3.2.modules b/modulesets/gnome-suites-core-deps-3.2.modules
index 5e3d01d..7f706eb 100644
--- a/modulesets/gnome-suites-core-deps-3.2.modules
+++ b/modulesets/gnome-suites-core-deps-3.2.modules
@@ -1002,7 +1002,9 @@
</autotools>
<autotools id="nss"
- autogen-sh="autogen.sh" supports-non-srcdir-builds="no"
+ autogen-sh="autogen.sh"
+ supports-non-srcdir-builds="no"
+ supports-parallel-builds="no"
check-target="false">
<pkg-config>nss.pc</pkg-config>
<branch repo="ftp.mozilla.org"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]