-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSConstruct
241 lines (190 loc) · 9.68 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------------------------------------------------
# Help message -------------------------------------------------------------------------------------------------------
Help("""
Type 'scons config=<config type> project=<module name>
config type = release | debug
module name = all | AcParameters | Convolver | Kirkeby | PeakVue | SineSweepGenerator | STI | TimeHistoryAnalyzer | XFunctions
Default scons config=release project=all
""")
# Import external environment variables, ecc. ------------------------------------------------------------------------
import os
import sys
# import the module
sys.path.append('scripts')
from wxconfig import *
# Manage command line arguments --------------------------------------------------------------------------------------
vars = Variables()
vars.AddVariables( EnumVariable('config', 'Set configuration', 'release',
allowed_values=('debug', 'release')),
EnumVariable('project', 'Set target module', 'all',
allowed_values=('all',
'AcParameters',
'Convolver',
'Kirkeby',
'PeakVue',
'SineSweepGenerator',
'STI',
'TimeHistoryAnalyzer',
'XFunctions',
'Common')),
BoolVariable('usewxconfig', 'Use wx-config script', 1) )
# Modules --------------------------------------------------------------------------------------------------
aurora_modules = Split("""AcParameters
Convolver
Kirkeby
PeakVue
SineSweepGenerator
STI
TimeHistoryAnalyzer
XFunctions""")
# Create common evironment for build: -------------------------------------------------------------------------------
common_env = Environment( CXX = 'g++',
ENV = {'PATH' : os.environ['PATH']},
variables = vars )
common_env['build_platform'] = common_env['PLATFORM']
common_env['target_platform'] = common_env['PLATFORM']
use_wx_config = common_env['usewxconfig']
# it is recommended to get these from SCons parameters
common_env['wxconfig'] = 'wx-config'
# Get project name: --------------------------------------------------------------------------------------------------
project = common_env['project']
# Set debug flag: --------------------------------------------------------------------------------------------------
debug = False
if common_env['config'] == 'debug':
debug = True
# Paths name --------------------------------------------------------------------------------------------------
audacity_src_path = os.environ['HOME'] + '/src/audacity-src'
aurora_src_prefix = os.environ['HOME'] + '/Dropbox/Development/aurora/src'
audacity_modules_path = '/usr/local/share/audacity/modules'
wx_cfg = 'wx-config --cflags --libs'
if debug:
wx_cfg += ' --debug=yes'
wx_prefix = '/usr/local'
else:
wx_prefix = '/usr'
# Preprocessor options -----------------------------------------------------------------------------------------------
cpp_flags = ['-Wall']
# Compiler options ---------------------------------------------------------------------------------------------------
if debug:
cxx_flags = Split('-g -O0')
else:
cxx_flags = ['-O3']
# Include paths ---------------------------------------------------------------------------------------------------
include_path = [ aurora_src_prefix + '/Common/src',
aurora_src_prefix + '/Common/include',
audacity_src_path + '/src',
wx_prefix + '/include/wx-2.8' ]
# Linker options -----------------------------------------------------------------------------------------------------
common_libs = Split('m fftw3f')
link_flags = ['-Wl,--export-dynamic']
if debug:
link_flags += ['-g']
common_env.Append( CPPFLAGS = cpp_flags,
CPPPATH = include_path,
CXXFLAGS = cxx_flags,
LINKFLAGS = link_flags,
LIBS = common_libs)
# Check for library presence: -------------------------------------------------------------------------------
conf = Configure(common_env, custom_tests = {'CheckWXConfig' : CheckWXConfig })
# CheckWXConfig(version, componentlist, debug)
# version: string with minimum version ('x.y')
# componentlist: list of components needed. This was introduced with
# wxWidgets 2.6 if I'm correct. You'll usually need
# ['adv', 'core', 'base'], in this order. If you use
# wxGLCanvas, prepend 'gl' like below.
if not conf.CheckWXConfig('2.8', ['html', 'adv', 'core', 'base'], debug):
print 'wxWidgets library not found.'
Exit(1)
if not conf.CheckLibWithHeader('fftw3', 'fftw3.h', 'c'):
print 'Did not find libfftw3f.a or libfftw3f.so, exiting!'
Exit(1)
common_env = conf.Finish()
# wxWidgets - linux --------------------------------------------------------------------------------------------------
wx_cpp_defines = ['MULTIRATE_FILTERING',
'__ITUP56_SINGLE_FRAME__',
'__AUDEBUG__'] #aurora debug macro
wx_libpath = ['/usr/lib',
'/usr/local/lib']
if not use_wx_config:
wx_include_path = [ wx_prefix + '/include/wx-2.8']
wx_cpp_defines += ['_FILE_OFFSET_BITS=64',
'_LARGE_FILES',
'__WXGTK__']
wx_cxx_flags_linux = ['-pthread']
if debug:
if not use_wx_config:
wx_cpp_defines += ['__WXDEBUG__']
wx_include_path += [wx_prefix + '/lib/wx/include/gtk2-unicode-debug-2.8']
wx_libs = Split("""wx_baseud-2.8
wx_baseud_net-2.8
wx_gtk2ud_adv-2.8
wx_gtk2ud_core-2.8
wx_gtk2ud_html-2.8""")
else:
wx_cpp_defines += [ 'AURORA_RELEASE' ]
if not use_wx_config:
wx_include_path += [ wx_prefix + '/lib/wx/include/gtk2-unicode-release-2.8']
wx_libs = Split("""wx_baseu-2.8
wx_baseu_net-2.8
wx_gtk2u_adv-2.8
wx_gtk2u_core-2.8
wx_gtk2u_html-2.8""")
# Set specific environments -------------------------------------------------------------------------------------------
wx_env = common_env.Clone()
if use_wx_config:
wx_env.ParseConfig(wx_cfg)
wx_env.Append(CPPDEFINES = wx_cpp_defines,
LIBPATH = wx_libpath)
else:
wx_env.Append(CPPDEFINES = wx_cpp_defines,
CPPPATH = wx_include_path,
CXXFLAGS = cxx_flags,
LINKFLAGS = wx_link_flags,
LIBS = wx_libs,
LIBPATH = wx_libpath)
lib_env = wx_env.Clone()
# Add Aurora static libs -------------------------------------------------------------------------------------------
if debug:
wx_env.Append(LIBS = ['aurorad'],
LIBPATH = ['../Common'])
else:
wx_env.Append(LIBS = ['aurora'],
LIBPATH = ['../Common'])
# Set build directory --------------------------------------------------------------------------------------
build_dir = os.environ['HOME'] + '/Development/Aurora/linux'
if debug:
build_prefix = build_dir + '/Debug'
else:
build_prefix = build_dir + '/Release'
# Set exports lists ---------------------------------------------------------------------------------------
exports_list = ['project',
'lib_env',
'wx_env',
'build_dir',
'build_prefix',
'audacity_modules_path',
'debug']
# Invoke Sconscripts -------------------------------------------------------------------------------------------
commons_obj = SConscript( 'src/Common/src/SConscript',
exports = exports_list,
variant_dir = build_prefix + '/Common',
duplicate = 0 )
if project != 'Common':
exports_list += ['commons_obj']
product_list = []
if project == 'all':
for mod_name in aurora_modules:
project = mod_name
product_list += SConscript( 'src/' + mod_name + '/src/SConscript',
exports = exports_list,
variant_dir = build_prefix + '/' + mod_name,
duplicate = 0 )
else:
product_list += SConscript( 'src/' + project + '/src/SConscript',
exports = exports_list,
variant_dir = build_prefix + '/' + project,
duplicate = 0 )
# Install -----------------------------------------------------------------------------------------------------
wx_env.Install(audacity_modules_path, product_list)
wx_env.Alias('install', audacity_modules_path)