summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xvar/spack/repos/builtin/packages/openfoam/common/spack-Allwmake11
-rw-r--r--var/spack/repos/builtin/packages/openfoam/package.py60
2 files changed, 40 insertions, 31 deletions
diff --git a/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake b/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake
index a98d7d0db2..91287383d8 100755
--- a/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake
+++ b/var/spack/repos/builtin/packages/openfoam/common/spack-Allwmake
@@ -1,8 +1,8 @@
#!/bin/bash
# Build wrapper script - FOAM_INST_DIR is only required by foam-extend
export FOAM_INST_DIR=$(cd .. && pwd -L)
-. $PWD/etc/bashrc '' # No arguments
-mkdir -p $FOAM_APPBIN $FOAM_LIBBIN 2>/dev/null # Allow interrupt
+. "$PWD/etc/bashrc" '' # No arguments
+mkdir -p "$FOAM_APPBIN" "$FOAM_LIBBIN" 2>/dev/null # Allow build interrupt
echo "Build openfoam with SPACK ($@)"
echo "WM_PROJECT_DIR = $WM_PROJECT_DIR"
@@ -12,6 +12,7 @@ then
./Allwmake-spack $@ # Pass arguments
else
./Allwmake $@ # Pass arguments
+ ##echo "Disabled build of openfoam" # When testing environment only
# Generate manpages
if [ -x bin/tools/foamCreateManpage ]
@@ -23,13 +24,13 @@ fi
# Link non-dummy MPI_FOAM type to parent-dir, where rpath can find it
-if [ "${FOAM_MPI:=dummy}" != dummy -a -d "$FOAM_LIBBIN/$FOAM_MPI" ]
+if [ "${FOAM_MPI:=dummy}" != dummy ] && [ -d "$FOAM_LIBBIN/$FOAM_MPI" ]
then
(
cd "$FOAM_LIBBIN" || exit 1
- for i in $FOAM_MPI/lib*.so
+ for i in "$FOAM_MPI"/lib*.so
do
- [ -f $i ] && ln -sf $i "${i##*/}"
+ [ -f "$i" ] && ln -sf "$i" "${i##*/}"
done
)
fi
diff --git a/var/spack/repos/builtin/packages/openfoam/package.py b/var/spack/repos/builtin/packages/openfoam/package.py
index d0d6dac390..cc2986256e 100644
--- a/var/spack/repos/builtin/packages/openfoam/package.py
+++ b/var/spack/repos/builtin/packages/openfoam/package.py
@@ -376,21 +376,29 @@ class Openfoam(Package):
fmt += 'v{0}/OpenFOAM-v{0}.tgz'
return fmt.format(version, version)
- def setup_environment(self, spack_env, run_env):
- """Add environment variables to the generated module file.
- These environment variables come from running:
+ def setup_minimal_environment(self, env):
+ """Sets a minimal openfoam environment.
+ """
+ tty.info('OpenFOAM minimal env {0}'.format(self.prefix))
+ env.set('FOAM_PROJECT_DIR', self.projectdir)
+ env.set('WM_PROJECT_DIR', self.projectdir)
+ for d in ['wmake', self.archbin]: # bin added automatically
+ env.prepend_path('PATH', join_path(self.projectdir, d))
+
+ def setup_build_environment(self, env):
+ """Sets the build environment (prior to unpacking the sources).
+ """
+ pass
+
+ def setup_run_environment(self, env):
+ """Sets the run environment (post-installation).
+ The environment comes from running:
.. code-block:: console
$ . $WM_PROJECT_DIR/etc/bashrc
"""
- # NOTE: Spack runs setup_environment twice.
- # 1) pre-build to set up the build environment
- # 2) post-install to determine runtime environment variables
- # The etc/bashrc is only available (with corrrect content)
- # post-installation.
-
bashrc = join_path(self.projectdir, 'etc', 'bashrc')
minimal = True
if os.path.isfile(bashrc):
@@ -427,8 +435,7 @@ class Openfoam(Package):
'MPI_ARCH_PATH', # Can be needed for compilation
])
- run_env.extend(mods)
- spack_env.extend(mods)
+ env.extend(mods)
minimal = False
tty.info('OpenFOAM bashrc env: {0}'.format(bashrc))
except Exception:
@@ -436,22 +443,23 @@ class Openfoam(Package):
if minimal:
# pre-build or minimal environment
- tty.info('OpenFOAM minimal env {0}'.format(self.prefix))
- run_env.set('FOAM_PROJECT_DIR', self.projectdir)
- run_env.set('WM_PROJECT_DIR', self.projectdir)
- spack_env.set('FOAM_PROJECT_DIR', self.projectdir)
- spack_env.set('WM_PROJECT_DIR', self.projectdir)
- for d in ['wmake', self.archbin]: # bin added automatically
- run_env.prepend_path('PATH', join_path(self.projectdir, d))
- spack_env.prepend_path('PATH', join_path(self.projectdir, d))
-
- def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
- """Location of the OpenFOAM project directory.
- This is identical to the WM_PROJECT_DIR value, but we avoid that
- variable since it would mask the normal OpenFOAM cleanup of
- previous versions.
+ self.setup_minimal_environment(env)
+
+ def setup_dependent_build_environment(self, env, dependent_spec):
+ """Use full OpenFOAM environment when building.
+ Mirror WM_PROJECT_DIR value as FOAM_PROJECT_DIR to avoid
+ masking the normal OpenFOAM cleanup of previous versions.
+ """
+ self.setup_run_environment(env)
+ env.set('FOAM_PROJECT_DIR', self.projectdir)
+
+ def setup_dependent_run_environment(self, env, dependent_spec):
+ """Use full OpenFOAM environment when running.
+ Mirror WM_PROJECT_DIR value as FOAM_PROJECT_DIR to avoid
+ masking the normal OpenFOAM cleanup of previous versions.
"""
- self.setup_environment(spack_env, run_env)
+ self.setup_run_environment(env)
+ env.set('FOAM_PROJECT_DIR', self.projectdir)
@property
def projectdir(self):