~ubuntu-branches/ubuntu/wily/bombono-dvd/wily

« back to all changes in this revision

Viewing changes to SConstruct

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-04 11:46:25 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101104114625-8xfdhvhpsm51i0nu
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
BV.Targets = COMMAND_LINE_TARGETS
20
20
 
21
21
############################################
22
 
# Dependency libraries
 
22
# Dependency libraries & Settings
23
23
 
24
24
# via pkg-config
25
 
RequiredLibs = ['glibmm-2.4', 'libxml++-2.6', 'mjpegtools', 'GraphicsMagick++', 'gtkmm-2.4']
 
25
RequiredLibs = ['glibmm-2.4', 'libxml++-2.6', 'gtkmm-2.4']
26
26
 
27
27
# define path to libs
28
28
def SetLibraries(config, user_options_dict):
34
34
    # we make arg's tuple from list
35
35
    args = tuple([ (BV.MakeDictName(lib),) for lib in RequiredLibs ])
36
36
    user_options.AddVariables(*args)
37
 
        
 
37
 
 
38
 
 
39
# legacy stuff (support for GM is hard => trash)
 
40
# to turn on:
 
41
# 1. False -> True
 
42
# 2. uncomment in src/SConscript
 
43
BuildMcomposite = False
 
44
if BuildMcomposite:
 
45
    RequiredLibs.extend(['mjpegtools', 'GraphicsMagick++'])
 
46
 
 
47
# global -pthread
 
48
IsThreadedBuild = False
 
49
ThreadOpt = ['-pthread']
 
50
            
38
51
############################################
39
52
# Compilers
40
53
 
42
55
cxx_warn_flags    = []
43
56
debug_flags   = ['-g', '-O0']
44
57
release_flags = ['-O2']
45
 
profile_flags = ['-g'] #['-pg']
46
58
defines       = []
47
59
 
48
60
def CalcCommonFlags():
49
61
    if BV.IsReenter(CalcCommonFlags):
50
62
        return
51
63
 
52
 
    global common_warn_flags, cxx_warn_flags, profile_flags, defines
 
64
    global common_warn_flags, cxx_warn_flags, debug_flags, defines
53
65
    if BV.IsGccCompiler():
54
66
        # GCC
55
67
        common_warn_flags = ['-ansi']
59
71
        # but not
60
72
        #   CXXCOM = $CXX -o $TARGET -c $CCFLAGS $CXXFLAGS ...
61
73
        cxx_warn_flags = ['-Wall', '-W', '-Wno-reorder'] # -W == -Wextra
62
 
 
 
74
        # Oh, GCC! Just give me the speed. If you don't stop getting slower, I'll go to Clang.
 
75
        debug_flags += ['-pipe']
 
76
    elif BV.IsClangCompiler():
 
77
        common_warn_flags = ['-ansi']
 
78
        cxx_warn_flags    = [
 
79
            '-Wall', '-Wno-reorder', 
 
80
            '-Wno-unused-variable'   # many Boost code throws it like "boost::lambda::_1"
 
81
        ]
63
82
    elif BV.Cc == 'como' or BV.Cxx == 'como':
64
83
        # Comeau compiler
65
84
        #
81
100
         '--diag_suppress=611,21,815,414',
82
101
        ]
83
102
        cxx_warn_flags = []
84
 
        profile_flags = []
85
103
        # policy: no XOPEN things meanwhile.
86
104
        defines = [ 
87
105
                    ('_POSIX_C_SOURCE','200112L'),  # fdopen(), fileno(), ...
98
116
        cflags = release_flags
99
117
 
100
118
    ldflags = []
101
 
    if BV.BuildProfile:
102
 
        cflags += profile_flags
103
 
        ldflags += profile_flags
 
119
    #if BV.BuildProfile:
 
120
    #    cflags += profile_flags
 
121
    #    ldflags += profile_flags
104
122
    
105
123
    env.Replace(CC = BV.Cc)
106
124
    env.Replace(CXX = BV.Cxx)
129
147
        AdjustConfigOptions.lfs = dict
130
148
    env.Append(**AdjustConfigOptions.lfs)
131
149
 
 
150
    # Multithreading, global
 
151
    if IsThreadedBuild:
 
152
        env.Append(CCFLAGS = ThreadOpt, LINKFLAGS = ThreadOpt)
 
153
 
132
154
############################################
133
155
# Defaults
134
156
 
145
167
 
146
168
def ParseVariables(user_options):
147
169
    user_options.AddVariables (
148
 
            (EnumVariable ('BUILD_CFG',
 
170
            (EnumVariable('BUILD_CFG',
149
171
                        'Select release or debug build.', 
150
172
                        'release', allowed_values = ('release', 'debug'))),
151
173
                ('BUILD_DIR', 'Target directory for intermediate files.',
152
174
                                        'build'),
153
 
            (BoolVariable ('BUILD_PROFILE',
154
 
                        #'Set to 1 if you want to compile in profiling information (gprof).',
155
 
                        'Set to 1 if you want to compile in profiling information (just -g for oprofile, not for gprof).',
156
 
                        'false')),
157
 
            (BoolVariable ('BUILD_BRIEF',
 
175
            (BoolVariable('BUILD_BRIEF',
158
176
                        'Set to 1 if you want brief compiling/linking output.',
159
177
                        'false')),
160
 
            (BoolVariable ('BUILD_QUICK',
161
 
                        'Set to 1 if you want to reduce building time using: \n' +
162
 
                         '\t1) PCH - precompiled headers \n' +
163
 
                         '\t2) some SCons perfomance tuning.\t\t\t',
164
 
                        'false')),
 
178
            (EnumVariable('BUILD_QUICK',
 
179
                        "Set to 'true' if you want to reduce building time using: \n"
 
180
                        "\t1) PCH - precompiled headers \n"
 
181
                        "\t2) some SCons perfomance tuning.\n"
 
182
                        "\t'auto' implies true for debug build and false for release one.",
 
183
                        'auto', allowed_values = ('auto', 'false', 'true'))),
165
184
            ('PREFIX',  'Change the default install directory.', '/usr/local'),
166
185
            ('DESTDIR', 'Set the intermediate install directory.', ''),
167
186
            ('CC', 'C compiler.'),
169
188
                ('CFLAGS',  'Extra C Compiler flags (for C++ too).', ''),
170
189
                ('CXXFLAGS','Extra C++ Compiler flags.', ''),
171
190
                ('LDFLAGS', 'Extra Linker flags.', ''),
172
 
            (BoolVariable ('TEST',
173
 
                        'Set to 1 if you want to run tests for checking your build.',
174
 
                        'false')),
175
 
            (BoolVariable ('TEST_BUILD',
176
 
                        'Set to 1 if you want to build tests (for developers).',
177
 
                        'false')),
178
 
            (BoolVariable ('USE_EXT_BOOST',
 
191
            (BoolVariable('TEST',
 
192
                        'Set to 1 if you want to build and run tests.',
 
193
                        'false')),
 
194
            (BoolVariable('USE_EXT_BOOST',
179
195
                        'Leave this setting 0 to use embedded Boost library version (recommended).',
180
196
                        'false')),
181
197
            ('BOOST_INCLUDE', 'Set to include path for external(not embedded) version of the Boost library.', ''),
182
198
            ('BOOST_LIBPATH', 'Set to library dir path for external(not embedded) version of the Boost library.', ''),
183
199
            ('DVDREAD_INCLUDE', 'Set to include path for libdvdread header files.', ''),
184
200
            ('DVDREAD_LIBPATH', 'Set to library path where the libdvdread is located.', ''),
 
201
            # Undocumented
 
202
            (BoolVariable('TEST_BUILD',
 
203
                        'Set to 1 if you want to build with tests (all).',
 
204
                        'false')),
185
205
            )
186
206
    # we need to add 'lib dict vars' user_options to load in user_options_env
187
207
    AddLibOptions(user_options)
188
208
 
189
209
    # Configuration
190
 
    user_options.AddVariables( ('IS_GCC',), ('CONFIGURATION',) )
 
210
    def add_calc_variables(*lst):
 
211
        lst = ((name,) for name in lst)
 
212
        user_options.AddVariables( *lst )
 
213
    add_calc_variables('IS_GCC', 'IS_CLANG', 'CONFIGURATION')
191
214
 
192
215
    # make help (scons -h)
193
216
    user_options_env = Environment(ENV = os.environ, options = user_options)
196
219
    global user_options_dict
197
220
    user_options_dict = user_options_env.Dictionary()
198
221
    # must be later than assigning
 
222
    BV.InitUOD(user_options_dict)
199
223
    Export('user_options_dict')
200
 
    BV.UserOptDict = user_options_dict
201
224
    user_options_dict['AdjustConfigOptions'] = AdjustConfigOptions
202
225
 
203
226
    # fill in BuildVars
204
227
    BV.BuildCfg = user_options_dict['BUILD_CFG']
205
228
    BV.BuildDir = user_options_dict['BUILD_DIR']
206
 
    BV.BuildProfile = user_options_dict['BUILD_PROFILE']
207
229
    BV.BuildBrief = user_options_dict['BUILD_BRIEF']
208
230
 
209
231
    BV.Cc  = user_options_dict['CC']
240
262
    user_options = Variables(None, BV.Args)
241
263
    ParseVariables(user_options)
242
264
    try:
 
265
        def write_dict_value(name):
 
266
            config.write('%s = %r\n' % (name, user_options_dict[name]))
 
267
 
243
268
        # save to file
244
269
        config = open(BV.CfgFile, 'w')
245
270
    
246
271
        config.write("# Options for building Atom project\n")
247
272
        config.write('BUILD_CFG = %r\n' % (BV.BuildCfg))
248
273
        config.write('BUILD_DIR = %r\n' % (BV.BuildDir))
249
 
        config.write('BUILD_PROFILE = %r\n' % (BV.BuildProfile))
250
274
        config.write('BUILD_BRIEF = %r\n' % (BV.BuildBrief))
251
 
        config.write('BUILD_QUICK = %r\n' % (user_options_dict['BUILD_QUICK']))
252
 
        config.write('PREFIX = %r\n' % (user_options_dict['PREFIX']))
253
 
        config.write('DESTDIR = %r\n' % (user_options_dict['DESTDIR']))
 
275
        write_dict_value('BUILD_QUICK')
 
276
        config.write('TEST = %r\n' % (BV.RunTests))
 
277
        write_dict_value('PREFIX')
 
278
        write_dict_value('DESTDIR')
254
279
    
255
280
        config.write('\n# Compiler information\n')
256
281
        config.write('CC = %r\n' % (BV.Cc))
259
284
        config.write('CXXFLAGS = %r\n' % (BV.CxxFlags))
260
285
        config.write('LDFLAGS = %r\n' % (BV.LdFlags))
261
286
 
262
 
        config.write('\n# Test options\n')
263
 
        config.write('TEST = %r\n' % (BV.RunTests))
264
 
        config.write('TEST_BUILD = %r\n' % (BV.BuildTests))
265
 
 
266
287
        config.write('\n# Boost library\n')
267
 
        config.write('USE_EXT_BOOST = %r\n' % (user_options_dict['USE_EXT_BOOST']))
268
 
        config.write('BOOST_INCLUDE = %r\n' % (user_options_dict['BOOST_INCLUDE']))
269
 
        config.write('BOOST_LIBPATH = %r\n' % (user_options_dict['BOOST_LIBPATH']))
 
288
        write_dict_value('USE_EXT_BOOST')
 
289
        write_dict_value('BOOST_INCLUDE')
 
290
        write_dict_value('BOOST_LIBPATH')
270
291
 
271
292
        config.write('\n# libdvdread library\n')
272
 
        config.write('DVDREAD_INCLUDE = %r\n' % (user_options_dict['DVDREAD_INCLUDE']))
273
 
        config.write('DVDREAD_LIBPATH = %r\n' % (user_options_dict['DVDREAD_LIBPATH']))
 
293
        write_dict_value('DVDREAD_INCLUDE')
 
294
        write_dict_value('DVDREAD_LIBPATH')
274
295
 
275
296
        config.write('\n### Calculated data ###\n')
276
297
        SConscript('Autoconfig')
277
298
 
278
 
        config.write('\nIS_GCC = %r\n' % (user_options_dict['IS_GCC']))
 
299
        config.write('\n')
 
300
        write_dict_value('IS_GCC')
 
301
        write_dict_value('IS_CLANG')
279
302
 
280
303
        config.write('\n# Configuration\n')
281
 
        config.write('CONFIGURATION = %r\n' % (user_options_dict['CONFIGURATION']))
 
304
        write_dict_value('CONFIGURATION')
282
305
 
283
306
        SetLibraries(config, user_options_dict)
284
307
 
 
308
        config.write('\n# Undocumented\n')
 
309
        # this one has only one purpose I can say: just build all
 
310
        # to test/profile SCons speed
 
311
        config.write('TEST_BUILD = %r\n' % (BV.BuildTests))
 
312
 
285
313
        config.close()
286
314
    except:
287
315
        # something went wrong, remove config and exit/raise
291
319
        # raise is better, we'll see the error and its location
292
320
        raise #Exit(1)
293
321
 
294
 
BuildDir(BV.BuildDir, '.', duplicate=0)
 
322
# optimization: checking files as make
 
323
Decider('timestamp-newer')
 
324
BV.VariantDir(BV.BuildDir, '.', duplicate=0)
295
325
 
296
326
def GenerateBaseConfigH(target, source, env):
297
327
    cfg_file = open(target[0].path, 'w')
333
363
# :TODO: remake via gcc' -include option, see "build todos"
334
364
# need for shared_ptr speed (to use quick heap implementation
335
365
# for ref count holding)
336
 
prj_defines  = ['BOOST_SP_USE_QUICK_ALLOCATOR']
 
366
prj_defines = [
 
367
    'BOOST_SP_USE_QUICK_ALLOCATOR',
 
368
    'BOOST_SYSTEM_NO_DEPRECATED' # remove warnings for 'boost::system::posix_category' defined but not used ...
 
369
]
337
370
if not BV.IsDebugCfg():
338
371
    prj_defines += ['NDEBUG']
339
372
 
348
381
 
349
382
# 4 get lib dicts
350
383
GetDict = BV.GetDict
351
 
Export('GetDict')
352
 
 
353
 
mjpeg_dict    = GetDict('mjpegtools')
354
 
gm_dict       = GetDict('GraphicsMagick++')
355
 
gtk2mm_dict   = GetDict('gtkmm-2.4')
 
384
 
 
385
def GetGtkmmDict():
 
386
    dct = GetDict('gtkmm-2.4')
 
387
    if not IsThreadedBuild:
 
388
        # make happy gdb (debugger) by linking with multithreaded libc (in advance),
 
389
        # cause it doesn't like singlethreaded app turns into multithreaded one
 
390
        # in runtime (gtk shared libraries've become multithreaded)
 
391
        dct['LINKFLAGS'] = dct.get('LINKFLAGS', []) + ThreadOpt
 
392
    return dct
 
393
 
 
394
gtk2mm_dict   = GetGtkmmDict()
356
395
libxmlpp_dict = GetDict('libxml++-2.6')
357
396
 
358
397
############################################
371
410
372
411
# mlib
373
412
#
374
 
# Depends on ext: Boost, boost-logging, Boost.Filesystem
 
413
# Depends on ext: Boost, boost-logging, Boost.Filesystem&System
375
414
#
376
415
mlib_env = boost_env.Clone()
377
416
mlib_env.Append(CPPPATH = ['#libs/boost-logging']) #, LIBS = ['pthread']))
378
 
mlib_env.Append( LIBS = ['boost_filesystem'] )
 
417
# libboost_system.a linking is needed only for static builds
 
418
mlib_env.Append( LIBS = ['boost_filesystem', 'boost_system', 'boost_regex'] )
379
419
Export('mlib_env')
380
420
 
381
421
404
444
Export('mdemux_env')
405
445
 
406
446
407
 
# mproject
 
447
# mdemux/tests
 
448
#
 
449
# Depends on: mdemux
 
450
# Depends on ext: Boost.Test
 
451
#
 
452
mdemux_tests_env = mdemux_env.Clone()
 
453
mdemux_tests_env.AppendUnique(**boost_test_dict)
 
454
Export('mdemux_tests_env')
 
455
 
 
456
 
457
# mbase
408
458
#
409
459
# Depends on: mlib
410
460
# Depends on ext: glibmm-2.4, libxml++-2.6
415
465
Export('mbase_env')
416
466
 
417
467
418
 
# mproject/tests
 
468
# mbase/tests
419
469
#
420
470
# Depends on: mlib/tests
421
471
#
423
473
mbase_tests_env.AppendUnique(**boost_test_dict)
424
474
Export('mbase_tests_env')
425
475
 
426
 
#
427
 
# mcomposite
428
 
#
429
 
# Depends on: mlib, mproject
430
 
# Depends on ext: boost, mjpegtools, GraphicsMagick++
431
 
#
432
 
mcomposite_env = mbase_env.Clone()
433
 
mcomposite_env.AppendUnique(**user_options_dict['LIBMPEG2_DICT'])
434
 
mcomposite_env.AppendUnique(**mjpeg_dict)
435
 
mcomposite_env.AppendUnique(**gm_dict)
436
 
Export('mcomposite_env')
437
 
 
438
 
439
 
# mcomposite/tests
440
 
#
441
 
# Depends on: mcomposite, mlib/tests
442
 
#
443
 
mcomposite_tests_env = mcomposite_env.Clone()
444
 
mcomposite_tests_env.AppendUnique(**boost_test_dict)
445
 
Export('mcomposite_tests_env')
446
 
 
447
 
448
 
# mdemux/tests
449
 
#
450
 
# Depends on: mcomposite
451
 
# Depends on ext: Boost.Test
452
 
#
453
 
mdemux_tests_env = mcomposite_env.Clone()
454
 
mdemux_tests_env.AppendUnique(**boost_test_dict)
455
 
mdemux_tests_env.AppendUnique(**user_options_dict['DVDREAD_DICT'])
456
 
Export('mdemux_tests_env')
457
 
 
458
476
459
477
# mgui
460
478
#
464
482
mgui_env = mbase_env.Clone()
465
483
AddMovieDicts(mgui_env)
466
484
mgui_env.AppendUnique(**gtk2mm_dict)
467
 
mgui_env.Append( LIBS = ['boost_regex'] )
468
485
 
469
486
# if BV.Cc == 'como':
470
487
#     mgui_env.Append(CXXFLAGS='--g++')
481
498
mgui_tests_env.AppendUnique(**boost_test_dict)
482
499
Export('mgui_tests_env')
483
500
 
 
501
if BuildMcomposite:
 
502
    #
 
503
    # mcomposite
 
504
    #
 
505
    # Depends on: mlib, mbase
 
506
    # Depends on ext: boost, mjpegtools, GraphicsMagick++
 
507
    #
 
508
    mcomposite_env = mbase_env.Clone()
 
509
    mcomposite_env.AppendUnique(**user_options_dict['LIBMPEG2_DICT'])
 
510
    mcomposite_env.AppendUnique(**GetDict('mjpegtools'))
 
511
    mcomposite_env.AppendUnique(**GetDict('GraphicsMagick++'))
 
512
    Export('mcomposite_env')
 
513
    
 
514
    # 
 
515
    # mcomposite/tests
 
516
    #
 
517
    # Depends on: mcomposite, mlib/tests
 
518
    #
 
519
    mcomposite_tests_env = mcomposite_env.Clone()
 
520
    mcomposite_tests_env.AppendUnique(**boost_test_dict)
 
521
    Export('mcomposite_tests_env')
484
522
 
485
523
#
486
524
# Installation