-
Notifications
You must be signed in to change notification settings - Fork 57
/
SConstruct
63 lines (53 loc) · 2.36 KB
/
SConstruct
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
import sys
import distutils.sysconfig
import numpy.distutils.misc_util
LIBPATH = ['/usr/lib', '.', '/usr/local/lib', '/sw/lib']
CPPPATH = ['/usr/local/include', '/sw/include', '/usr/include']
CCFLAGS = ['-O3']
# Some settings depending on the platform.
if sys.platform == 'darwin':
libname = 'libarac.dylib'
linkflags = '-Wno-long-double -undefined suppress -flat_namespace '
frameworksflags = '-flat_namespace -undefined suppress'
CPPPATH.append('/System/Library/Frameworks/vecLib.framework/Versions/A/Headers')
elif sys.platform == 'linux2':
libname = 'libarac.so'
frameworksflags = ''
linkflags = ''
else:
raise SystemExit("Cannot build on %s." % sys.platform)
TARGET = '/usr/local'
PYTHONPATH = [distutils.sysconfig.get_python_inc()]
NUMPYPATH = numpy.distutils.misc_util.get_numpy_include_dirs()
# First compile and link the library.
libenv = Environment(LIBS=['m', 'blas'], CPPPATH=CPPPATH, LIBPATH=LIBPATH,
SHLIBPREFIX="", CCFLAGS=CCFLAGS)
library_globs = ['src/cpp/*.cpp',
'src/cpp/common/*.cpp',
'src/cpp/utilities/*.cpp',
'src/cpp/datasets/*.cpp',
'src/cpp/optimization/*.cpp',
'src/cpp/optimization/descent/*.cpp',
'src/cpp/structure/*.cpp',
'src/cpp/structure/connections/*.cpp',
'src/cpp/structure/modules/*.cpp',
'src/cpp/structure/networks/*.cpp',
'src/cpp/structure/networks/mdrnns/*.cpp']
lib = libenv.SharedLibrary(libname, sum([Glob(i) for i in library_globs], []))
# Then compile the tests.
testenv = Environment(LIBS=['arac', 'gtest'], CPPPATH=CPPPATH, LIBPATH=LIBPATH)
test = testenv.Program('test-arac', Glob('src/cpp/tests/*.cpp'))
swigenv = Environment(SWIGFLAGS=['-python', '-c++', '-outdir', 'src/python/arac'],
CPPPATH=CPPPATH + NUMPYPATH + PYTHONPATH,
LIBS=['arac'],
FRAMEWORKSFLAGS=frameworksflags,
LINKFLAGS=linkflags,
LIBPATH=LIBPATH,
LDMODULEPREFIX='src/python/arac/_',
LDMODULESUFFIX = '.so',
)
swig = swigenv.LoadableModule('cppbridge',
['src/swig/cppbridge.i'])
# Declare some dependencies.
Depends(test, lib)
Depends(swig, test)