2 from SCons.Script import *
5 # Parse LOGLEVELS parameter
6 def parseLogOption(value):
7 stream, area, level = ( x.strip() for x in value.strip().split('|') )
8 stream = ''.join('(%s)' % x for x in stream.split('::') )
9 if area : area = ''.join( '(%s)' % x for x in area.split('::') )
11 return '(( %s,%s,%s ))' % (stream,area,level)
13 def expandLogOption(target, source, env, for_signature):
14 return ' '.join( parseLogOption(x) for x in env.subst('$LOGLEVELS').split() )
16 if env.subst('$LOGLEVELS'):
17 env.Append( expandLogOption=expandLogOption )
18 env.Append( CPPDEFINES = { 'SENF_LOG_CONF': '$expandLogOption' } )
21 ###########################################################################
22 # This looks much more complicated than it is: We do three things here:
23 # a) switch between final or debug options
24 # b) parse the LOGLEVELS parameter into the correct SENF_LOG_CONF syntax
25 # c) check for a local SENF, set options accordingly and update that SENF if needed
27 def SetupForSENF(env):
28 env.Append( LIBS = [ 'senf', 'rt', '$BOOSTREGEXLIB',
29 '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
31 BOOSTREGEXLIB = 'boost_regex',
32 BOOSTIOSTREAMSLIB = 'boost_iostreams',
33 BOOSTSIGNALSLIB = 'boost_signals',
34 BOOSTFSLIB = 'boost_filesystem',
35 CXXFLAGS = [ '-Wno-long-long',
36 '${"$CXXFLAGS_"+(final and "final" or "debug")}',
37 '${profile and ("-g","-pg") or None}' ],
38 LINKFLAGS = [ '${"$LINKFLAGS_"+(final and "final" or "debug")}',
39 '${profile and "-pg" or None}' ],
40 SENF_BUILDOPTS = [ '-j%s' % (env.GetOption('num_jobs') or "1") ],
41 CXXFLAGS_debug = [ '-O0', '-g', '-fno-inline' ],
42 LINKFLAGS_debug = [ '-g', '-rdynamic' ],
45 # Add command-line options: 'LOGLEVELS' and 'final'
47 opts.Add( 'LOGLEVELS', 'Special log levels. Syntax: <stream>|[<area>]|<level> ...',
48 '${"$LOGLEVELS_"+(final and "final" or "debug")}' )
49 opts.Add( BoolOption('final', 'Build final (optimized) build', False) )
50 opts.Add( BoolOption('debug', 'Link in debug symbols', False) )
51 opts.Add( BoolOption('profile', 'Add profile information', False) )
54 env.Help(opts.GenerateHelpText(env))
58 # If we have a symbolic link (or directory) 'senf', we use it as our
60 if os.path.exists('senf'):
61 print "\nUsing SENF in './senf'\n"
62 env.Append( LIBPATH = [ 'senf' ],
63 CPPPATH = [ 'senf/include' ],
64 SENF_BUILDOPTS = [ '${final and "final=1" or None}',
65 '${debug and "debug=1" or None}',
66 '${profile and "profile=1" or None}' ],
67 CPPDEFINES = [ '${not(final) and "SENF_DEBUG" or None}' ] )
71 # env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')])))
73 print '\nUsing global SENF\n'