X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senfscons%2Fsenfutil.py;h=4aae4da2e8cfbc99d4476a7200d23d95cfd7835a;hb=87204d50de0c429f265aec817bc9efd9af816082;hp=a0954a8b2e31f842dd5174bb1067b3b1b31baa1b;hpb=f2cc6f8a4ca99301f9f26156803e541ec2dff66b;p=senf.git diff --git a/senfscons/senfutil.py b/senfscons/senfutil.py index a0954a8..4aae4da 100644 --- a/senfscons/senfutil.py +++ b/senfscons/senfutil.py @@ -1,6 +1,20 @@ import os.path from SCons.Script import * +def parseLogOption(value): + stream, area, level = ( x.strip() for x in value.strip().split('|') ) + stream = ''.join('(%s)' % x for x in stream.split('::') ) + if area : area = ''.join( '(%s)' % x for x in area.split('::') ) + else : area = '(_)' + return '((%s,%s,%s))' % (stream,area,level) + +def expandLogOption(target, source, env, for_signature): + if env.get('LOGLEVELS'): + return [ 'SENF_LOG_CONF="' + ''.join( parseLogOption(x) for x in env.subst('$LOGLEVELS').split() )+'"'] + else: + return [] + + ########################################################################### # This looks much more complicated than it is: We do three things here: # a) switch between final or debug options @@ -8,39 +22,35 @@ from SCons.Script import * # c) check for a local SENF, set options accordingly and update that SENF if needed def SetupForSENF(env): - env.Append( LIBS = [ 'senf', 'iberty', 'boost_regex', 'boost_iostreams' ], + env.Append( LIBS = [ 'senf', 'rt', '$BOOSTREGEXLIB', + '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB', + '$BOOSTFSLIB' ], + BOOSTREGEXLIB = 'boost_regex', + BOOSTIOSTREAMSLIB = 'boost_iostreams', + BOOSTSIGNALSLIB = 'boost_signals', + BOOSTFSLIB = 'boost_filesystem', CXXFLAGS = [ '-Wno-long-long', - '${"$CXXFLAGS_"+(final and "final" or "debug")}' ], - LINKFLAGS = [ '${"$LINKFLAGS_"+(final and "final" or "debug")}' ], + '${"$CXXFLAGS_"+(final and "final" or "debug")}', + '${profile and ("-g","-pg") or None}' ], + LINKFLAGS = [ '${"$LINKFLAGS_"+(final and "final" or "debug")}', + '${profile and "-pg" or None}' ], SENF_BUILDOPTS = [ '-j%s' % (env.GetOption('num_jobs') or "1") ], CXXFLAGS_debug = [ '-O0', '-g', '-fno-inline' ], LINKFLAGS_debug = [ '-g', '-rdynamic' ], + + expandLogOption = expandLogOption, + CPPDEFINES = [ '$expandLogOptions' ], ) - # Parse LOGLEVELS parameter - def parseLogOption(value): - stream, area, level = ( x.strip() for x in value.strip().split('|') ) - stream = ''.join('(%s)' % x for x in stream.split('::') ) - if area : area = ''.join( '(%s)' % x for x in elts[1].split('::') ) - else : area = '(_)' - return '(( %s,%s,%s ))' % (stream,area,level) - - def expandLogOption(target, source, env, for_signature): - return ' '.join( parseLogOption(x) for x in env.subst('$LOGLEVELS').split() ) - # Add command-line options: 'LOGLEVELS' and 'final' opts = Options() opts.Add( 'LOGLEVELS', 'Special log levels. Syntax: |[]| ...', '${"$LOGLEVELS_"+(final and "final" or "debug")}' ) opts.Add( BoolOption('final', 'Build final (optimized) build', False) ) + opts.Add( BoolOption('debug', 'Link in debug symbols', False) ) + opts.Add( BoolOption('profile', 'Add profile information', False) ) opts.Update(env) - print env.subst('$LOGLEVELS') - - if env.subst('$LOGLEVELS'): - env.Append( expandLogOption=expandLogOption ) - env.Append( CPPDEFINES = { 'SENF_LOG_CONF': '$expandLogOption' } ) - env.Help(opts.GenerateHelpText(env)) # If we have a symbolic link (or directory) 'senf', we use it as our @@ -49,11 +59,25 @@ def SetupForSENF(env): print "\nUsing SENF in './senf'\n" env.Append( LIBPATH = [ 'senf' ], CPPPATH = [ 'senf/include' ], - SENF_BUILDOPTS = [ '${final and "final=1" or None}' ], + SENF_BUILDOPTS = [ '${final and "final=1" or None}', + '${debug and "debug=1" or None}', + '${profile and "profile=1" or None}' ], + CPPDEFINES = [ '${not(final) and "SENF_DEBUG" or None}' ] ) + + #env.Default( + # env.AlwaysBuild( + # env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')]))) + elif os.path.exists('../senf'): + print "\nUsing SENF in '../senf'\n" + env.Append( LIBPATH = [ '../senf' ], + CPPPATH = [ '../senf/include' ], + SENF_BUILDOPTS = [ '${final and "final=1" or None}', + '${debug and "debug=1" or None}', + '${profile and "profile=1" or None}' ], CPPDEFINES = [ '${not(final) and "SENF_DEBUG" or None}' ] ) - env.Default( - env.AlwaysBuild( - env.Command('senf/libsenf.a', [], [ 'scons -C senf $SENF_BUILDOPTS libsenf.a' ]))) + #env.Default( + # env.AlwaysBuild( + # env.Command('senf/libsenf.a', [], [ 'scons -C %s $SENF_BUILDOPTS libsenf.a' % os.path.realpath('senf')]))) else: print '\nUsing global SENF\n'