Compatibility workarounds for SCons 0.97 (hardy)
[senf.git] / site_scons / senfutil.py
index 61fb998..1cb88e3 100644 (file)
@@ -1,6 +1,13 @@
 import os.path
 from SCons.Script import *
 
+# Fix for SCons 0.97 compatibility
+try:
+    Variables
+except NameError: 
+    Variables = Options
+    BoolVariable = BoolOption
+
 def parseLogOption(value):
     stream, area, level = ( x.strip() for x in value.strip().split('|') )
     stream = ''.join('(%s)' % x for x in stream.split('::') )
@@ -22,6 +29,30 @@ class BuildTypeOptions:
         type = env['final'] and "final" or env['debug'] and "debug" or "normal"
         return env[self._var + "_" + type]
 
+def parseArguments(env, *defs):
+    vars = Variables(args=ARGUMENTS)
+    for d in defs : vars.Add(d)
+    vars.Update(env)
+    env.Help("""
+Any construction environment variable may be set from the scons
+command line (see SConstruct file and SCons documentation for a list
+of variables) using
+
+   VARNAME=value    Assign new value  
+   VARNAME+=value   Append value at end
+
+Special command line parameters:
+""")
+    env.Help(vars.GenerateHelpText(env))
+    try                  : unknv = vars.UnknownVariables()
+    except AttributeError: unknv = vars.UnknownOptions()
+    for k,v in unknv.iteritems():
+        if k.endswith('+'):
+            env.Append(**{k[:-1]: v})
+        else:
+            env.Replace(**{k: v})
+
+
 ###########################################################################
 # This looks much more complicated than it is: We do three things here:
 # a) switch between final or debug options
@@ -73,14 +104,11 @@ def SetupForSENF(env, senf_paths = []):
         )
 
     # Interpret command line options
-    opts = Variables(ARGUMENTS)
-    opts.Add( 'LOGLEVELS', 'Special log levels. Syntax: <stream>|[<area>]|<level> ...',
-              '${"$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.Update(env)
-    env.Replace(**dict(opts.UnknownVariables()))
-    env.Help(opts.GenerateHelpText(env))
+    parseArguments(
+        env, 
+        BoolVariable('final', 'Build final (optimized) build', False),
+        BoolVariable('debug', 'Link in debug symbols', False),
+    )
 
     # If we have a symbolic link (or directory) 'senf', we use it as our
     # senf repository
@@ -115,4 +143,5 @@ def DefaultOptions(env):
         CXXFLAGS_debug   = [ '$CXXFLAGS_normal' ],
 
         LINKFLAGS_normal = [ '-Wl,-S' ],
+        LINKFLAGS_debug  = [ '-g' ],
     )