2016-12-27 16:17:12 +08:00
|
|
|
##############################################################################
|
|
|
|
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
|
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
|
|
|
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
|
|
|
# For details, see https://github.com/llnl/spack
|
2017-06-25 13:22:55 +08:00
|
|
|
# Please also see the NOTICE and LICENSE files for our notice and the LGPL.
|
2016-12-27 16:17:12 +08:00
|
|
|
#
|
2017-03-31 07:35:57 +08:00
|
|
|
# License
|
|
|
|
# -------
|
2016-12-27 16:17:12 +08:00
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License (as
|
|
|
|
# published by the Free Software Foundation) version 2.1, February 1999.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
# conditions of the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2017-03-31 07:35:57 +08:00
|
|
|
#
|
|
|
|
# Legal Notice
|
|
|
|
# ------------
|
|
|
|
# OPENFOAM is a trademark owned by OpenCFD Ltd
|
|
|
|
# (producer and distributor of the OpenFOAM software via www.openfoam.com).
|
|
|
|
# The trademark information must remain visible and unadulterated in this
|
|
|
|
# file and via the "spack info" and comply with the term set by
|
|
|
|
# http://openfoam.com/legal/trademark-policy.php
|
|
|
|
#
|
|
|
|
# This file is not part of OpenFOAM, nor does it constitute a component of an
|
|
|
|
# OpenFOAM distribution.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Notes
|
|
|
|
# - mpi handling: WM_MPLIB=USER and provide wmake rules for special purpose
|
|
|
|
# 'USER and 'USERMPI' mpi implementations.
|
|
|
|
# The choice of 'USER' vs 'USERMPI' may change in the future.
|
|
|
|
#
|
|
|
|
# Changes
|
|
|
|
# 2017-03-28 Mark Olesen <mark.olesen@esi-group.com>
|
|
|
|
# - avoid installing intermediate targets.
|
|
|
|
# - reworked to mirror the openfoam-com package.
|
|
|
|
# If changes are needed here, consider if they need applying there too.
|
|
|
|
#
|
2017-06-22 00:35:31 +08:00
|
|
|
# Known issues
|
|
|
|
# - Combining +parmgridgen with +float32 probably won't work.
|
|
|
|
#
|
2016-12-27 16:17:12 +08:00
|
|
|
##############################################################################
|
2016-05-23 00:55:29 +08:00
|
|
|
from spack import *
|
|
|
|
from spack.environment import *
|
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
import glob
|
|
|
|
import re
|
|
|
|
import shutil
|
2016-05-23 00:55:29 +08:00
|
|
|
import os
|
2017-03-31 07:35:57 +08:00
|
|
|
from spack.pkg.builtin.openfoam_com import *
|
2016-05-23 00:55:29 +08:00
|
|
|
|
|
|
|
|
2016-05-30 21:46:39 +08:00
|
|
|
class FoamExtend(Package):
|
2017-03-31 07:35:57 +08:00
|
|
|
"""The Extend Project is a fork of the OpenFOAM opensource library
|
|
|
|
for Computational Fluid Dynamics (CFD).
|
|
|
|
This offering is not approved or endorsed by OpenCFD Ltd,
|
|
|
|
producer and distributor of the OpenFOAM software via www.openfoam.com,
|
|
|
|
and owner of the OPENFOAM trademark.
|
|
|
|
"""
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2016-06-01 06:57:01 +08:00
|
|
|
homepage = "http://www.extend-project.de/"
|
|
|
|
|
2017-03-16 02:02:36 +08:00
|
|
|
version('4.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-4.0')
|
2016-05-23 00:55:29 +08:00
|
|
|
version('3.2', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.2')
|
|
|
|
version('3.1', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.1')
|
|
|
|
version('3.0', git='http://git.code.sf.net/p/foam-extend/foam-extend-3.0')
|
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
# variant('int64', default=False,
|
2017-06-22 00:35:31 +08:00
|
|
|
# description='Compile with 64-bit label')
|
2017-03-31 07:35:57 +08:00
|
|
|
variant('float32', default=False,
|
|
|
|
description='Compile with 32-bit scalar (single-precision)')
|
|
|
|
variant('paraview', default=False,
|
|
|
|
description='Build paraview plugins (eg, paraFoam)')
|
|
|
|
variant('scotch', default=True,
|
|
|
|
description='With scotch for decomposition')
|
|
|
|
variant('ptscotch', default=True,
|
|
|
|
description='With ptscotch for decomposition')
|
|
|
|
variant('metis', default=True,
|
|
|
|
description='With metis for decomposition')
|
|
|
|
variant('parmetis', default=True,
|
|
|
|
description='With parmetis for decomposition')
|
|
|
|
variant('parmgridgen', default=True,
|
|
|
|
description='With parmgridgen support')
|
|
|
|
variant('source', default=True,
|
|
|
|
description='Install library/application sources and tutorials')
|
|
|
|
|
|
|
|
provides('openfoam')
|
2016-05-23 00:55:29 +08:00
|
|
|
depends_on('mpi')
|
|
|
|
depends_on('python')
|
|
|
|
depends_on('zlib')
|
2017-06-26 22:58:02 +08:00
|
|
|
depends_on('flex', type='build')
|
2016-06-30 03:06:21 +08:00
|
|
|
depends_on('cmake', type='build')
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
depends_on('scotch~metis', when='~ptscotch+scotch')
|
|
|
|
depends_on('scotch~metis+mpi', when='+ptscotch')
|
|
|
|
depends_on('metis@5:', when='+metis')
|
|
|
|
depends_on('parmetis', when='+parmetis')
|
2017-06-22 00:35:31 +08:00
|
|
|
# mgridgen is statically linked
|
|
|
|
depends_on('parmgridgen', when='+parmgridgen', type='build')
|
2017-03-31 07:35:57 +08:00
|
|
|
depends_on('paraview@:5.0.1', when='+paraview')
|
|
|
|
|
2017-06-22 00:35:31 +08:00
|
|
|
# General patches
|
|
|
|
common = ['spack-Allwmake', 'README-spack']
|
|
|
|
assets = []
|
2017-03-31 07:35:57 +08:00
|
|
|
|
2017-06-22 00:35:31 +08:00
|
|
|
# Some user config settings
|
|
|
|
config = {
|
|
|
|
'label-size': False, # <- No int32/int64 support
|
|
|
|
'mplib': 'USERMPI', # USER | USERMPI
|
2017-03-31 07:35:57 +08:00
|
|
|
}
|
|
|
|
|
2017-06-22 00:35:31 +08:00
|
|
|
# The openfoam architecture, compiler information etc
|
|
|
|
_foam_arch = None
|
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
# Content for etc/prefs.{csh,sh}
|
|
|
|
etc_prefs = {}
|
|
|
|
|
|
|
|
# Content for etc/config.{csh,sh}/ files
|
|
|
|
etc_config = {}
|
|
|
|
|
2017-06-22 00:35:31 +08:00
|
|
|
phases = ['configure', 'build', 'install']
|
|
|
|
build_script = './spack-Allwmake' # <- Added by patch() method.
|
|
|
|
|
|
|
|
#
|
|
|
|
# - End of definitions / setup -
|
|
|
|
#
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
def setup_environment(self, spack_env, run_env):
|
2017-06-22 00:35:31 +08:00
|
|
|
run_env.set('FOAM_INST_DIR', os.path.dirname(self.projectdir)),
|
|
|
|
run_env.set('FOAM_PROJECT_DIR', self.projectdir)
|
2017-03-31 07:35:57 +08:00
|
|
|
run_env.set('WM_PROJECT_DIR', self.projectdir)
|
2017-06-22 00:35:31 +08:00
|
|
|
for d in ['wmake', self.archbin]: # bin already added automatically
|
|
|
|
run_env.prepend_path('PATH', join_path(self.projectdir, d))
|
|
|
|
|
|
|
|
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
|
|
|
|
"""Provide location of the OpenFOAM project.
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
spack_env.set('FOAM_PROJECT_DIR', self.projectdir)
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def projectdir(self):
|
|
|
|
"""Absolute location of project directory: WM_PROJECT_DIR/"""
|
2017-06-22 00:35:31 +08:00
|
|
|
return self.prefix # <- install directly under prefix
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
@property
|
2017-06-22 00:35:31 +08:00
|
|
|
def foam_arch(self):
|
|
|
|
if not self._foam_arch:
|
|
|
|
self._foam_arch = OpenfoamArch(self.spec, **self.config)
|
|
|
|
return self._foam_arch
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def archbin(self):
|
|
|
|
"""Relative location of architecture-specific executables"""
|
2017-06-22 00:35:31 +08:00
|
|
|
return join_path('applications', 'bin', self.foam_arch)
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
@property
|
|
|
|
def archlib(self):
|
|
|
|
"""Relative location of architecture-specific libraries"""
|
2017-06-22 00:35:31 +08:00
|
|
|
return join_path('lib', self.foam_arch)
|
2016-05-23 00:55:29 +08:00
|
|
|
|
|
|
|
def patch(self):
|
2017-06-22 00:35:31 +08:00
|
|
|
"""Adjust OpenFOAM build for spack.
|
|
|
|
Where needed, apply filter as an alternative to normal patching."""
|
|
|
|
add_extra_files(self, self.common, self.assets)
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
# Adjust ParMGridGen - this is still a mess
|
|
|
|
files = [
|
|
|
|
'src/dbns/Make/options',
|
|
|
|
'src/fvAgglomerationMethods/MGridGenGamgAgglomeration/Make/options' # noqa: E501
|
2016-05-23 00:55:29 +08:00
|
|
|
]
|
2017-03-31 07:35:57 +08:00
|
|
|
for f in files:
|
|
|
|
filter_file(r'-lMGridGen', r'-lmgrid', f, backup=False)
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
# Adjust for flex version check
|
|
|
|
files = [
|
2016-12-03 05:51:03 +08:00
|
|
|
'src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L', # noqa: E501
|
|
|
|
'src/surfMesh/surfaceFormats/stl/STLsurfaceFormatASCII.L', # noqa: E501
|
|
|
|
'src/meshTools/triSurface/triSurface/interfaces/STL/readSTLASCII.L', # noqa: E501
|
|
|
|
'applications/utilities/preProcessing/fluentDataToFoam/fluentDataToFoam.L', # noqa: E501
|
|
|
|
'applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L', # noqa: E501
|
|
|
|
'applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L', # noqa: E501
|
|
|
|
'applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L', # noqa: E501
|
|
|
|
'applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L', # noqa: E501
|
|
|
|
'applications/utilities/mesh/conversion/fluent3DMeshToElmer/fluent3DMeshToElmer.L' # noqa: E501
|
|
|
|
]
|
2017-03-31 07:35:57 +08:00
|
|
|
for f in files:
|
|
|
|
filter_file(
|
|
|
|
r'#if YY_FLEX_SUBMINOR_VERSION < 34',
|
|
|
|
r'#if YY_FLEX_MAJOR_VERSION <= 2 && YY_FLEX_MINOR_VERSION <= 5 && YY_FLEX_SUBMINOR_VERSION < 34', # noqa: E501
|
2017-06-22 00:35:31 +08:00
|
|
|
f, backup=False)
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
def configure(self, spec, prefix):
|
|
|
|
"""Make adjustments to the OpenFOAM configuration files in their various
|
|
|
|
locations: etc/bashrc, etc/config.sh/FEATURE and customizations that
|
|
|
|
don't properly fit get placed in the etc/prefs.sh file (similiarly for
|
|
|
|
csh).
|
|
|
|
"""
|
|
|
|
# Content for etc/prefs.{csh,sh}
|
|
|
|
self.etc_prefs = {
|
|
|
|
'000': { # Sort first
|
|
|
|
'compilerInstall': 'System',
|
|
|
|
},
|
|
|
|
'001': {},
|
|
|
|
'cmake': {
|
|
|
|
'CMAKE_DIR': spec['cmake'].prefix,
|
|
|
|
'CMAKE_BIN_DIR': spec['cmake'].prefix.bin,
|
|
|
|
},
|
|
|
|
'python': {
|
Python command, libraries, and headers (#3367)
## Motivation
Python installations are both important and unfortunately inconsistent. Depending on the Python version, OS, and the strength of the Earth's magnetic field when it was installed, the name of the Python executable, directory containing its libraries, library names, and the directory containing its headers can vary drastically.
I originally got into this mess with #3274, where I discovered that Boost could not be built with Python 3 because the executable is called `python3` and we were telling it to use `python`. I got deeper into this mess when I started hacking on #3140, where I discovered just how difficult it is to find the location and name of the Python libraries and headers.
Currently, half of the packages that depend on Python and need to know this information jump through hoops to determine the correct information. The other half are hard-coded to use `python`, `spec['python'].prefix.lib`, and `spec['python'].prefix.include`. Obviously, none of these packages would work for Python 3, and there's no reason to duplicate the effort. The Python package itself should contain all of the information necessary to use it properly. This is in line with the recent work by @alalazo and @davydden with respect to `spec['blas'].libs` and friends.
## Prefix
For most packages in Spack, we assume that the installation directory is `spec['python'].prefix`. This generally works for anything installed with Spack, but gets complicated when we include external packages. Python is a commonly used external package (it needs to be installed just to run Spack). If it was installed with Homebrew, `which python` would return `/usr/local/bin/python`, and most users would erroneously assume that `/usr/local` is the installation directory. If you peruse through #2173, you'll immediately see why this is not the case. Homebrew actually installs Python in `/usr/local/Cellar/python/2.7.12_2` and symlinks the executable to `/usr/local/bin/python`. `PYTHONHOME` (and presumably most things that need to know where Python is installed) needs to be set to the actual installation directory, not `/usr/local`.
Normally I would say, "sounds like user error, make sure to use the real installation directory in your `packages.yaml`". But I think we can make a special case for Python. That's what we decided in #2173 anyway. If we change our minds, I would be more than happy to simplify things.
To solve this problem, I created a `spec['python'].home` attribute that works the same way as `spec['python'].prefix` but queries Python to figure out where it was actually installed. @tgamblin Is there any way to overwrite `spec['python'].prefix`? I think it's currently immutable.
## Command
In general, Python 2 comes with both `python` and `python2` commands, while Python 3 only comes with a `python3` command. But this is up to the OS developers. For example, `/usr/bin/python` on Gentoo is actually Python 3. Worse yet, if someone is using an externally installed Python, all 3 commands may exist in the same directory! Here's what I'm thinking:
If the spec is for Python 3, try searching for the `python3` command.
If the spec is for Python 2, try searching for the `python2` command.
If neither are found, try searching for the `python` command.
## Libraries
Spack installs Python libraries in `spec['python'].prefix.lib`. Except on openSUSE 13, where it installs to `spec['python'].prefix.lib64` (see #2295 and #2253). On my CentOS 6 machine, the Python libraries are installed in `/usr/lib64`. Both need to work.
The libraries themselves change name depending on OS and Python version. For Python 2.7 on macOS, I'm seeing:
```
lib/libpython2.7.dylib
```
For Python 3.6 on CentOS 6, I'm seeing:
```
lib/libpython3.so
lib/libpython3.6m.so.1.0
lib/libpython3.6m.so -> lib/libpython3.6m.so.1.0
```
Notice the `m` after the version number. Yeah, that's a thing.
## Headers
In Python 2.7, I'm seeing:
```
include/python2.7/pyconfig.h
```
In Python 3.6, I'm seeing:
```
include/python3.6m/pyconfig.h
```
It looks like all Python 3 installations have this `m`. Tested with Python 3.2 and 3.6 on macOS and CentOS 6
Spack has really nice support for libraries (`find_libraries` and `LibraryList`), but nothing for headers. Fixed.
2017-04-30 08:24:13 +08:00
|
|
|
'PYTHON_DIR': spec['python'].home,
|
|
|
|
'PYTHON_BIN_DIR': spec['python'].home.bin,
|
2017-03-31 07:35:57 +08:00
|
|
|
},
|
|
|
|
'flex': {
|
|
|
|
'FLEX_SYSTEM': 1,
|
|
|
|
'FLEX_DIR': spec['flex'].prefix,
|
|
|
|
},
|
|
|
|
'bison': {
|
|
|
|
'BISON_SYSTEM': 1,
|
|
|
|
'BISON_DIR': spec['flex'].prefix,
|
|
|
|
},
|
|
|
|
'zlib': {
|
|
|
|
'ZLIB_SYSTEM': 1,
|
|
|
|
'ZLIB_DIR': spec['zlib'].prefix,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
# Adjust configuration via prefs - sort second
|
2017-06-22 00:35:31 +08:00
|
|
|
self.etc_prefs['001'].update(self.foam_arch.foam_dict())
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
if '+scotch' in spec or '+ptscotch' in spec:
|
|
|
|
pkg = spec['scotch'].prefix
|
|
|
|
self.etc_prefs['scotch'] = {
|
|
|
|
'SCOTCH_SYSTEM': 1,
|
|
|
|
'SCOTCH_DIR': pkg,
|
|
|
|
'SCOTCH_BIN_DIR': pkg.bin,
|
|
|
|
'SCOTCH_LIB_DIR': pkg.lib,
|
|
|
|
'SCOTCH_INCLUDE_DIR': pkg.include,
|
|
|
|
}
|
|
|
|
|
|
|
|
if '+metis' in spec:
|
|
|
|
pkg = spec['metis'].prefix
|
|
|
|
self.etc_prefs['metis'] = {
|
|
|
|
'METIS_SYSTEM': 1,
|
|
|
|
'METIS_DIR': pkg,
|
|
|
|
'METIS_BIN_DIR': pkg.bin,
|
|
|
|
'METIS_LIB_DIR': pkg.lib,
|
|
|
|
'METIS_INCLUDE_DIR': pkg.include,
|
|
|
|
}
|
|
|
|
|
|
|
|
if '+parmetis' in spec:
|
|
|
|
pkg = spec['parmetis'].prefix
|
|
|
|
self.etc_prefs['parametis'] = {
|
|
|
|
'PARMETIS_SYSTEM': 1,
|
|
|
|
'PARMETIS_DIR': pkg,
|
|
|
|
'PARMETIS_BIN_DIR': pkg.bin,
|
|
|
|
'PARMETIS_LIB_DIR': pkg.lib,
|
|
|
|
'PARMETIS_INCLUDE_DIR': pkg.include,
|
|
|
|
}
|
|
|
|
|
|
|
|
if '+parmgridgen' in spec:
|
|
|
|
pkg = spec['parmgridgen'].prefix
|
|
|
|
self.etc_prefs['parmgridgen'] = {
|
|
|
|
'PARMGRIDGEN_SYSTEM': 1,
|
|
|
|
'PARMGRIDGEN_DIR': pkg,
|
|
|
|
'PARMGRIDGEN_BIN_DIR': pkg.bin,
|
|
|
|
'PARMGRIDGEN_LIB_DIR': pkg.lib,
|
|
|
|
'PARMGRIDGEN_INCLUDE_DIR': pkg.include,
|
|
|
|
}
|
2016-12-03 05:51:03 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
if '+paraview' in self.spec:
|
|
|
|
self.etc_prefs['paraview'] = {
|
|
|
|
'PARAVIEW_SYSTEM': 1,
|
|
|
|
'PARAVIEW_DIR': spec['paraview'].prefix,
|
|
|
|
'PARAVIEW_BIN_DIR': spec['paraview'].prefix.bin,
|
|
|
|
}
|
|
|
|
self.etc_prefs['qt'] = {
|
|
|
|
'QT_SYSTEM': 1,
|
|
|
|
'QT_DIR': spec['qt'].prefix,
|
|
|
|
'QT_BIN_DIR': spec['qt'].prefix.bin,
|
|
|
|
}
|
|
|
|
|
|
|
|
# Write prefs files according to the configuration.
|
|
|
|
# Only need prefs.sh for building, but install both for end-users
|
|
|
|
write_environ(
|
|
|
|
self.etc_prefs,
|
|
|
|
posix=join_path('etc', 'prefs.sh'),
|
|
|
|
cshell=join_path('etc', 'prefs.csh'))
|
|
|
|
|
|
|
|
def build(self, spec, prefix):
|
|
|
|
"""Build using the OpenFOAM Allwmake script, with a wrapper to source
|
|
|
|
its environment first.
|
2017-06-22 00:35:31 +08:00
|
|
|
Only build if the compiler is known to be supported.
|
2017-03-31 07:35:57 +08:00
|
|
|
"""
|
2017-06-22 00:35:31 +08:00
|
|
|
self.foam_arch.has_rule(self.stage.source_path)
|
|
|
|
self.foam_arch.create_rules(self.stage.source_path, self)
|
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
args = []
|
|
|
|
if self.parallel: # Build in parallel? - pass via the environment
|
2017-06-22 00:35:31 +08:00
|
|
|
os.environ['WM_NCOMPPROCS'] = str(make_jobs)
|
2017-03-31 07:35:57 +08:00
|
|
|
builder = Executable(self.build_script)
|
|
|
|
builder(*args)
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
def install(self, spec, prefix):
|
2017-06-22 00:35:31 +08:00
|
|
|
"""Install under the projectdir"""
|
|
|
|
opts = str(self.foam_arch)
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
# Fairly ugly since intermediate targets are scattered inside sources
|
|
|
|
appdir = 'applications'
|
2017-06-22 00:35:31 +08:00
|
|
|
projdir = os.path.basename(self.projectdir)
|
2017-03-31 07:35:57 +08:00
|
|
|
mkdirp(self.projectdir, join_path(self.projectdir, appdir))
|
2017-06-22 00:35:31 +08:00
|
|
|
# Filtering: bashrc, cshrc
|
|
|
|
edits = {
|
|
|
|
'WM_PROJECT_INST_DIR': os.path.dirname(self.projectdir),
|
|
|
|
'WM_PROJECT_DIR': join_path('$WM_PROJECT_INST_DIR', projdir),
|
|
|
|
}
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
# All top-level files, except spack build info and possibly Allwmake
|
|
|
|
if '+source' in spec:
|
|
|
|
ignored = re.compile(r'^spack-.*')
|
|
|
|
else:
|
|
|
|
ignored = re.compile(r'^(Allclean|Allwmake|spack-).*')
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
files = [
|
2017-06-22 00:35:31 +08:00
|
|
|
f for f in glob.glob("*")
|
|
|
|
if os.path.isfile(f) and not ignored.search(f)
|
2017-03-31 07:35:57 +08:00
|
|
|
]
|
|
|
|
for f in files:
|
|
|
|
install(f, self.projectdir)
|
2016-05-23 00:55:29 +08:00
|
|
|
|
2017-03-31 07:35:57 +08:00
|
|
|
# Install directories. install applications/bin directly
|
2017-06-22 00:35:31 +08:00
|
|
|
# Install 'etc' before 'bin' (for symlinks)
|
|
|
|
for d in ['etc', 'bin', 'wmake', 'lib', join_path(appdir, 'bin')]:
|
2017-03-31 07:35:57 +08:00
|
|
|
install_tree(
|
|
|
|
d,
|
2017-06-22 00:35:31 +08:00
|
|
|
join_path(self.projectdir, d),
|
|
|
|
symlinks=True)
|
2016-05-23 00:55:29 +08:00
|
|
|
|
|
|
|
if '+source' in spec:
|
2017-03-31 07:35:57 +08:00
|
|
|
subitem = join_path(appdir, 'Allwmake')
|
|
|
|
install(subitem, join_path(self.projectdir, subitem))
|
|
|
|
|
2017-06-22 00:35:31 +08:00
|
|
|
ignored = [opts] # Ignore intermediate targets
|
2017-03-31 07:35:57 +08:00
|
|
|
for d in ['src', 'tutorials']:
|
|
|
|
install_tree(
|
|
|
|
d,
|
|
|
|
join_path(self.projectdir, d),
|
2017-06-22 00:35:31 +08:00
|
|
|
ignore=shutil.ignore_patterns(*ignored),
|
|
|
|
symlinks=True)
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
for d in ['solvers', 'utilities']:
|
|
|
|
install_tree(
|
|
|
|
join_path(appdir, d),
|
|
|
|
join_path(self.projectdir, appdir, d),
|
2017-06-22 00:35:31 +08:00
|
|
|
ignore=shutil.ignore_patterns(*ignored),
|
|
|
|
symlinks=True)
|
|
|
|
|
|
|
|
etc_dir = join_path(self.projectdir, 'etc')
|
|
|
|
rewrite_environ_files( # Adjust etc/bashrc and etc/cshrc
|
|
|
|
edits,
|
|
|
|
posix=join_path(etc_dir, 'bashrc'),
|
|
|
|
cshell=join_path(etc_dir, 'cshrc'))
|
|
|
|
self.install_links()
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
def install_links(self):
|
|
|
|
"""Add symlinks into bin/, lib/ (eg, for other applications)"""
|
2017-06-22 00:35:31 +08:00
|
|
|
# Make build log visible - it contains OpenFOAM-specific information
|
|
|
|
with working_dir(self.projectdir):
|
|
|
|
os.symlink(
|
|
|
|
join_path('.spack', 'build.out'),
|
|
|
|
join_path('log.' + str(self.foam_arch)))
|
2017-03-31 07:35:57 +08:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|