-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSConstruct
More file actions
77 lines (60 loc) · 2.2 KB
/
SConstruct
File metadata and controls
77 lines (60 loc) · 2.2 KB
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
# This is an scons script to build the library
# Projects in different IDEs should make an scons call to this file
from os import path
# directory info
viking_dirs = {
'target': 'viking',
'src': 'source/src', # root of source files
'include': 'source/include', # root of include directory
'build': 'build', # name of the build folder created in the root of the repository
'obj': 'obj', # name of the build subdirectory where object files are built
'bin': 'bin',
'release': 'Release',
'debug': 'Debug',
'demos': 'demos',
'test': 'Test'
}
# compiler flags
viking_flags = {
'common': [ '-std=c++0x', '-Wall' ],
'debug': [ '-g', '-D_DEBUG' ],
'release': [ '-O2', '-DNDEBUG' ],
}
# libraries to link
viking_libs = {
'common': [ 'Irrlicht', 'GL' ]
}
# will be either viking_dirs['debug'] or viking_dirs['release'] depending on script arguments
build_configuration = ''
# pick up "debug" argument from command line input. Defaults to 0 (false).
if ARGUMENTS.get('debug', '0') != '0':
build_configuration = viking_dirs['debug']
else:
build_configuration = viking_dirs['release']
# create environment
env = Environment()
# add common compiler flags
env.Append(CXXFLAGS = viking_flags['common'])
# add include directory
env.Append(CPPPATH = path.abspath(viking_dirs['include']))
configuration_path = ''
# conditionally add compiler flags
if build_configuration == viking_dirs['debug']:
env.Append(CXXFLAGS = viking_flags['debug'])
configuration_path = viking_dirs['debug']
else:
env.Append(CXXFLAGS = viking_flags['release'])
configuration_path = viking_dirs['release']
# compose path to build of Viking
viking_dirs['build_obj'] = path.abspath(path.join(viking_dirs['build'], configuration_path, viking_dirs['obj']))
viking_dirs['build_bin'] = path.abspath(path.join(viking_dirs['build'], configuration_path, viking_dirs['bin']))
# export variables so other scripts can Import them
Export('env viking_dirs build_configuration viking_libs')
# subdirectories with SConscripts in them
script_subdirs = []
if ARGUMENTS.get('viking','1') != '0':
script_subdirs += ['source']
if ARGUMENTS.get('test','0') != '0':
script_subdirs += ['tests']
# Run scripts to selectively build viking sub-projects
SConscript(dirs=script_subdirs, name='SConscript')