diff --git a/packages/dune/package.py b/packages/dune/package.py index 0b0492b..7b8cd81 100644 --- a/packages/dune/package.py +++ b/packages/dune/package.py @@ -68,6 +68,7 @@ class Dune(CMakePackage): # Define one variant for each Dune module that we have. Only core modules # are activated by default. variant('alugrid', default=False, description='Build with dune-alugrid module') + variant('codegen', default=False, description='Build with dune-codegen module') variant('functions', default=False, description='Build with dune-functions module') variant('geometry', default=True, description='Build with dune-geometry module') variant('grid', default=True, description='Build with dune-grid module') @@ -83,7 +84,7 @@ class Dune(CMakePackage): # If a Dune module behaves differently for different versions (e.g. dune-python got # merged into dune-common post-2.7), define the resource outside of this loop. for vers, branch in dune_versions_to_branch.items(): - version(vers, branch=dune_versions_to_branch[vers]) + version(vers, branch=branch) resource( name='dune-geometry', @@ -167,14 +168,24 @@ class Dune(CMakePackage): resource( name='dune-pdelab', git='https://gitlab.dune-project.org/pdelab/dune-pdelab.git', - branch='master', + branch='bugfix/library-build', when='@master+pdelab', ) + # The dune-codegen package does not yet have a 2.7-compatible release + resource( + name='dune-codegen', + git='https://gitlab.dune-project.org/extensions/dune-codegen.git', + branch='bugfix/installed-library', + when='@master+codegen', + submodules=True, + ) + # Dependencies between modules - not necessarily the full set # as the closure of module dependencies is built later on. module_dependencies = {} module_dependencies["dune-alugrid"] = ["dune-grid", "dune-geometry", "dune-common"] + module_dependencies["dune-codegen"] = ["dune-pdelab", "dune-testtools", "dune-alugrid"] module_dependencies["dune-common"] = [] module_dependencies["dune-functions"] = ["dune-grid", "dune-typetree", "dune-localfunctions", "dune-istl"] module_dependencies["dune-geometry"] = ["dune-common"] @@ -192,6 +203,7 @@ class Dune(CMakePackage): # Specify upstream dependencies (often depending on variants) depends_on('arpack-ng', when='+arpack') + depends_on('benchmark', when='+codegen') depends_on('blas', when='+blas') depends_on('cmake@3.1:', type='build') depends_on('eigen', when='+pdelab') @@ -200,6 +212,7 @@ class Dune(CMakePackage): depends_on('gmp', when='+gmp') depends_on('intel-tbb', when='+tbb') depends_on('lapack', when='+lapack') +# depends_on('likwid', when='+codegen') likwid cannot be built in spack v0.14.2 due to the lua dependency being broken depends_on('metis', when='+metis') depends_on('mpi') depends_on('parmetis', when='+parmetis') @@ -207,9 +220,11 @@ class Dune(CMakePackage): depends_on('python@3.0:', type=('build', 'run')) depends_on('py-setuptools', type='build', when='+python') depends_on('py-numpy', type=('build', 'run'), when='+python') + depends_on('py-pip', type=('build', 'run'), when='+codegen') depends_on('py-pip', type=('build', 'run'), when='+python') depends_on('py-pip', type=('build', 'run'), when='+testtools') depends_on('py-sphinx', type=('build', 'run'), when='+doc') + depends_on('py-wheel', type='build', when='+codegen') depends_on('py-wheel', type='build', when='+python') depends_on('py-wheel', type='build', when='+testtools') depends_on('scotch+mpi', when='+ptscotch') @@ -222,6 +237,10 @@ class Dune(CMakePackage): # Apply patches patch('virtualenv_from_envvariable.patch', when='+testtools') + patch('virtualenv_from_envvariable.patch', when='+codegen') + + # Some conflicts + conflicts('dune~superlu', when='+codegen') def setup_build_environment(self, env): # We reset the DUNE_CONTROL_PATH here because any entries in this @@ -241,7 +260,7 @@ class Dune(CMakePackage): # For those modules that typically work with the Dune Virtualenv, # we export the location of the virtualenv as an environment variable. - if '+testtools' in self.spec: + if '+testtools' in self.spec or '+codegen' in self.spec: env.set('DUNE_PYTHON_VIRTUALENV_PATH', join_path(Path.home(), '.cache', 'dune-python-env', self.spec.dag_hash())) def cmake_args(self): @@ -280,7 +299,7 @@ class Dune(CMakePackage): if '+testtools' in spec or '+codegen' in spec: cmake_args.append('-DDUNE_PYTHON_VIRTUALENV_SETUP:BOOL=ON') cmake_args.append('-DDUNE_PYTHON_ALLOW_GET_PIP:BOOL=ON') - cmake_args.append('-DDUNE_PYTHON_VIRTUALENV_PATH:STRING="%s"' % join_path(self.prefix, 'dune-python-env')) + cmake_args.append('-DDUNE_PYTHON_VIRTUALENV_PATH:STRING="%s"' % join_path(Path.home(), '.cache', 'dune-python-env', self.spec.dag_hash())) cmake_args.append('-DDUNE_PYTHON_INSTALL_LOCATION:STRING="system"') if '+python' in spec: @@ -320,6 +339,12 @@ class Dune(CMakePackage): return CMakePackage._get_needed_resources(self) def cmake(self, spec, prefix): + # dune-codegen delivers its own set of patches for its submodules + # that we can apply with a script delivered by dune-codegen. + if '+codegen' in self.spec: + with working_dir(join_path(self.root_cmakelists_dir, 'dune-codegen')): + Executable('patches/apply_patches.sh')() + # Write an opts file for later use with open(join_path(self.stage.source_path, "..", "dune.opts"), "w") as optFile: optFile.write('CMAKE_FLAGS="')