summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-12-25 16:05:45 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2014-12-25 16:05:45 -0800
commitb3042db75523b465c088f9aff8efb73049a9c81c (patch)
treedb11d97a8ee71c5f094a6fbf7a4ba58e40a216b7 /lib
parent852c1dc2866fc59b6250288aad6c8d7c988588a8 (diff)
downloadspack-b3042db75523b465c088f9aff8efb73049a9c81c.tar.gz
spack-b3042db75523b465c088f9aff8efb73049a9c81c.tar.bz2
spack-b3042db75523b465c088f9aff8efb73049a9c81c.tar.xz
spack-b3042db75523b465c088f9aff8efb73049a9c81c.zip
Add patch function to Package, so that packages can define custom patch functions.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_environment.py7
-rw-r--r--lib/spack/spack/package.py16
2 files changed, 18 insertions, 5 deletions
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index a2fcff1f10..87cfa772ca 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -199,3 +199,10 @@ def set_module_variables_for_package(pkg):
# Useful directories within the prefix are encapsulated in
# a Prefix object.
m.prefix = pkg.prefix
+
+
+def setup_package(pkg):
+ """Execute all environment setup routines."""
+ set_compiler_environment_variables(pkg)
+ set_build_environment_variables(pkg)
+ set_module_variables_for_package(pkg)
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 4ab7ff23cf..1a797e88b1 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -662,8 +662,11 @@ class Package(object):
# Kick off the stage first.
self.do_stage()
+ # Package can add its own patch function.
+ has_patch_fun = hasattr(self, 'patch') and callable(self.patch)
+
# If there are no patches, note it.
- if not self.patches:
+ if not self.patches and not has_patch_fun:
tty.msg("No patches needed for %s." % self.name)
return
@@ -686,7 +689,7 @@ class Package(object):
tty.msg("Already patched %s" % self.name)
return
- # Apply all the patches for specs that match this on
+ # Apply all the patches for specs that match this one
for spec, patch_list in self.patches.items():
if self.spec.satisfies(spec):
for patch in patch_list:
@@ -704,6 +707,11 @@ class Package(object):
os.remove(bad_file)
touch(good_file)
+ if has_patch_fun:
+ self.patch()
+
+ tty.msg("Patched %s" % self.name)
+
def do_install(self, **kwargs):
"""This class should call this version of the install method.
@@ -750,9 +758,7 @@ class Package(object):
spack.install_layout.make_path_for_spec(self.spec)
# Set up process's build environment before running install.
- build_env.set_compiler_environment_variables(self)
- build_env.set_build_environment_variables(self)
- build_env.set_module_variables_for_package(self)
+ build_env.setup_package(self)
if fake_install:
mkdirp(self.prefix.bin)