-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
77 lines (67 loc) · 2.24 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
#!python
#!/usr/bin/env python
import os, os.path, sys, fnmatch, time
# ------------------------------------------------------------------
# ------------- BUILD ENVIRONMENT ----------------------------------
# ------------------------------------------------------------------
common_env = Environment(ENV = os.environ, tools = ['default'])
try:
common_env['CXX']=os.environ['CXX']
except:
pass
#end try
# check dependencies
conf = Configure(common_env)
# ------------------------------------------------------------------
# ------------- BUILD SETTINGS -------------------------------------
# ------------------------------------------------------------------
debug = int(ARGUMENTS.get('debug', 0))
test = int(ARGUMENTS.get('test', 0))
release = 0
if (debug):
# Debug build
# Add -g for debug builds
conf.env.Append(CFLAGS = '-g')
conf.env.Append(CPPFLAGS = '-g')
else:
# Add -O3 for release builds
conf.env.Append(CFLAGS = '-O3')
conf.env.Append(CPPFLAGS = '-O3')
release = 1
#end if
# Finalize configuring environment
env = conf.Finish()
# ------------------------------------------------------------------
# ------------- BUILD TARGETS --------------------------------------
# ------------------------------------------------------------------
mode = ''
if(debug): mode = 'debug'
else: mode = 'release'
#
# Paths
#
dirs = ['src']
for sd in dirs:
buildDir = os.path.join('build/%s'%(mode),sd)
consFile = os.path.join(buildDir,'SConscript')
common_env.VariantDir(buildDir, sd)
common_env.SConscript(consFile, {'env': common_env})
#end for
# ------------------------------------------------------------------
# ------------- POST-BUILD ACTIONS ---------------------------------
# ------------------------------------------------------------------
# Add an action to run tests
def runTests(target=None, source=None, env=None):
targetdir = target[0].dir
if(test):
print ('\n[ *** Running Test-suite *** ]\n')
cmd = os.path.join('./build/%s'%(mode), 'src/tests/testsuite')
while (not os.path.exists(cmd)):
pass
#wend
time.sleep(1)
os.system(cmd)
#end if
#end func
runTestsCommand = Command( 'runTests', [], runTests)
Depends(runTestsCommand, DEFAULT_TARGETS)