-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSConstruct
More file actions
296 lines (264 loc) · 6.83 KB
/
SConstruct
File metadata and controls
296 lines (264 loc) · 6.83 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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
import os
EnsureSConsVersion( 2, 3, 0 )
# Versions
loudnessAssessmentVersionMajor = "1"
loudnessAssessmentVersionMinor = "3"
loudnessAssessmentVersionMicro = "8"
loudnessAssessmentVersion = [
loudnessAssessmentVersionMajor,
loudnessAssessmentVersionMinor,
loudnessAssessmentVersionMicro ]
loudnessAssessmentVersionStr = ".".join( loudnessAssessmentVersion )
### Command line options ###
# Get build mode
AddOption(
'--mode',
dest='mode',
type='string',
nargs=1,
action='store',
default='release',
metavar='MODE',
help='Select build mode: debug, release. [default: release].'
)
buildMode = GetOption('mode')
if not ( buildMode in [ 'debug', 'release' ] ) :
raise Exception( "Can't select build mode ['debug', 'release']" )
# Get libboost install path
AddOption(
'--boost',
dest='boost',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='Path to root of boost library (only need accumulators headers).'
)
# Get libsndfile install path
AddOption(
'--sndfile',
dest='sndfile',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='Path to root of sndfile library.'
)
# Get qt install path
AddOption(
'--qt',
dest='qt',
type='string',
nargs=1,
action='store',
default='/usr',
metavar='DIR',
help='Path to root of qt library, can be overwrited with QTDIR environement variable.'
)
AddOption(
'--qt-suffix',
dest='qtSuffix',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='Use this option to specify the path to qt library (is case of conflict between several versions for example).'
)
# Get ADM/EAR install path
AddOption(
'--adm',
dest='adm',
type='string',
nargs=1,
action='store',
default='/usr/local',
metavar='DIR',
help='Path to root of ITU-R ADM library.'
)
AddOption(
'--ear',
dest='ear',
type='string',
nargs=1,
action='store',
default='/usr/local',
metavar='DIR',
help='Path to root of EBU ADM Renderer library.'
)
AddOption(
'--bw64',
dest='bw64',
type='string',
nargs=1,
action='store',
default='/usr/local',
metavar='DIR',
help='Path to root of ITU-R BW64 headers.'
)
AddOption(
'--adm-engine',
dest='adm-engine',
type='string',
nargs=1,
action='store',
default='/usr/local',
metavar='DIR',
help='Path to root of ADM Engine.'
)
AddOption(
'--adm-loudness-worker',
dest='build-adm-loudness-worker',
action='store_true',
help='Build ADM loudness worker.'
)
# Get ffmpeg install path
AddOption(
'--ffmpeg',
dest='ffmpeg',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='Path to root of ffmpeg library.'
)
# Get avtranscoder install path
AddOption(
'--avtranscoder',
dest='avtranscoder',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='Path to root of avtranscoder library.'
)
AddOption(
'--avtranscoder-version',
dest='avtranscoderVersion',
type='string',
nargs=1,
action='store',
help='Version of avtranscoder library to link (needed only if compile on Windows).'
)
# Get gtest install path
AddOption(
'--gtest',
dest='gtest',
type='string',
nargs=1,
action='store',
metavar='DIR',
help='Path to root of gtest framework (used for the tests).'
)
# Get gtest install path
AddOption(
'--ebu-test-essences',
dest='ebuTestEssences',
type='string',
nargs=1,
action='store',
default='.',
metavar='DIR',
help='Path to essences used during tests based on EBU samples.'
)
# Get target arch
AddOption(
'--target-arch',
dest='targetArch',
type='string',
nargs=1,
action='store',
default='',
help='Use this option to specify the target arch (x86, x64...). By default the arch is choosen depending on the compiler plateform.'
)
# Option to generate code coverage
AddOption(
'--coverage',
dest='coverage',
action='append_const',
const='--coverage',
help='To run the tests and get a code coverage report.'
)
### Create env ###
env = Environment(ENV = {
'PATH': os.environ['PATH'],
'TARGET_ARCH': GetOption('targetArch'),
})
boost_root = GetOption('boost')
boost_include = ''
boost_lib = ''
if boost_root:
boost_include = os.path.join( boost_root, 'include' )
boost_lib = os.path.join( boost_root, 'lib' )
sndfile_root = GetOption('sndfile')
sndfile_include = ''
sndfile_lib = ''
if sndfile_root:
sndfile_include = os.path.join( sndfile_root, 'include' )
sndfile_lib = os.path.join( sndfile_root, 'lib' )
qt_dir = GetOption('qt')
if 'QTDIR' in os.environ:
qt_dir = os.environ['QTDIR']
qt_include_suffix = GetOption('qtSuffix')
qt_include = ''
if qt_include_suffix:
qt_include = os.path.join(qt_dir, 'include', qt_include_suffix)
env.Append(
CPPPATH = [
'#src',
sndfile_include,
boost_include,
qt_include,
],
CXXFLAGS = [
'-DLOUDNESS_ASSESSMENT_VERSION_MAJOR=' + loudnessAssessmentVersionMajor,
'-DLOUDNESS_ASSESSMENT_VERSION_MINOR=' + loudnessAssessmentVersionMinor,
'-DLOUDNESS_ASSESSMENT_VERSION_MICRO=' + loudnessAssessmentVersionMicro,
],
LIBPATH = [
'#src',
sndfile_lib,
boost_lib,
],
SHLIBVERSION = loudnessAssessmentVersionStr,
)
# Set QTDIR if specify
if qt_dir:
env.Append(
QTDIR = qt_dir,
)
# Set frameworks path if MacOS
if env['PLATFORM'] == "darwin":
env.Append(
FRAMEWORKPATH = [
'/usr/local/Frameworks',
],
)
# Add compile flags
if env['CC'] == 'gcc':
env.Append( CXXFLAGS = ['-Wall', '-fPIC', '-std=c++11'] )
if GetOption('coverage'):
env['CXXFLAGS'].extend( ['-fprofile-arcs', '-ftest-coverage'] )
env.Append( LINKFLAGS = ['-fprofile-arcs'] )
if buildMode == 'release':
env.Append( CXXFLAGS = ['-O3'] )
else:
env.Append( CXXFLAGS = ['-g'] )
elif env['CC'] == 'cl': # msvc
# Exception handling used by the compiler
env.Append( CXXFLAGS = ['/EHsc'] )
if buildMode == 'release':
# /MT: Use the multithread, static version of the run-time library
# /Ox: maximal optimization
env.Append( CXXFLAGS = ['/MT', '/Ox'] )
else:
# Plus DEBUG option
env.Append( CXXFLAGS = ['/MTd'] )
# Build src, apps and tests
Export( 'env' )
Export( 'loudnessAssessmentVersionStr' )
VariantDir( 'build/' + buildMode + '/src', 'src', duplicate = 0 )
VariantDir( 'build/' + buildMode + '/app', 'app', duplicate = 0 )
SConscript( 'src/SConscript', variant_dir = 'build/' + buildMode + '/src' )
SConscript( 'app/SConscript', variant_dir = 'build/' + buildMode + '/app' )
SConscript( 'test/SConscript', variant_dir = 'build/' + buildMode + '/test' )
SConscript( 'worker/SConscript', variant_dir = 'build/' + buildMode + '/worker' )