-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathSConscript
More file actions
93 lines (83 loc) · 3.88 KB
/
SConscript
File metadata and controls
93 lines (83 loc) · 3.88 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# -*- python -*-
#
# Copyright (c) 2010-2012, Jim Bosch
# All rights reserved.
#
# ndarray is distributed under a simple BSD-like license;
# see the LICENSE file that should be present in the root
# of the source distribution, or alternately available at:
# https://github.com/ndarray/ndarray
#
import os
import sys
def RunBinaryUnitTest(target, source, env):
if not env.Execute(source[0].abspath):
env.Execute(Touch(target))
def BinaryUnitTest(env, source, dependencies=None):
if os.name != 'nt':
bin = env.Program(target="%s.test" % source, source=source)
else:
bin = env.Program(source)
run = env.Command(".%s.succeeded" % str(source), bin, RunBinaryUnitTest)
if dependencies:
env.Depends(run, dependencies)
env.Alias("tests", run)
return run
def RunPythonUnitTest(target, source, env):
if not env.Execute('%s %s' % (sys.executable, source[0].abspath)):
env.Execute(Touch(target))
def PythonUnitTest(env, script, dependencies):
run = env.Command(".%s.succeeded" % str(script), script, RunPythonUnitTest)
env.Depends(run, dependencies)
env.Alias("tests", run)
return run
Import("env", "testEnv", "pyEnv", "bpEnv")
if testEnv.haveBoostTest:
BinaryUnitTest(testEnv, "ndarray.cc")
BinaryUnitTest(testEnv, "views.cc")
if testEnv.haveEigen:
BinaryUnitTest(testEnv, "ndarray-eigen.cc")
if testEnv.haveFFTW:
fftwEnv = testEnv.Clone()
BinaryUnitTest(fftwEnv, "ndarray-fft.cc")
if pyEnv.havePython:
mod = pyEnv.LoadableModule("python_test_mod", "python_test_mod.cc", SHLIBPREFIX="")
if os.name == 'nt':
# Move the module to have the correct name.
mod = env.Command(os.path.join(Dir('.').srcnode().abspath, "python_test_mod.pyd"),
mod,
Move(os.path.join(Dir('.').srcnode().abspath, "python_test_mod.pyd"), mod[0]))
PythonUnitTest(pyEnv, "python_test.py", mod)
if pyEnv.haveSwig and pyEnv.haveEigen:
mod = pyEnv.LoadableModule("_swig_test_mod", ["swig_test_mod.i"], SHLIBPREFIX="")
if os.name == 'nt':
# Move the module to have the correct name.
mod = env.Command(os.path.join(Dir('.').srcnode().abspath, "_swig_test_mod.pyd"),
mod,
Move(os.path.join(Dir('.').srcnode().abspath, "_swig_test_mod.pyd"), mod[0]))
PythonUnitTest(pyEnv, "swig_test.py", mod)
if bpEnv.haveBoostPython:
libs = bpEnv.get("LIBS", []) + ["boost_numpy"]
libpath = bpEnv.get("LIBPATH", []) + [Dir("#Boost.NumPy/libs/numpy/src").abspath]
rpath = bpEnv.get("RPATH", []) + [Dir("#Boost.NumPy/libs/numpy/src").abspath]
bpEnv.Append( LINKFLAGS = ["$__RPATH"] ) # workaround for SCons bug #1644
mod = bpEnv.LoadableModule("bp_test_mod", "bp_test_mod.cc", SHLIBPREFIX="",
LIBS=libs, LIBPATH=libpath, RPATH=rpath)
if os.name == 'nt':
# Move the module to have the correct name.
mod = env.Command(os.path.join(Dir('.').srcnode().abspath, "bp_test_mod.pyd"),
mod,
Move(os.path.join(Dir('.').srcnode().abspath, "bp_test_mod.pyd"), mod[0]))
PythonUnitTest(bpEnv, "bp_test.py", mod)
if bpEnv.haveEigen:
mod = bpEnv.LoadableModule("eigen_bp_test_mod", "eigen_bp_test_mod.cc", SHLIBPREFIX="",
LIBS=libs, LIBPATH=libpath, RPATH=rpath)
if os.name == 'nt':
# Move the module to have the correct name.
mod = env.Command(os.path.join(Dir('.').srcnode().abspath, "eigen_bp_test_mod.pyd"),
mod,
Move(os.path.join(Dir('.').srcnode().abspath, "eigen_bp_test_mod.pyd"), mod[0]))
PythonUnitTest(bpEnv, "eigen_bp_test.py", mod)
env.Clean("tests", Glob("*.os"))
env.Clean("tests", Glob("*.pyc"))
env.Clean("tests", Glob("*.so"))