4
4
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
5
5
6
6
from spack import *
7
+ import glob
7
8
8
9
9
10
class Genn (PythonPackage ):
@@ -16,22 +17,32 @@ class Genn(PythonPackage):
16
17
version ('4.6.0' , sha256 = '5e5ca94fd3a56b5b963a4911ea1b2130df6fa7dcdde3b025bd8cb85d4c2d3236' )
17
18
18
19
conflicts ('%gcc@:4.9.3' )
19
- depends_on ('gmake' , type = 'build' )
20
+ depends_on ('gmake' , type = 'build' )
21
+ depends_on ('googletest' , type = ('build' , 'run' , 'test' ))
22
+ depends_on ('lcov' , type = ('build' , 'run' , 'test' ))
20
23
21
24
variant ('cuda' , default = True , description = 'Enable CUDA support' )
22
25
depends_on ('cuda' , when = '+cuda' )
23
26
24
27
variant ('python' , default = True , description = 'Enable PyGeNN' )
25
28
extends ('python' , when = '+python' )
26
- depends_on (
'[email protected] :' ,
when = '+python' )
27
- depends_on (
'[email protected] :' ,
when = '+python' )
28
- depends_on ('py-six' , when = '+python' )
29
- depends_on ('py-deprecated' , when = '+python' )
30
- depends_on ('py-psutil' , when = '+python' )
31
- depends_on (
'[email protected] :' ,
when = '+python' )
32
- depends_on ('swig' , when = '+python' )
29
+ depends_on (
'[email protected] :' ,
when = '+python' , type = ( 'build' , 'run' , 'test' ) )
30
+ depends_on (
'[email protected] :' ,
when = '+python' , type = ( 'build' , 'run' , 'test' ) )
31
+ depends_on ('py-six' , when = '+python' , type = ( 'build' , 'run' , 'test' ) )
32
+ depends_on ('py-deprecated' , when = '+python' , type = ( 'build' , 'run' , 'test' ) )
33
+ depends_on ('py-psutil' , when = '+python' , type = ( 'build' , 'run' , 'test' ) )
34
+ depends_on (
'[email protected] :' ,
when = '+python' , type = ( 'build' , 'run' , 'test' ) )
35
+ depends_on ('swig' , when = '+python' , type = ( 'build' , 'run' , 'test' ) )
33
36
34
37
patch ('include_path.patch' )
38
+ patch ('tests_gtest.patch' )
39
+
40
+ def patch (self ):
41
+ files = set (glob .glob ("tests/**/Makefile" , recursive = True ))
42
+ filter_file ('\$\(GTEST_DIR\)/src/gtest-all\.cc' ,
43
+ '-L$(GTEST_DIR)/lib -lgtest' , * files )
44
+ filter_file ('\$\(GTEST_DIR\)/src/gtest_main\.cc' ,
45
+ '-L$(GTEST_DIR)/lib -lgtest_main' , * files )
35
46
36
47
def build (self , spec , prefix ):
37
48
make ('PREFIX={}' .format (prefix ), 'install' )
@@ -42,8 +53,10 @@ def build(self, spec, prefix):
42
53
def install (self , spec , prefix ):
43
54
install_tree ('bin' , prefix .bin )
44
55
install_tree ('include' , prefix .include )
45
- mkdirp (prefix .src .genn )
46
- install_tree ('src/genn' , prefix .src .genn )
56
+ mkdirp (prefix .src )
57
+ install_tree ('src' , prefix .src )
58
+ install_tree ('tests' , prefix .tests )
59
+ install ('version.txt' , prefix )
47
60
if '+python' in self .spec :
48
61
super (Genn , self ).install (spec , prefix )
49
62
@@ -53,3 +66,20 @@ def setup_run_environment(self, env):
53
66
env .append_path ('CUDA_PATH' , self .spec ['cuda' ].prefix )
54
67
if '+python' in self .spec :
55
68
super (Genn , self ).setup_run_environment (env )
69
+
70
+ def test (self ):
71
+ env ['CC' ] = self .compiler .cc
72
+ env ['CXX' ] = self .compiler .cxx
73
+ # workaround for https://github.com/spack/spack/issues/20553
74
+ env ['GTEST_DIR' ] = self .spec ['googletest' ].prefix
75
+ env ['LD_LIBRARY_PATH' ] = self .spec ['googletest' ].prefix .lib
76
+ env ['PATH' ] = '{}:{}' .format (self .spec ['lcov' ].prefix .bin , env ['PATH' ])
77
+ # overriding automatic python testing
78
+ with working_dir (self .prefix .tests ):
79
+ # FIXME:
80
+ # * expects a non-zero return code for errors
81
+ # * also too slow for a simple install test?
82
+ # ⇒ provide another simple install test?
83
+ self .run_test ('run_tests.sh' )
84
+ if '+python' in self .spec :
85
+ super (Genn , self ).test ()
0 commit comments