2 from SCons.Script import *
4 def parseLogOption(value):
5 stream, area, level = ( x.strip() for x in value.strip().split('|') )
6 stream = ''.join('(%s)' % x for x in stream.split('::') )
7 if area : area = ''.join( '(%s)' % x for x in area.split('::') )
9 return '((%s,%s,%s))' % (stream,area,level)
11 def expandLogOption(target, source, env, for_signature):
12 if env.get('LOGLEVELS'):
13 return [ 'SENF_LOG_CONF="' + ''.join( parseLogOption(x) for x in env.subst('$LOGLEVELS').split() )+'"']
18 ###########################################################################
19 # This looks much more complicated than it is: We do three things here:
20 # a) switch between final or debug options
21 # b) parse the LOGLEVELS parameter into the correct SENF_LOG_CONF syntax
22 # c) check for a local SENF, set options accordingly and update that SENF if needed
24 def SetupForSENF(env):
25 env.Append( LIBS = [ 'senf', 'rt', '$BOOSTREGEXLIB',
26 '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
28 BOOSTREGEXLIB = 'boost_regex',
29 BOOSTIOSTREAMSLIB = 'boost_iostreams',
30 BOOSTSIGNALSLIB = 'boost_signals',
31 BOOSTFSLIB = 'boost_filesystem',
32 CXXFLAGS = [ '-Wno-long-long',
33 '${"$CXXFLAGS_"+(final and "final" or "debug")}',
34 '${profile and ("-g","-pg") or None}' ],
35 LINKFLAGS = [ '${"$LINKFLAGS_"+(final and "final" or "debug")}',
36 '${profile and "-pg" or None}' ],
37 SENF_BUILDOPTS = [ '-j%s' % (env.GetOption('num_jobs') or "1") ],
38 CXXFLAGS_debug = [ '-O0', '-g', '-fno-inline' ],
39 LINKFLAGS_debug = [ '-g', '-rdynamic' ],
41 expandLogOption = expandLogOption,
42 CPPDEFINES = [ '$expandLogOptions' ],
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))
56 # If we have a symbolic link (or directory) 'senf', we use it as our
58 if os.path.exists('senf'):
59 print "\nUsing SENF in './senf'\n"
60 env.Append( LIBPATH = [ 'senf' ],
62 SENF_BUILDOPTS = [ '${final and "final=1" or None}',
63 '${debug and "debug=1" or None}',
64 '${profile and "profile=1" or None}' ],
65 CPPDEFINES = [ '${not(final) and "SENF_DEBUG" or None}' ] )
69 # env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')])))
70 elif os.path.exists('../senf'):
71 print "\nUsing SENF in '../senf'\n"
72 env.Append( LIBPATH = [ '../senf' ],
73 CPPPATH = [ '../senf/include' ],
74 SENF_BUILDOPTS = [ '${final and "final=1" or None}',
75 '${debug and "debug=1" or None}',
76 '${profile and "profile=1" or None}' ],
77 CPPDEFINES = [ '${not(final) and "SENF_DEBUG" or None}' ] )
81 # env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')])))
83 print '\nUsing global SENF\n'