v0.15.5
Loading...
Searching...
No Matches
package.py
Go to the documentation of this file.
1# Copyright (c) 2022 [Authors](http://mofem.eng.gla.ac.uk/mofem/html/authors.html)
2#
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included in all
11# copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20#
21# [MIT License](https://opensource.org/licenses/MIT)#
22
23
24from spack import *
25
26
28 """mofem fracture module"""
29
30 homepage = "http://mofem.eng.gla.ac.uk"
31 git = "https://bitbucket.org/mofem/um_eshelbian_plasticity.git"
32
33 maintainers = ['likask','CallumRuncie']
34
35 # Development versions
36 version('main', branch='main')
37 version('develop', branch='develop')
38 version('lukasz', branch='lukasz/develop')
39 # Versions
40 version('0.15.6', branch='Version0.15.6')
41 version('0.15.5', branch='Version0.15.5')
42 version('0.15.4', branch='Version0.15.4')
43 version('0.15.3', branch='Version0.15.3')
44 version('0.15.2', branch='Version0.15.2')
45 version('0.15.1', branch='Version0.15.1')
46 version('0.15.0', branch='Version0.15.0')
47
48 variant('copy_user_modules', default=True,
49 description='Copy user modules directory instead linking')
50
51 extends('mofem-cephas')
52
53 depends_on('mofem-cephas@main', when='@main')
54 depends_on('mofem-cephas@develop', when='@develop')
55 depends_on('mofem-cephas@lukasz', when='@lukasz')
56
57 depends_on('mofem-cephas@0.15.5:', when='@0.15.6')
58 depends_on('mofem-cephas@0.15.4:', when='@0.15.5')
59 depends_on('mofem-cephas@0.15.3:', when='@0.15.4')
60 depends_on('mofem-cephas@0.15.2:', when='@0.15.3')
61 depends_on('mofem-cephas@0.15.1:', when='@0.15.2')
62 depends_on('mofem-cephas@0.15.0:', when='@0.15.1')
63
65 env.set('CTEST_OUTPUT_ON_FAILURE', '1')
66
67 # The CMakeLists.txt installed with mofem-cephas package set cmake
68 # environment to install extension from extension repository. It searches
69 # for modules in user provides paths, for example in Spack source path.Also
70 # it finds all cmake exported targets installed in lib directory, which are
71 # built with dependent extensions, f.e. mofem - users - modules or others if
72 # needed.
73 @property
75 """The relative path to the directory containing CMakeLists.txt
76
77 This path is relative to the root of the extracted tarball,
78 not to the ``build_directory``. Defaults to the current directory.
79
80 :return: directory containing CMakeLists.txt
81 """
82 spec = self.spec
83 return spec['mofem-cephas'].prefix.include.cmake.users_modules
84
85 @property
86 def build_directory(self):
87 spec = self.spec
88 build_type = spec.variants['build_type'].value
89 build_dir = 'users_modules/eshelbian_plasticity'
90 return join_path(self.stage.path, build_dir)
91
92 def cmake_args(self):
93 spec = self.spec
94 from_variant = self.define_from_variant
95
96 options = []
97
98 # obligatory options
99 options.extend([
100 '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
101 '-DMPI_RUN_FLAGS=--allow-run-as-root',
102 '-DWITH_SPACK=YES'])
103 options.append(self.define(
104 'MOFEM_DIR', spec['mofem-cephas'].prefix))
105 options.append(self.define(
106 'EXTERNAL_MODULE_SOURCE_DIRS', self.stage.source_path))
107
108 # build tests
109 options.append(self.define('MOFEM_UM_BUILD_TESTS', self.run_tests))
110
111 return options
112
113 # This function is not needed to run code installed by extension, nor in
114 # the install process. However, for users like to have access to source
115 # code to play, change and make it. Having source code at hand one can
116 # compile in own build directory it in package view when the extension is
117 # activated.
118 @run_after('install')
120 source = self.stage.source_path
121 prefix = self.prefix
122 install_tree(source, prefix.ext_users_modules.mixed_fracture_module)
123
124 def check(self):
125 """Searches the CMake-generated Makefile for the target ``test``
126 and runs it if found.
127 """
128 with working_dir(self.build_directorybuild_directory):
129 ctest('-L', 'short', '--output-on-failure', parallel=False)