-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
99 lines (77 loc) · 2.21 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /usr/bin/python
# @file
# This file is part of gambit2vtk
#
# For conditions of distribution and use, please see the copyright
# notice in the file 'COPYING' at the root directory of this package
# and the copyright notice at https://github.com/TUM-I5/gambit2vtk
#
# @copyright 2012 Technische Universitaet Muenchen
# @author Sebastian Rettenberger <[email protected]>
import os
#
# set up possible variables
#
vars = Variables()
vars.AddVariables(
EnumVariable( 'mode', 'build mode', 'release', allowed_values=('debug', 'release')),
PathVariable( 'prefix', 'install prefix', '/usr/local', PathVariable.PathAccept )
)
# set environment
env = Environment(ENV = os.environ,
variables = vars)
# generate help text
Help(vars.GenerateHelpText(env))
# handle unknown, maybe misspelled variables
unknownVariables = vars.UnknownVariables()
# exit in the case of unknown variables
if unknownVariables:
print "*** The following build variables are unknown:", unknownVariables.keys()
Exit(1)
#
# Set compiler flags
#
# eclipse specific flag
env.Append(CCFLAGS=['-fmessage-length=0'])
# other default flags
env.Append(CCFLAGS=['-Wall'])
# switch between debug/release
if env['mode'] == 'debug':
env.Append(CCFLAGS=['-O0', '-g3'])
else: # env['mode'] == release
env.Append(CCFLAGS=['-O3'])
# Find libxml2
env.ParseConfig("xml2-config --cflags --libs")
# Add the src directory to the include path
env.Append(CPPPATH=['src'])
# program name
program_name = 'gambit2vtk'
# build directory
build_dir = os.path.join(env['mode'], 'build')
# all directories containing sources ('src/' will be prepended)
src_dirs = [
'.',
'config',
'converter',
'io',
'tools'
]
# get the src-code files
env.src_files = []
for dir in src_dirs:
Export('env')
SConscript(os.path.join('src', dir, 'SConscript'),
variant_dir = os.path.join(build_dir, dir),
duplicate = 0)
Import('env')
# build the program
program = env.Program(os.path.join(env['mode'], program_name), env.src_files)
#
# install the program
#
# directory for executables
bin = os.path.join(env['prefix'], 'bin')
# install the executable
env.Install(bin, program)
# let "scons install" install all files
env.Alias('install', [bin])