-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
84 lines (72 loc) · 3.08 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
# Copyright © 2005-2009 Swiss Tropical Institute and Liverpool School Of Tropical Medicine
# Licence: GNU General Public Licence version 2 or later (see COPYING)
# This is a minimal scons configuration to build openMalaria; it is not currently complete or platform-independant.
# TODO: boinc option
# TODO: print help
# TODO: separate build dir
# TODO: check for xsd or xsdcxx
# TODO: -O2 / -g, etc.
import os.path;
import subprocess;
import glob;
import dircache;
def which(program):
import os
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def findSources(dPath):
ret = []
for l in dircache.listdir(dPath):
d = dPath + '/' + l
if os.path.isdir(d):
ret = ret + findSources(d)
ret = ret + glob.glob(dPath+'/*.cpp')
ret = ret + glob.glob(dPath+'/*.C')
ret = ret + glob.glob(dPath+'/*.cxx')
return ret
def xsdFunc(target,source,env):
outDir = os.path.dirname(str(target[0]))
inFile = str(source[0])
p = subprocess.Popen(env['XsdExec']+' cxx-tree --type-naming ucc --function-naming java --namespace-map =scnXml --generate-inline --generate-doxygen --output-dir '+outDir+' '+inFile, shell=True)
return p.wait()
xsd = Builder(action = xsdFunc, src_suffix = '.xsd')
env = Environment(CPPPATH = ['include', 'xsdcxx', 'C:\\Program Files\\CodeSynthesis XSD 3.2\\include'],
LIBPATH = ['lib'],
LIBS = ['gsl','gslcblas','xerces-c','z'])
#potentially plus: pthreads
env.Append(LDFLAGS = ['-isysroot /Developer/SDKs/MacOSX10.4u.sdk','-Wl,-syslibroot,/ Developer/SDKs/MacOSX10.4u.sdk','-arch i386'])
env.Append(CPPSUFFIXES = [".d"])
#env.Append(CCFLAGS = ['-isysroot','/Developer/SDKs/MacOSX10.4u.sdk','-arch','i386'])
#env.Append(LDFLAGS = ['-isysroot /Developer/SDKs/MacOSX10.4u.sdk','-Wl,-syslibroot,/ Developer/SDKs/MacOSX10.4u.sdk','-arch i386'])
env.Append(BUILDERS = {'XSD' : xsd})
#env.Append(CPPPATH = ['../boinc', '../boinc/api', '../boinc/lib'])
env.Append(CCFLAGS = ['-DWITHOUT_BOINC'])
conf = Configure(env)
# TODO: Checks for libraries, header files, etc. go here!
#env['XsdExec'] = which('xsdcxx')
#if env['XsdExec'] == None:
# env['XsdExec'] = which('xsd')
# if env['XsdExec'] == None:
# print 'Unable to find (code synthesis\') xsd program'
# Exit(1)
env['XsdExec'] = 'xsd'
env = conf.Finish()
env.XSD(['xsdcxx/scenario.cxx','xsdcxx/scenario.hxx','xsdcxx/scenario.ixx'],'xsdcxx/scenario')
env.Program ('openMalaria', findSources('model') + findSources('xsdcxx'), PDB = 'openMalaria.pdb')
#env.Program ('openMalaria', ['model/gzstream.C'] + Glob('model/*.cpp') + Glob('model/*/*.cpp') + Glob('xsdcxx/*.c*'))
# Optimisations:
# check timestamp and if different checksum to decide whether to rebuild
Decider('MD5-timestamp')
# We can probably use this safely, if we need to.
#SetOption('implicit_cache', 1)