[jhbuild] Promote & use eval_args, to avoid re.sub (GNOME bug 670683)
- From: Craig Keogh <cskeogh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] Promote & use eval_args, to avoid re.sub (GNOME bug 670683)
- Date: Thu, 3 May 2012 12:10:39 +0000 (UTC)
commit 4b85c395c57cf16636e54901e2658a87b3956aa9
Author: Craig Keogh <cskeogh adam com au>
Date: Wed Apr 18 16:03:06 2012 +0930
Promote & use eval_args, to avoid re.sub (GNOME bug 670683)
re.sub gives errors on some paths, string.replace is better suited.
Based upon patch by Marcin Wojdyr.
jhbuild/modtypes/__init__.py | 10 ++++++++++
jhbuild/modtypes/autotools.py | 20 +++-----------------
jhbuild/modtypes/cmake.py | 9 ---------
jhbuild/modtypes/linux.py | 5 +----
jhbuild/modtypes/perl.py | 6 +-----
jhbuild/moduleset.py | 1 -
6 files changed, 15 insertions(+), 36 deletions(-)
---
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 5e7ddc5..9197f8f 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -160,6 +160,15 @@ class Package:
def __repr__(self):
return "<%s '%s'>" % (self.__class__.__name__, self.name)
+ def eval_args(self, args):
+ args = args.replace('${prefix}', self.config.prefix)
+ libsubdir = 'lib'
+ if self.config.use_lib64:
+ libsubdir = 'lib64'
+ libdir = os.path.join(self.config.prefix, libsubdir)
+ args = args.replace('${libdir}', libdir)
+ return args
+
def get_extra_env(self):
return self.config.module_extra_env.get(self.name)
extra_env = property(get_extra_env)
@@ -431,6 +440,7 @@ them into the prefix."""
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')
+ instance.config = config
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 8a5a50b..98e1dad 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -323,29 +323,15 @@ class AutogenModule(Package, DownloadableModule):
def parse_autotools(node, config, uri, repositories, default_repo):
instance = AutogenModule.parse_from_xml(node, config, uri, repositories, default_repo)
- # Make some substitutions; do special handling of '${prefix}' and '${libdir}'
- prefix_re = re.compile('(\${prefix})')
- # I'm not sure the replacement of ${libdir} is necessary for firefox...
- libdir_re = re.compile('(\${libdir})')
- libsubdir = '/lib'
- if config.use_lib64:
- libsubdir = '/lib64'
-
if node.hasAttribute('autogenargs'):
autogenargs = node.getAttribute('autogenargs')
- autogenargs = prefix_re.sub(config.prefix, autogenargs)
- autogenargs = libdir_re.sub(config.prefix + libsubdir, autogenargs)
- instance.autogenargs = autogenargs
+ instance.autogenargs = instance.eval_args(autogenargs)
if node.hasAttribute('makeargs'):
makeargs = node.getAttribute('makeargs')
- makeargs = prefix_re.sub(config.prefix, makeargs)
- makeargs = libdir_re.sub(config.prefix + libsubdir, makeargs)
- instance.makeargs = makeargs
+ instance.makeargs = instance.eval_args(makeargs)
if node.hasAttribute('makeinstallargs'):
makeinstallargs = node.getAttribute('makeinstallargs')
- makeinstallargs = prefix_re.sub(config.prefix, makeinstallargs)
- makeinstallargs = libdir_re.sub(config.prefix + libsubdir, makeinstallargs)
- instance.makeinstallargs = makeinstallargs
+ instance.makeinstallargs = instance.eval_args(makeinstallargs)
if node.hasAttribute('supports-non-srcdir-builds'):
instance.supports_non_srcdir_builds = \
diff --git a/jhbuild/modtypes/cmake.py b/jhbuild/modtypes/cmake.py
index 76567c9..7ba4a33 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -57,15 +57,6 @@ class CMakeModule(Package, DownloadableModule):
else:
return self.get_srcdir(buildscript)
- def eval_args(self, args):
- args = args.replace('${prefix}', self.config.prefix)
- libsubdir = 'lib'
- if self.config.use_lib64:
- libsubdir = 'lib64'
- libdir = os.path.join(self.config.prefix, libsubdir)
- args = args.replace('${libdir}', libdir)
- return args
-
def get_cmakeargs(self):
args = '%s %s' % (self.cmakeargs,
self.config.module_cmakeargs.get(
diff --git a/jhbuild/modtypes/linux.py b/jhbuild/modtypes/linux.py
index 54f35e2..6372c42 100644
--- a/jhbuild/modtypes/linux.py
+++ b/jhbuild/modtypes/linux.py
@@ -21,7 +21,6 @@
__metaclass__ = type
import os
-import re
import shutil
import errno
@@ -275,9 +274,7 @@ def parse_linux(node, config, uri, repositories, default_repo):
makeargs = ''
if node.hasAttribute('makeargs'):
makeargs = node.getAttribute('makeargs')
- # Make some substitutions; do special handling of '${prefix}' and '${libdir}'
- p = re.compile('(\${prefix})')
- makeargs = p.sub(config.prefix, makeargs)
+ makeargs = makeargs.replace('${prefix}', config.prefix)
dependencies, after, suggests = get_dependencies(node)
branch = get_branch(node, repositories, default_repo, config)
diff --git a/jhbuild/modtypes/perl.py b/jhbuild/modtypes/perl.py
index 61c58aa..bde229e 100644
--- a/jhbuild/modtypes/perl.py
+++ b/jhbuild/modtypes/perl.py
@@ -20,7 +20,6 @@
__metaclass__ = type
import os
-import re
from jhbuild.errors import BuildStateError
from jhbuild.modtypes import \
@@ -83,12 +82,9 @@ class PerlModule(Package, DownloadableModule):
def parse_perl(node, config, uri, repositories, default_repo):
instance = PerlModule.parse_from_xml(node, config, uri, repositories, default_repo)
- # Make some substitutions; do special handling of '${prefix}'
- prefix_re = re.compile('(\${prefix})')
if node.hasAttribute('makeargs'):
makeargs = node.getAttribute('makeargs')
- makeargs = prefix_re.sub(config.prefix, makeargs)
- instance.makeargs = makeargs
+ instance.makeargs = instance.eval_args(makeargs)
return instance
register_module_type('perl', parse_perl)
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index 2119eee..4562d46 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -480,7 +480,6 @@ def _parse_module_set(config, uri):
if moduleset_name:
module.tags.append(moduleset_name)
module.moduleset_name = moduleset_name
- module.config = config
moduleset.add(module)
# keep default repository around, used when creating automatic modules
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]