hmpf. fix for last commit. sry.
[senf.git] / site_scons / senfutil.py
index 331b3a8..30c1f90 100644 (file)
@@ -1,4 +1,5 @@
-import os, os.path, site_tools.Yaptu, types, re, fnmatch
+import os, os.path, site_tools.Yaptu, types, re, fnmatch, sys
+import SCons.Util
 from SCons.Script import *
 
 senfutildir = os.path.dirname(__file__)
@@ -11,6 +12,19 @@ except NameError:
     BoolVariable = BoolOption
 
 ###########################################################################
+extdir = os.path.join(senfutildir, '../senf/Ext')
+sys.path.append(extdir)
+
+for ext in os.listdir(extdir):
+    if not os.path.isdir( os.path.join(extdir, ext)): continue
+    if ext.startswith('.'): continue
+    try:
+        setattr( sys.modules[__name__], ext, 
+                __import__('%s.site_scons' % ext, fromlist=['senfutil']).senfutil )
+    except ImportError:
+        pass
+
+###########################################################################
 
 def loadTools(env):
     global senfutildir
@@ -37,13 +51,16 @@ Special command line parameters:
     try                  : unknv = vars.UnknownVariables()
     except AttributeError: unknv = vars.UnknownOptions()
     env.SetDefault(ARGUMENT_VARIABLES = {})
-    for k,v in unknv.iteritems():
+    for k,v in ARGLIST:
+        if not unknv.has_key(k) : continue
         if k.endswith('+'):
-            env.Append(**{k[:-1]: v})
-            env.Append(ARGUMENT_VARIABLES = {k[:-1]:v})
+            env.Append(**{k[:-1]: [v]})
+            env.Append(ARGUMENT_VARIABLES = {k[:-1]:[v]})
         else:
             env.Replace(**{k: v})
             env.Append(ARGUMENT_VARIABLES = {k:v})
+    if env.get('PARSEFLAGS', None):
+        env.MergeFlags(env['PARSEFLAGS'])
 
 def importProcessEnv(env):
     env.Append( ENV = dict(( (k,v)
@@ -202,15 +219,17 @@ def DefaultOptions(env):
         env,
         BoolVariable('final', 'Build final (optimized) build', False),
         BoolVariable('debug', 'Link in debug symbols', False),
+        BoolVariable('profile', 'compile and link with the profiling enabled option', False),
     )
 
     # Set nice default options
     env.Append(
-        CXXFLAGS         = [ '-Wall', '-Woverloaded-virtual' ],
+        CXXFLAGS         = [ '-Wall', '-Woverloaded-virtual',  "${profile and '-pg' or None}" ],
         CXXFLAGS_final   = [ '-O3' ],
         CXXFLAGS_normal  = [ '-O2', '-g' ],
         CXXFLAGS_debug   = [ '-O0', '-g' ],
 
+        LINKFLAGS        = [ "${profile and '-pg' or None}" ],
         LINKFLAGS_normal = [ '-Wl,-S' ],
         LINKFLAGS_debug  = [ '-g' ],
     )
@@ -232,6 +251,18 @@ def Glob(env, exclude=[], subdirs=[]):
     testSources.sort()
     return (sources, testSources)
 
+def CleanGlob(env, targets, patterns):
+    if env.GetOption('clean'):
+        targets = SCons.Util.flatten(targets)
+        for target in targets:
+            if target in BUILD_TARGETS:
+                patterns = map(str,SCons.Util.flatten(env.subst_list(patterns)))
+                files = [ os.path.join(path,f)
+                          for path, subdirs, files in os.walk('.')
+                          for pattern in patterns
+                          for f in fnmatch.filter(files,pattern) ]
+                return env.Clean(target, files)
+
 tagfiles = None
 
 def Doxygen(env, doxyheader=None, doxyfooter=None, doxycss=None, mydoxyfile=False, senfdoc_path=[],