1 |
opts = Options('custom.py') |
2 |
opts.AddOptions( |
3 |
BoolOption('RELEASE', 'Set to build for release', 0), |
4 |
PathOption('PYTHON_HOME','Path to python home','/usr/lib/python2.3'), |
5 |
PathOption('BOOST_HOME','Path to boost home','/usr/include/boost') |
6 |
) |
7 |
|
8 |
|
9 |
# Extensions to Scons |
10 |
def build_py(target, source, env): |
11 |
# Code to build .pyc from .py |
12 |
import py_compile, sys; |
13 |
py_compile.compile(str(source[0]), str(target[0])) |
14 |
return None |
15 |
py_builder = Builder(action = build_py, suffix = '.pyc', src_suffix = '.py', single_source=True) |
16 |
|
17 |
env = Environment(tools = ['default'],options = opts) |
18 |
env.Append(BUILDERS = {'PyCompile' : py_builder}); |
19 |
|
20 |
print "PLATFORM is:", env['PLATFORM'] |
21 |
|
22 |
EnsurePythonVersion(2,3) |
23 |
|
24 |
#TODO: How do I convert these to options? |
25 |
#TODO: Is there a more compact way of setting up the include paths? |
26 |
|
27 |
# Third-Party libraries |
28 |
boost_home = env['BOOST_HOME'] |
29 |
python_home = env['PYTHON_HOME'] |
30 |
|
31 |
# Where to install (and find) esys includes and libraries |
32 |
# Note: #/ means relative to the top of source tree |
33 |
esys_inc = '#/include' |
34 |
esys_lib = '#/lib' |
35 |
|
36 |
# Derived paths |
37 |
if env['PLATFORM'] == "win32": |
38 |
python_inc = python_home + '/include' |
39 |
python_lib = python_home + '/libs' |
40 |
boost_inc = boost_home |
41 |
boost_lib = boost_home + '/windows_binary/lib' |
42 |
elif env['PLATFORM'] == "posix": |
43 |
python_inc = '/usr/include/python2.3' |
44 |
python_lib = '/usr/lib' |
45 |
boost_inc = '/usr/include' |
46 |
boost_lib = '/usr/lib' |
47 |
|
48 |
incdir = [ boost_inc, python_inc, esys_inc ] |
49 |
libdir = [ boost_lib, python_lib, esys_lib ] |
50 |
|
51 |
env.Append(CPPPATH=incdir) |
52 |
env.Append(LIBPATH=libdir) |
53 |
|
54 |
|
55 |
if env['PLATFORM'] == "win32": |
56 |
env.Append(CCFLAGS = ' /GR /EHsc /TP /wd4068') |
57 |
env.Append(CPPDEFINES = ['MSVC', 'WIN32']) |
58 |
if False : |
59 |
print "RELEASE build" |
60 |
else: |
61 |
print "DEBUG build" |
62 |
env.Append(CPPDEFINES = ['DOASSERT']) |
63 |
env.Append(CCFLAGS = ' /Od /MDd /RTC1') |
64 |
env.Append(CPPDEFINES = ['_DEBUG']) |
65 |
boost_lib_name = 'boost_python-vc71-mt-sgd' |
66 |
elif env['PLATFORM'] == "posix": |
67 |
env.Append(CC = ' -std=c99') |
68 |
env.Append(CCFLAGS = ' -c -fpic -W -Wall -Wno-unknown-pragmas') |
69 |
boost_lib_name = 'boost_python' |
70 |
if False : |
71 |
print "RELEASE build" |
72 |
else: |
73 |
print "DEBUG build" |
74 |
env.Append(CPPDEFINES = ['DOASSERT', 'DOPROF']) |
75 |
env.Prepend(CCFLAGS = ' -g -O0') |
76 |
|
77 |
Export(["env", "incdir", "esys_inc", "esys_lib", "boost_lib_name" ]) |
78 |
|
79 |
# C/C++ Libraries |
80 |
env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0) |
81 |
env.SConscript(dirs = ['bruce/src'], build_dir='build/$PLATFORM/bruce', duplicate=0) |
82 |
env.SConscript(dirs = ['escript/src/Data'], build_dir='build/$PLATFORM/escript/Data', duplicate=0) |
83 |
env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0) |
84 |
env.SConscript(dirs = ['tools/mmio/src'], build_dir='build/$PLATFORM/tools/mmio', duplicate=0) |
85 |
env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0) |
86 |
env.SConscript(dirs = ['finley/src/finleyC'], build_dir='build/$PLATFORM/finleyC', duplicate=0) |
87 |
env.SConscript(dirs = ['finley/src/CPPAdapter'], build_dir='build/$PLATFORM/CPPAdapter', duplicate=0) |
88 |
|
89 |
# Unit Tests |
90 |
env.SConscript(dirs = ['esysUtils/test/EsysException'], build_dir='build/$PLATFORM/esysUtils/test/EsysException', duplicate=0) |
91 |
env.SConscript(dirs = ['escript/test'], build_dir='build/$PLATFORM/escript/test', duplicate=0) |
92 |
env.SConscript(dirs = ['bruce/test'], build_dir='build/$PLATFORM/bruce/test', duplicate=0) |
93 |
env.SConscript(dirs = ['finley/test'], build_dir='build/$PLATFORM/finley/test', duplicate=0) |
94 |
|
95 |
if env['PLATFORM'] == "win32": |
96 |
env.SConscript(dirs = ['win32/win32_utils'], build_dir='build/$PLATFORM/win32_utils', duplicate=0) |