[jhbuild] Move 3x duplicated get_makeargs into new base class (GNOME bug 670213)
- From: Craig Keogh <cskeogh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] Move 3x duplicated get_makeargs into new base class (GNOME bug 670213)
- Date: Mon, 27 Aug 2012 12:37:31 +0000 (UTC)
commit a3b1f62eb3ea2851fb7e3306cf4a439d588d414b
Author: Craig Keogh <cskeogh adam com au>
Date: Fri Aug 24 15:51:50 2012 +0930
Move 3x duplicated get_makeargs into new base class (GNOME bug 670213)
jhbuild/modtypes/__init__.py | 22 ++++++++++++++++++++++
jhbuild/modtypes/autotools.py | 32 ++++++++++----------------------
jhbuild/modtypes/cmake.py | 18 +++---------------
jhbuild/modtypes/linux.py | 10 +++-------
4 files changed, 38 insertions(+), 44 deletions(-)
---
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 2b89c11..da95e15 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -470,6 +470,28 @@ them into the prefix."""
instance.pkg_config = pkg_config
return instance
+class MakeModule(Package):
+ '''A base class for modules that use the command 'make' within the build
+ process.'''
+ def __init__(self, name, branch=None, makeargs='', makeinstallargs='',
+ makefile='Makefile'):
+ Package.__init__(self, name, branch=branch)
+ self.makeargs = makeargs
+ self.makeinstallargs = makeinstallargs
+ self.makefile = makefile
+
+ def get_makeargs(self, buildscript, add_parallel=True):
+ makeargs = '%s %s' % (self.makeargs,
+ self.config.module_makeargs.get(
+ self.name, self.config.makeargs))
+ if self.supports_parallel_build and add_parallel:
+ # 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 self.eval_args(makeargs).strip()
+
+
class DownloadableModule:
PHASE_CHECKOUT = 'checkout'
PHASE_FORCE_CHECKOUT = 'force_checkout'
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index 921e24d..f40d839 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -26,11 +26,11 @@ import stat
from jhbuild.errors import FatalError, BuildStateError, CommandError
from jhbuild.modtypes import \
- Package, DownloadableModule, register_module_type
+ DownloadableModule, register_module_type, MakeModule
__all__ = [ 'AutogenModule' ]
-class AutogenModule(Package, DownloadableModule):
+class AutogenModule(MakeModule, DownloadableModule):
'''Base type for modules that are distributed with a Gnome style
"autogen.sh" script and the GNU build tools. Subclasses are
responsible for downloading/updating the working copy.'''
@@ -57,30 +57,18 @@ class AutogenModule(Package, DownloadableModule):
autogen_template=None,
check_target=True,
supports_static_analyzer=True):
- Package.__init__(self, name, branch=branch)
+ MakeModule.__init__(self, name, branch=branch, makeargs=makeargs,
+ makeinstallargs=makeinstallargs, makefile=makefile)
self.autogenargs = autogenargs
- self.makeargs = makeargs
- self.makeinstallargs = makeinstallargs
self.supports_non_srcdir_builds = supports_non_srcdir_builds
self.skip_autogen = skip_autogen
self.skip_install_phase = skip_install_phase
self.autogen_sh = autogen_sh
- self.makefile = makefile
self.autogen_template = autogen_template
self.check_target = check_target
self.supports_install_destdir = True
self.supports_static_analyzer = supports_static_analyzer
- def _get_makeargs(self, buildscript, add_parallel=True):
- makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
- self.name, self.config.makeargs)
- if self.supports_parallel_build and add_parallel:
- # 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
@@ -212,7 +200,7 @@ class AutogenModule(Package, DownloadableModule):
def do_clean(self, buildscript):
buildscript.set_action(_('Cleaning'), self)
- makeargs = self._get_makeargs(buildscript)
+ 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)
@@ -221,7 +209,7 @@ class AutogenModule(Package, DownloadableModule):
def do_build(self, buildscript):
buildscript.set_action(_('Building'), self)
- makeargs = self._get_makeargs(buildscript)
+ 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)
@@ -255,7 +243,7 @@ class AutogenModule(Package, DownloadableModule):
def do_check(self, buildscript):
buildscript.set_action(_('Checking'), self)
- makeargs = self._get_makeargs(buildscript, add_parallel=False)
+ makeargs = self.get_makeargs(buildscript, add_parallel=False)
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),
@@ -268,7 +256,7 @@ class AutogenModule(Package, DownloadableModule):
def do_dist(self, buildscript):
buildscript.set_action(_('Creating tarball for'), self)
- makeargs = self._get_makeargs(buildscript)
+ 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)
@@ -277,7 +265,7 @@ class AutogenModule(Package, DownloadableModule):
def do_distcheck(self, buildscript):
buildscript.set_action(_('Dist checking'), self)
- makeargs = self._get_makeargs(buildscript)
+ 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)
@@ -311,7 +299,7 @@ class AutogenModule(Package, DownloadableModule):
if hasattr(self.branch, 'delete_unknown_files'):
self.branch.delete_unknown_files(buildscript)
else:
- makeargs = self._get_makeargs(buildscript)
+ 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 fa4e23d..d242c2b 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -23,12 +23,12 @@ import os
from jhbuild.errors import BuildStateError, CommandError
from jhbuild.modtypes import \
- Package, DownloadableModule, register_module_type
+ Package, DownloadableModule, register_module_type, MakeModule
from jhbuild.commands.sanitycheck import inpath
__all__ = [ 'CMakeModule' ]
-class CMakeModule(Package, DownloadableModule):
+class CMakeModule(MakeModule, DownloadableModule):
"""Base type for modules that use CMake build system."""
type = 'cmake'
@@ -41,9 +41,8 @@ class CMakeModule(Package, DownloadableModule):
def __init__(self, name, branch=None,
cmakeargs='', makeargs='',):
- Package.__init__(self, name, branch=branch)
+ MakeModule.__init__(self, name, branch=branch, makeargs=makeargs)
self.cmakeargs = cmakeargs
- self.makeargs = makeargs
self.supports_non_srcdir_builds = True
self.supports_install_destdir = True
@@ -72,17 +71,6 @@ class CMakeModule(Package, DownloadableModule):
self.name, self.config.cmakeargs))
return self.eval_args(args)
- def get_makeargs(self):
- 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).strip()
-
def do_configure(self, buildscript):
buildscript.set_action(_('Configuring'), self)
srcdir = self.get_srcdir(buildscript)
diff --git a/jhbuild/modtypes/linux.py b/jhbuild/modtypes/linux.py
index 7c34763..f2cdef7 100644
--- a/jhbuild/modtypes/linux.py
+++ b/jhbuild/modtypes/linux.py
@@ -26,7 +26,7 @@ import errno
from jhbuild.errors import FatalError, BuildStateError
from jhbuild.modtypes import \
- Package, register_module_type
+ register_module_type, MakeModule
__all__ = [ 'LinuxModule' ]
@@ -45,7 +45,7 @@ class LinuxConfig:
raise BuildStateError(_('kconfig file %s was not created') % self.path)
-class LinuxModule(Package):
+class LinuxModule(MakeModule):
'''For modules that are built with the linux kernel method of
make config, make, make install and make modules_install.'''
type = 'linux'
@@ -62,9 +62,8 @@ class LinuxModule(Package):
PHASE_INSTALL = 'install'
def __init__(self, name, branch=None, kconfigs=None, makeargs=None):
- Package.__init__(self, name, branch=branch)
+ MakeModule.__init__(self, name, branch=branch, makeargs=makeargs)
self.kconfigs = kconfigs
- self.makeargs = makeargs
def get_srcdir(self, buildscript):
return self.branch.srcdir
@@ -90,9 +89,6 @@ class LinuxModule(Package):
self.branch.force_checkout(buildscript)
do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT, PHASE_MRPROPER]
- def get_makeargs(self):
- return self.makeargs + ' ' + self.config.module_makeargs.get(self.name, self.config.makeargs)
-
def do_mrproper(self, buildscript):
buildscript.set_action(_('make mrproper'), self)
for kconfig in self.kconfigs:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]