forked from NVIDIA/thrust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConscript
More file actions
60 lines (41 loc) · 1.55 KB
/
SConscript
File metadata and controls
60 lines (41 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Import('env')
# clone the parent's env so that we do not modify it
my_env = env.Clone()
vars = Variables()
# add a variable to filter source files by a regex
vars.Add('tests', 'Filter test files using a regex', '.')
# update variables
my_env.Help(vars.GenerateHelpText(env))
vars.Update(my_env)
# populate the environment
# with cl we have to do /bigobj
if my_env.subst('$CXX') == 'cl':
my_env.Append(CPPFLAGS = '/bigobj')
# #include the current directory
my_env.Append(CPPPATH = Dir('.').srcnode())
# find all .cus & .cpps
sources = []
extensions = ['*.cu', '*.cpp']
# gather sources in the current directorie
for ext in extensions:
sources.extend(my_env.Glob(ext))
# gather sources from directories
sources.extend(SConscript('backend/SConscript', exports='env'))
# filter sources
import re
filter_exp = 'int main|TestDriver|{0}'.format(my_env['tests'])
pattern = re.compile(filter_exp)
def test_filter(src):
return pattern.search(src.get_contents())
sources = filter(test_filter, sources)
tester = my_env.Program('tester', sources)
# create a 'unit_tests' alias
unit_tests_alias = my_env.Alias('unit_tests', [tester])
# add the verbose tester to the 'run_unit_tests' alias
run_unit_tests_alias = my_env.Alias('run_unit_tests', [tester], tester[0].abspath + ' --verbose')
# always build the 'run_unit_tests' target whether or not it needs it
my_env.AlwaysBuild(run_unit_tests_alias)
# add the unit tests alias to the 'run_tests' alias
my_env.Alias('run_tests', [tester], tester[0].abspath)
# build children
SConscript('trivial_tests/SConscript', exports='env')