1 |
import os |
2 |
Import('*') |
3 |
|
4 |
local_env=env.Copy() |
5 |
py_wrapper_local_env=env.Copy() |
6 |
# Remove the sharedlibrary prefix on all platform - we don't want 'lib' mucking with our python modules |
7 |
del py_wrapper_local_env['SHLIBPREFIX'] |
8 |
|
9 |
lib_name = 'escript' |
10 |
py_wrapper_name = lib_name+'cpp' |
11 |
py_wrapper_source = py_wrapper_name+'.cpp' |
12 |
py_wrapper_lib_name = py_wrapper_name |
13 |
|
14 |
# get the relevant file names: |
15 |
src_dir = local_env.Dir('.').srcnode().abspath |
16 |
filenames = [ x for x in os.listdir(src_dir) if os.path.splitext(x)[1] in [".h", ".c", ".cpp"] ] |
17 |
|
18 |
sources = [x for x in filenames if os.path.splitext(x)[1] in ['.cpp', '.c']] |
19 |
headers = [x for x in filenames if os.path.splitext(x)[1] in ['.h']] |
20 |
|
21 |
# Filter out sources that should not be in the list automatically |
22 |
sources.remove(py_wrapper_source) # FIXME: should probably refactor the source tree so the python wrapper isn't colocated with c++ sources |
23 |
|
24 |
local_env.Append(LIBS = [boost_lib] + [ 'esysUtils'] + sys_libs + netCDF_libs + mpi_libs + [python_lib]) |
25 |
py_wrapper_local_env.Append(LIBS = [boost_lib] + [ lib_name, 'esysUtils'] + sys_libs + netCDF_libs + [python_lib]) |
26 |
if useNetCDF == 'yes': |
27 |
local_env.Append(LIBS = netCDF_libs) |
28 |
local_env.Append(CPPDEFINES = [ 'USE_NETCDF' ]) |
29 |
py_wrapper_local_env.Append(LIBS = netCDF_libs) |
30 |
py_wrapper_local_env.Append(CPPDEFINES = [ 'USE_NETCDF' ]) |
31 |
|
32 |
if papi_instrument_solver: |
33 |
local_env.Append(CPPDEFINES=['PAPI',]) |
34 |
if papi_libs: |
35 |
local_env.Append(LIBS = papi_libs) |
36 |
local_env.Append(CPPDEFINES=['BLOCKPAPI',]) |
37 |
|
38 |
local_env.Append(CPPDEFINES = [ 'ESCRIPT_EXPORTS'] ) |
39 |
|
40 |
lib = local_env.SharedLibrary(lib_name, sources) |
41 |
py_wrapper_lib = py_wrapper_local_env.SharedLibrary( py_wrapper_lib_name, py_wrapper_source) |
42 |
|
43 |
include_path = Dir(lib_name, incinstall) |
44 |
|
45 |
local_env.Install(include_path, headers ) |
46 |
local_env.Install(libinstall, lib) |
47 |
py_wrapper_local_env.InstallAs(pyinstall+'/escript/escriptcpp.so', py_wrapper_lib) |
48 |
|
49 |
#windows specific mod |
50 |
if os.name == 'nt': |
51 |
py_wrapper_local_env.InstallAs(target = [ pyinstall+'/escript/'+py_wrapper_lib_name+'.pyd', \ |
52 |
pyinstall+'/escript/'+py_wrapper_lib_name+'.lib', \ |
53 |
pyinstall+'/escript/'+py_wrapper_lib_name+'.exp' ], \ |
54 |
source = py_wrapper_lib ) |
55 |
|
56 |
# export the lib target since tests will depend on it |
57 |
# the lib target is a list of file nodes (why? win32 produces more than one output file: .lib, .dll, .pdb) |
58 |
# FIXME: This list handling produces the desired result but can this be done directly with scons File nodes? |
59 |
dep_lib = [libinstall+'/'+str(x) for x in lib] |
60 |
Export('dep_lib') |
61 |
|
62 |
|
63 |
|
64 |
# add source files to release |
65 |
release_srcfiles = [ env.File(x) for x in filenames ] + [env.File("SConscript"), ] |
66 |
env.Zip(src_zipfile, release_srcfiles) |
67 |
env.Tar(src_tarfile, release_srcfiles) |
68 |
|
69 |
# Call the python sconscript |
70 |
env.SConscript(dirs = ['#/escript/py_src'], build_dir='py', duplicate=0) |
71 |
|
72 |
# Call the unit tests SConscript |
73 |
local_env.SConscript(dirs = ['#/escript/test'], build_dir='#/build/$PLATFORM/escript/test', duplicate=0) |