-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathSConstruct
More file actions
100 lines (88 loc) · 3.51 KB
/
SConstruct
File metadata and controls
100 lines (88 loc) · 3.51 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
94
95
96
97
98
99
100
# -*- 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
sys.path.insert(0, os.path.abspath('Boost.NumPy'))
from SConsChecks import AddLibOptions, GetLibChecks
setupOptions, makeEnvironment, setupTargets, checks, libs = SConscript("Boost.NumPy/SConscript")
libs.extend(['swig', 'eigen', 'boost.test', 'fftw', 'boost.preprocessor'])
checks = GetLibChecks(libs)
variables = setupOptions()
AddOption("--with-eigen", dest="eigen_prefix", type="string", nargs=1, action="store",
metavar="DIR", default=os.environ.get("EIGEN_DIR"),
help="prefix for Eigen libraries; should have an 'include' subdirectory")
AddOption("--with-eigen-include", dest="eigen_include", type="string", nargs=1, action="store",
metavar="DIR", help="location of Eigen header files")
AddOption("--with-fftw", dest="fftw_prefix", type="string", nargs=1, action="store",
metavar="DIR", default=os.environ.get("FFTW_DIR"),
help="prefix for FFTW libraries; should have 'include' and 'lib' subdirectories")
AddOption("--with-fftw-include", dest="fftw_include", type="string", nargs=1, action="store",
metavar="DIR", help="location of FFTW header files")
AddOption("--with-fftw-lib", dest="fftw_lib", type="string", nargs=1, action="store",
metavar="DIR", help="location of FFTW library")
building = not GetOption("help") and not GetOption("clean")
env = makeEnvironment(variables)
env.Tool('m4')
env.AppendUnique(CPPPATH=["#include"])
if building:
config = env.Configure(custom_tests=checks)
haveEigen = config.CheckEigen()
haveFFTW = config.CheckFFTW()
env = config.Finish()
else:
haveEigen = False
haveFFTW = False
env.haveEigen = haveEigen
env.haveFFTW = haveFFTW
testEnv = env.Clone()
if building:
config = testEnv.Configure(custom_tests=checks)
haveBoostTest = config.CheckBoostTest()
testEnv = config.Finish()
else:
haveBoostTest = False
testEnv.haveBoostTest = haveBoostTest
pyEnv = env.Clone()
if building:
config = pyEnv.Configure(custom_tests=checks)
havePython = config.CheckPython() and config.CheckNumPy()
haveSwig = havePython and config.CheckSwig()
if haveSwig:
pyEnv.AppendUnique(SWIGPATH = ["#include"])
config.CheckBoostPP()
pyEnv = config.Finish()
else:
havePython = False
haveSwig = False
pyEnv.havePython = havePython
pyEnv.haveSwig = haveSwig
bpEnv = pyEnv.Clone()
if building:
config = bpEnv.Configure(custom_tests=checks)
haveBoostPython = config.CheckBoostPython()
bpEnv = config.Finish()
else:
haveBoostPython = False
bpEnv.haveBoostPython = haveBoostPython
bpEnv.AppendUnique(CPPPATH=["#Boost.NumPy"])
if haveBoostPython:
setupTargets(bpEnv, root="Boost.NumPy")
elif building:
print("Not building Boost.NumPy component.")
headers = SConscript(os.path.join("include", "SConscript"), exports="env")
prefix = Dir(GetOption("prefix")).abspath
install_headers = GetOption("install_headers")
if not install_headers:
install_headers = os.path.join(prefix, "include")
for header in Flatten(headers):
relative = os.path.relpath(header.abspath, Dir("#include").abspath)
env.Alias("install", env.InstallAs(os.path.join(install_headers, relative), header))
tests = SConscript(os.path.join("tests", "SConscript"), exports=["env", "testEnv", "pyEnv", "bpEnv"])