Move all build env settings from SENFSCons to SConstruct
[senf.git] / senfscons / senfutil.py
index d9f67ed..a2b1ce8 100644 (file)
@@ -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,7 +22,7 @@ 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', 'readline', 'rt', '$BOOSTREGEXLIB',
+    env.Append( LIBS           = [ 'senf', 'rt', '$BOOSTREGEXLIB',
                                    '$BOOSTIOSTREAMSLIB', '$BOOSTSIGNALSLIB',
                                    '$BOOSTFSLIB' ],
                 BOOSTREGEXLIB  = 'boost_regex',
@@ -23,19 +37,11 @@ def SetupForSENF(env):
                 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 area.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: <stream>|[<area>]|<level> ...',
@@ -45,10 +51,6 @@ def SetupForSENF(env):
     opts.Add( BoolOption('profile', 'Add profile information', False) )
     opts.Update(env)
 
-    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
@@ -62,8 +64,8 @@ def SetupForSENF(env):
                                        '${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')])))
+        #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'