~jheiss/galera/galera

1 by Teemu Ollakka
Initial import
1
###################################################################
2
#
130 by Teemu Ollakka
References lp:1036997 - synced with svn r2843
3
# Copyright (C) 2010-2012 Codership Oy <info@codership.com>
1 by Teemu Ollakka
Initial import
4
#
5
# SCons build script to build galera libraries
6
#
7
# Script structure:
8
# - Help message
9
# - Default parameters
10
# - Read commandline options
11
# - Set up and configure default build environment
12
# - Set up and configure check unit test build environment
13
# - Run root SConscript with variant_dir
14
#
15
####################################################################
16
17
import os
18
import platform
153 by Alexey Yurchenko
References
19
import string
1 by Teemu Ollakka
Initial import
20
21
sysname = os.uname()[0].lower()
22
machine = platform.machine()
23
print 'Host: ' + sysname + ' ' + machine
24
25
#
26
# Print Help
27
#
28
29
Help('''
30
Build targets:  build tests check install all
31
Default target: all
32
33
Commandline Options:
153 by Alexey Yurchenko
References
34
    debug=n             debug build with optimization level n
35
    arch=str            target architecture [i686|x86_64]
36
    build_dir=dir       build directory, default: '.'
37
    boost=[0|1]         disable or enable boost libraries
38
    boost_pool=[0|1]    use or not use boost pool allocator
39
    revno=XXXX          source code revision number
40
    bpostatic=path      a path to static libboost_program_options.a
41
    extra_sysroot=path  a path to extra development environment (Fink, Homebrew, MacPorts, MinGW)
1 by Teemu Ollakka
Initial import
42
''')
128 by Alex Yurchenko
Fixes lp:988100. Final 2.1 RC.
43
# bpostatic option added on Percona request
1 by Teemu Ollakka
Initial import
44
45
#
46
# Default params
47
#
48
49
build_target = 'all'
50
51
# Optimization level
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
52
opt_flags    = ' -g -O3 -DNDEBUG'
1 by Teemu Ollakka
Initial import
53
54
# Architecture (defaults to build host type)
55
compile_arch = ''
56
link_arch    = ''
57
58
# Build directory
59
build_dir    = ''
60
61
62
#
63
# Read commandline options
64
#
65
66
build_dir = ARGUMENTS.get('build_dir', '')
67
68
# Debug/dbug flags
69
debug = ARGUMENTS.get('debug', -1)
70
dbug  = ARGUMENTS.get('dbug', False)
71
154 by Alexey Yurchenko
References lp:1217947 - synced with SVN 3243
72
debug_lvl = int(debug)
73
if debug_lvl >= 0 and debug_lvl < 3:
74
    opt_flags = ' -g -O%d -fno-inline' % debug_lvl
1 by Teemu Ollakka
Initial import
75
    dbug = True
154 by Alexey Yurchenko
References lp:1217947 - synced with SVN 3243
76
elif debug_lvl == 3:
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
77
    opt_flags = ' -g -O3'
1 by Teemu Ollakka
Initial import
78
79
if dbug:
80
    opt_flags = opt_flags + ' -DGU_DBUG_ON'
81
82
# Target arch
83
arch = ARGUMENTS.get('arch', machine)
84
print 'Target: ' + sysname + ' ' + arch
85
86
if arch == 'i386' or arch == 'i686':
168 by Alexey Yurchenko
References lp:1240924 - added regression tests for lp:587170, removed stale wsrep_local_bf_aborts. Synced with SVN r 3367.
87
    #compile_arch = ' -m32 -march=i686 -msse4'
88
    compile_arch = ' -m32 -march=i686 '
153 by Alexey Yurchenko
References
89
    link_arth    = compile_arch
90
    if sysname != 'darwin' and sysname != 'freebsd':
91
        link_arch    = compile_arch + ' -Wl,-melf_i386'
1 by Teemu Ollakka
Initial import
92
elif arch == 'x86_64' or arch == 'amd64':
168 by Alexey Yurchenko
References lp:1240924 - added regression tests for lp:587170, removed stale wsrep_local_bf_aborts. Synced with SVN r 3367.
93
    #compile_arch = ' -m64 -msse4'
94
    compile_arch = ' -m64 '
153 by Alexey Yurchenko
References
95
    link_arth    = compile_arch
96
    if sysname != 'darwin' and sysname != 'freebsd':
97
        link_arch    = compile_arch + ' -Wl,-melf_x86_64'
130 by Teemu Ollakka
References lp:1036997 - synced with svn r2843
98
elif arch == 'ppc64':
99
    compile_arch = ' -mtune=native'
100
    link_arch    = ''
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
101
elif sysname == 'sunos':
102
    compile_arch = ''
103
    link_arch    = ''
1 by Teemu Ollakka
Initial import
104
else:
144 by Alexey Yurchenko
References lp:1093054 - merged with SVN r3000. Bugfixes for version 2.4
105
    compile_arch = ''
106
    link_arch    = ''
1 by Teemu Ollakka
Initial import
107
140 by Alexey Yurchenko
References lp:1093054 - synced with SVN r2918: added boost_pool option to disable using of boost::fast_pool_allocator with newer boosts (>1.49)
108
boost      = int(ARGUMENTS.get('boost', 1))
160 by Teemu Ollakka
References lp:1217947 - fixes to get 5.6 debian builds done
109
boost_pool = int(ARGUMENTS.get('boost_pool', 0))
140 by Alexey Yurchenko
References lp:1093054 - synced with SVN r2918: added boost_pool option to disable using of boost::fast_pool_allocator with newer boosts (>1.49)
110
ssl        = int(ARGUMENTS.get('ssl', 1))
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
111
tests      = int(ARGUMENTS.get('tests', 1))
112
strict_build_flags = int(ARGUMENTS.get('strict_build_flags', 1))
113
168 by Alexey Yurchenko
References lp:1240924 - added regression tests for lp:587170, removed stale wsrep_local_bf_aborts. Synced with SVN r 3367.
114
GALERA_VER = ARGUMENTS.get('version', '3.1')
64.1.2 by Alex Yurchenko
References lp:859856 - synced with SVN 0.8 branch r2387
115
GALERA_REV = ARGUMENTS.get('revno', 'XXXX')
116
# export to any module that might have use of those
117
Export('GALERA_VER', 'GALERA_REV')
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
118
print 'Signature: version: ' + GALERA_VER + ', revision: ' + GALERA_REV
1 by Teemu Ollakka
Initial import
119
153 by Alexey Yurchenko
References
120
LIBBOOST_PROGRAM_OPTIONS_A = ARGUMENTS.get('bpostatic', '')
121
LIBBOOST_SYSTEM_A = string.replace(LIBBOOST_PROGRAM_OPTIONS_A, 'boost_program_options', 'boost_system')
128 by Alex Yurchenko
Fixes lp:988100. Final 2.1 RC.
122
1 by Teemu Ollakka
Initial import
123
#
124
# Set up and export default build environment
125
#
126
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
127
env = Environment(ENV = {'PATH' : os.environ['PATH'], 'HOME' : os.environ['HOME']})
1 by Teemu Ollakka
Initial import
128
129
# Set up environment for ccache and distcc
154 by Alexey Yurchenko
References lp:1217947 - synced with SVN 3243
130
#env['ENV']['HOME']          = os.environ['HOME']
1 by Teemu Ollakka
Initial import
131
#env['ENV']['DISTCC_HOSTS']  = os.environ['DISTCC_HOSTS']
132
#env['ENV']['CCACHE_PREFIX'] = os.environ['CCACHE_PREFIX']
153 by Alexey Yurchenko
References
133
if 'CCACHE_DIR' in os.environ:
134
    env['ENV']['CCACHE_DIR'] = os.environ['CCACHE_DIR']
135
if 'CCACHE_CPP2' in os.environ:
136
    env['ENV']['CCACHE_CPP2'] = os.environ['CCACHE_CPP2']
1 by Teemu Ollakka
Initial import
137
138
# Set CC and CXX compilers
139
cc = os.getenv('CC', 'default')
140
if cc != 'default':
141
    env.Replace(CC = cc)
142
cxx = os.getenv('CXX', 'default')
143
if cxx != 'default':
144
    env.Replace(CXX = cxx)
145
link = os.getenv('LINK', 'default')
146
if link != 'default':
147
    env.Replace(LINK = link)
53 by Alex Yurchenko
Synced with SVN branch 0.8 r2261
148
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
149
# Initialize CPPFLAGS and LIBPATH from environment to get user preferences
150
env.Replace(CPPFLAGS = os.getenv('CPPFLAGS', ''))
151
env.Replace(LIBPATH = [os.getenv('LIBPATH', '')])
152
153 by Alexey Yurchenko
References
153
# Set -pthread flag explicitly to make sure that pthreads are
154
# enabled on all platforms.
155
env.Append(CPPFLAGS = ' -pthread')
156
157
# Freebsd ports are installed under /usr/local
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
158
if sysname == 'freebsd' or sysname == 'sunos':
159
    env.Append(LIBPATH  = ['/usr/local/lib'])
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
160
    env.Append(CPPFLAGS = ' -I/usr/local/include ')
161
if sysname == 'sunos':
162
   env.Replace(SHLINKFLAGS = '-shared ')
1 by Teemu Ollakka
Initial import
163
153 by Alexey Yurchenko
References
164
# Add paths is extra_sysroot argument was specified
165
extra_sysroot = ARGUMENTS.get('extra_sysroot', '')
166
if sysname == 'darwin' and extra_sysroot == '':
167
    # common developer environments and paths
168
    if os.system('which -s port') == 0 and os.path.isfile('/opt/local/bin/port'):
169
        extra_sysroot = '/opt/local'
170
    elif os.system('which -s brew') == 0 and os.path.isfile('/usr/local/bin/brew'):
171
        extra_sysroot = '/usr/local'
172
    elif os.system('which -s fink') == 0 and os.path.isfile('/sw/bin/fink'):
173
        extra_sysroot = '/sw'
174
if extra_sysroot != '':
175
    env.Append(LIBPATH = [extra_sysroot + '/lib'])
176
    env.Append(CPPFLAGS = ' -I' + extra_sysroot + '/include')
177
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
178
# print env.Dump()
1 by Teemu Ollakka
Initial import
179
#
180
# Set up build and link paths
153 by Alexey Yurchenko
References
181
#
1 by Teemu Ollakka
Initial import
182
183
# Include paths
156 by Alexey Yurchenko
References lp:1129512 - better compatibility with the previous exclusive logic: don't try to use any other nodes if at least one in the least can eventually become available.
184
env.Append(CPPPATH = Split('''#
87.1.16 by Alex Yurchenko
References lp:915499, lp:907071 - synced with SVN r2671
185
                              #/asio
156 by Alexey Yurchenko
References lp:1129512 - better compatibility with the previous exclusive logic: don't try to use any other nodes if at least one in the least can eventually become available.
186
                              #/common
87.1.16 by Alex Yurchenko
References lp:915499, lp:907071 - synced with SVN r2671
187
                              #/galerautils/src
188
                              #/gcomm/src
189
                              #/gcomm/src/gcomm
190
                              #/gcache/src
191
                              #/gcs/src
192
                              #/wsdb/src
193
                              #/galera/src
194
                           '''))
1 by Teemu Ollakka
Initial import
195
196
# Library paths
197
#env.Append(LIBPATH = Split('''#/galerautils/src
87.1.16 by Alex Yurchenko
References lp:915499, lp:907071 - synced with SVN r2671
198
#                              #/gcomm/src
199
#                              #/gcs/src
200
#                              #/wsdb/src
201
#                              #/galera/src
202
#                           '''))
1 by Teemu Ollakka
Initial import
203
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
204
# Preprocessor flags
153 by Alexey Yurchenko
References
205
if sysname != 'sunos' and sysname != 'darwin' and sysname != 'freebsd':
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
206
    env.Append(CPPFLAGS = ' -D_XOPEN_SOURCE=600')
153 by Alexey Yurchenko
References
207
if sysname == 'sunos':
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
208
    env.Append(CPPFLAGS = ' -D__EXTENSIONS__')
209
env.Append(CPPFLAGS = ' -DHAVE_COMMON_H')
210
1 by Teemu Ollakka
Initial import
211
# Common C/CXX flags
212
# These should be kept minimal as they are appended after C/CXX specific flags
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
213
env.Replace(CCFLAGS = opt_flags + compile_arch +
153 by Alexey Yurchenko
References
214
                      ' -Wall -Wextra -Wno-unused-parameter')
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
215
216
# C-specific flags
217
env.Replace(CFLAGS = ' -std=c99 -fno-strict-aliasing -pipe')
218
219
# CXX-specific flags
220
# Note: not all 3rd-party libs like '-Wold-style-cast -Weffc++'
221
#       adding those after checks
222
env.Replace(CXXFLAGS = ' -Wno-long-long -Wno-deprecated -ansi')
223
if sysname != 'sunos':
224
    env.Append(CXXFLAGS = ' -pipe')
225
1 by Teemu Ollakka
Initial import
226
227
# Linker flags
228
# TODO: enable '-Wl,--warn-common -Wl,--fatal-warnings' after warnings from
229
# static linking have beed addressed
230
#
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
231
env.Append(LINKFLAGS = link_arch)
1 by Teemu Ollakka
Initial import
232
233
#
234
# Check required headers and libraries (autoconf functionality)
235
#
236
237
conf = Configure(env)
238
239
# System headers and libraries
240
241
if not conf.CheckLib('pthread'):
242
    print 'Error: pthread library not found'
243
    Exit(1)
244
153 by Alexey Yurchenko
References
245
if sysname != 'darwin':
246
    if not conf.CheckLib('rt'):
247
        print 'Error: rt library not found'
248
        Exit(1)
249
250
if sysname == 'freebsd':
251
    if not conf.CheckLib('execinfo'):
252
        print 'Error: execinfo library not found'
253
        Exit(1)
1 by Teemu Ollakka
Initial import
254
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
255
if sysname == 'sunos':
256
    if not conf.CheckLib('socket'):
257
        print 'Error: socket library not found'
258
        Exit(1)
259
    if not conf.CheckLib('crypto'):
260
        print 'Error: crypto library not found'
261
        Exit(1)
262
    if not conf.CheckLib('nsl'):
263
        print 'Error: nsl library not found'
264
        Exit(1)
265
1 by Teemu Ollakka
Initial import
266
if conf.CheckHeader('sys/epoll.h'):
267
    conf.env.Append(CPPFLAGS = ' -DGALERA_USE_GU_NETWORK')
268
269
if conf.CheckHeader('byteswap.h'):
270
    conf.env.Append(CPPFLAGS = ' -DHAVE_BYTESWAP_H')
271
272
if conf.CheckHeader('endian.h'):
273
    conf.env.Append(CPPFLAGS = ' -DHAVE_ENDIAN_H')
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
274
elif conf.CheckHeader('sys/endian.h'):
1 by Teemu Ollakka
Initial import
275
    conf.env.Append(CPPFLAGS = ' -DHAVE_SYS_ENDIAN_H')
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
276
elif conf.CheckHeader('sys/byteorder.h'):
277
    conf.env.Append(CPPFLAGS = ' -DHAVE_SYS_BYTEORDER_H')
153 by Alexey Yurchenko
References
278
elif sysname != 'darwin':
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
279
    print 'can\'t find byte order information'
280
    Exit(1)
1 by Teemu Ollakka
Initial import
281
282
# Additional C headers and libraries
283
284
# boost headers
285
286
if not conf.CheckCXXHeader('boost/shared_ptr.hpp'):
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
287
    print 'boost/shared_ptr.hpp not found or not usable'
288
    Exit(1)
1 by Teemu Ollakka
Initial import
289
conf.env.Append(CPPFLAGS = ' -DHAVE_BOOST_SHARED_PTR_HPP')
290
162 by Alexey Yurchenko
References lp:1229107, lp:1201893, lp:1078759
291
if conf.CheckCXXHeader('unordered_map'):
292
    conf.env.Append(CPPFLAGS = ' -DHAVE_UNORDERED_MAP')
293
elif conf.CheckCXXHeader('tr1/unordered_map'):
134 by Alexey Yurchenko
References lp:1036997 - synced with SVN r2880
294
    conf.env.Append(CPPFLAGS = ' -DHAVE_TR1_UNORDERED_MAP')
58 by Alex Yurchenko
References lp:828648 - synced with SVN branch 0.8 r2321
295
else:
134 by Alexey Yurchenko
References lp:1036997 - synced with SVN r2880
296
    if conf.CheckCXXHeader('boost/unordered_map.hpp'):
297
        conf.env.Append(CPPFLAGS = ' -DHAVE_BOOST_UNORDERED_MAP_HPP')
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
298
    else:
1 by Teemu Ollakka
Initial import
299
        print 'no unordered map header available'
300
        Exit(1)
301
302
# pool allocator
303
if boost == 1:
153 by Alexey Yurchenko
References
304
    # Default suffix for boost multi-threaded libraries
305
    if sysname == 'darwin':
306
        boost_library_suffix = '-mt'
307
    else:
308
        boost_library_suffix = ''
309
    if sysname == 'darwin' and extra_sysroot != '':
310
        boost_library_path = extra_sysroot + '/lib'
311
    else:
312
        boost_library_path = ''
1 by Teemu Ollakka
Initial import
313
    # Use nanosecond time precision
314
    conf.env.Append(CPPFLAGS = ' -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG=1')
153 by Alexey Yurchenko
References
315
    # Common procedure to find boost static library
316
    boost_libpaths = [ boost_library_path, '/usr/local/lib', '/usr/local/lib64', '/usr/lib', '/usr/lib64' ]
317
    def check_boost_library(libBaseName, header, configuredLibPath, autoadd = 1):
318
        libName = libBaseName + boost_library_suffix
319
        if configuredLibPath != '' and not os.path.isfile(configuredLibPath):
320
            print "Error: file '%s' does not exist" % configuredLibPath
321
            Exit(1)
322
        if configuredLibPath == '':
323
           for libpath in boost_libpaths:
324
               libname = libpath + '/lib%s.a' % libName
325
               if os.path.isfile(libname):
326
                   configuredLibPath = libname
327
                   break
328
        if configuredLibPath != '':
329
            if not conf.CheckCXXHeader(header):
330
                print "Error: header '%s' does not exist" % header
331
                Exit (1)
332
            if autoadd:
333
                conf.env.Append(LIBS=File(configuredLibPath))
334
            else:
335
                return File(configuredLibPath)
336
        else:
337
            if not conf.CheckLibWithHeader(libs=[libName],
338
                                           header=header,
339
                                           language='CXX',
340
                                           autoadd=autoadd):
341
                print 'Error: library %s does not exist' % libName
342
                Exit (1)
343
            return [libName]
1 by Teemu Ollakka
Initial import
344
    # Required boost headers/libraries
345
    #
140 by Alexey Yurchenko
References lp:1093054 - synced with SVN r2918: added boost_pool option to disable using of boost::fast_pool_allocator with newer boosts (>1.49)
346
    if boost_pool == 1:
347
        if conf.CheckCXXHeader('boost/pool/pool_alloc.hpp'):
348
            print 'Using boost pool alloc'
349
            conf.env.Append(CPPFLAGS = ' -DGALERA_USE_BOOST_POOL_ALLOC=1')
144 by Alexey Yurchenko
References lp:1093054 - merged with SVN r3000. Bugfixes for version 2.4
350
            # due to a bug in boost >= 1.50 we need to link with boost_system
351
            # - should be a noop with no boost_pool.
153 by Alexey Yurchenko
References
352
            if sysname == 'darwin':
353
                if conf.CheckLib('boost_system' + boost_library_suffix):
354
                    conf.env.Append(LIBS=['boost_system' + boost_library_suffix])
355
            check_boost_library('boost_system',
356
                                'boost/system/error_code.hpp',
357
                                LIBBOOST_SYSTEM_A)
140 by Alexey Yurchenko
References lp:1093054 - synced with SVN r2918: added boost_pool option to disable using of boost::fast_pool_allocator with newer boosts (>1.49)
358
        else:
359
            print 'Error: boost/pool/pool_alloc.hpp not found or not usable'
360
            Exit(1)
156 by Alexey Yurchenko
References lp:1129512 - better compatibility with the previous exclusive logic: don't try to use any other nodes if at least one in the least can eventually become available.
361
153 by Alexey Yurchenko
References
362
    libboost_program_options = check_boost_library('boost_program_options',
363
                                                   'boost/program_options.hpp',
364
                                                   LIBBOOST_PROGRAM_OPTIONS_A,
365
                                                   autoadd = 0)
1 by Teemu Ollakka
Initial import
366
else:
367
    print 'Not using boost'
368
58 by Alex Yurchenko
References lp:828648 - synced with SVN branch 0.8 r2321
369
# asio
370
if conf.CheckCXXHeader('asio.hpp'):
371
    conf.env.Append(CPPFLAGS = ' -DHAVE_ASIO_HPP')
372
else:
373
    print 'asio headers not found or not usable'
374
    Exit(1)
375
376
# asio/ssl
377
if ssl == 1:
378
    if conf.CheckCXXHeader('asio/ssl.hpp'):
379
        conf.env.Append(CPPFLAGS = ' -DHAVE_ASIO_SSL_HPP')
380
    else:
381
        print 'ssl support required but asio/ssl.hpp not found or not usable'
382
        print 'compile with ssl=0 or check that openssl devel headers are usable'
383
        Exit(1)
384
    if conf.CheckLib('ssl'):
121 by Alex Yurchenko
Synced with SVN r2733. Fixes lp:942924.
385
        conf.CheckLib('crypto')
58 by Alex Yurchenko
References lp:828648 - synced with SVN branch 0.8 r2321
386
    else:
387
        print 'ssl support required but openssl library not found'
388
        print 'compile with ssl=0 or check that openssl library is usable'
389
        Exit(1)
390
124 by Alex Yurchenko
References lp:957425 - synced with SVN r2745. Solaris x86 build support.
391
# these will be used only with our softaware
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
392
if strict_build_flags == 1:
153 by Alexey Yurchenko
References
393
   conf.env.Append(CPPFLAGS = ' -Werror ')
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
394
   conf.env.Append(CCFLAGS  = ' -pedantic')
395
   conf.env.Append(CXXFLAGS = ' -Weffc++ -Wold-style-cast')
1 by Teemu Ollakka
Initial import
396
397
env = conf.Finish()
168 by Alexey Yurchenko
References lp:1240924 - added regression tests for lp:587170, removed stale wsrep_local_bf_aborts. Synced with SVN r 3367.
398
Export('arch', 'env', 'sysname', 'libboost_program_options')
153 by Alexey Yurchenko
References
399
400
#
401
# Actions to build .dSYM directories, containing debugging information for Darwin
402
#
403
404
if sysname == 'darwin' and int(debug) >= 0 and int(debug) < 3:
405
    env['LINKCOM'] = [env['LINKCOM'], 'dsymutil $TARGET']
406
    env['SHLINKCOM'] = [env['SHLINKCOM'], 'dsymutil $TARGET']
1 by Teemu Ollakka
Initial import
407
408
#
409
# Set up and export environment for check unit tests
410
#
411
412
# Clone base from default environment
413
check_env = env.Clone()
414
415
conf = Configure(check_env)
416
417
# Check header and library
418
419
if not conf.CheckHeader('check.h'):
420
    print 'Error: check header file not found or not usable'
421
    Exit(1)
422
423
if not conf.CheckLib('check'):
424
    print 'Error: check library not found or not usable'
425
    Exit(1)
426
427
conf.Finish()
428
429
#
430
# this follows recipes from http://www.scons.org/wiki/UnitTests
431
#
432
433
def builder_unit_test(target, source, env):
434
    app = str(source[0].abspath)
435
    if os.spawnl(os.P_WAIT, app, app)==0:
436
        open(str(target[0]),'w').write("PASSED\n")
437
    else:
438
        return 1
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
439
440
def builder_unit_test_dummy(target, source, env):
441
    return 0
442
1 by Teemu Ollakka
Initial import
443
# Create a builder for tests
152 by Alexey Yurchenko
Synced with SVN r3115. This fixes:
444
if tests == 1:
445
    bld = Builder(action = builder_unit_test)
446
else:
447
    bld = Builder(action = builder_unit_test_dummy) 
1 by Teemu Ollakka
Initial import
448
check_env.Append(BUILDERS = {'Test' :  bld})
449
450
Export('check_env')
451
452
#
453
# Run root SConscript with variant_dir
454
#
455
SConscript('SConscript', variant_dir=build_dir)