Combine all boot build stuff in a single scons tool
[senf.git] / senfscons / SENFSCons.py
index e385a94..bdb44f0 100644 (file)
@@ -3,16 +3,13 @@ import SCons.Options, SCons.Environment, SCons.Script.SConscript, SCons.Node.FS
 import SCons.Defaults, SCons.Action
 from SCons.Script import *
 
-def GlobSources(env, exclude=[], subdirs=[]):
+def Glob(env, exclude=[], subdirs=[]):
     testSources = glob.glob("*.test.cc")
     sources = [ x for x in glob.glob("*.cc") if x not in testSources and x not in exclude ]
     for subdir in subdirs:
         testSources += glob.glob(os.path.join(subdir,"*.test.cc"))
         sources += [ x for x in glob.glob(os.path.join(subdir,"*.cc"))
                      if x not in testSources and x not in exclude ]
-    return (sources, testSources)
-
-def GlobIncludes(env, exclude=[], subdirs=[]):
     includes = []
     for d in [ '.' ] + subdirs:
         for f in os.listdir(d):
@@ -22,30 +19,7 @@ def GlobIncludes(env, exclude=[], subdirs=[]):
                and ext not in env['CPP_EXCLUDE_EXTENSIONS'] \
                and p not in exclude:
                 includes.append(p)
-    return includes
-
-def Glob(env, exclude=[], subdirs=[]):
-    return ( GlobSources(env, exclude, subdirs),
-             GlobIncludes(env, exclude, subdirs) )
-
-def Test(env, sources):
-    test=env.BoostUnitTest( target = 'test', source = sources )
-    env.Alias('all_tests', test)
-    return test
-    
-def Objects(env, sources, testSources = None):
-    if type(sources) == type(()):
-        testSources = sources[1]
-        sources = sources[0]
-    if type(sources) is not type([]):
-        sources = [ sources ]
-
-    objects = env.Object(sources)
-
-    if testSources:
-        Test(env, testSources)
-
-    return objects
+    return ( sources, testSources, includes )
 
 def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
     # There is one small problem we need to solve with this builder: The Doxygen builder reads
@@ -57,8 +31,8 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
 
     # Module name is derived from the doxyfile path
     # Utils/Console/Doxyfile -> Utils_Console
-    module = doxyfile.dir.abspath[len(env.Dir('#').abspath)+1:].replace('/','_')
-    if not module : module = "Main"
+    module = doxyfile.dir.get_path(env.Dir('#')).replace('/','_')
+    if module == '.' : module = "Main"
 
     # Rule to generate tagfile
     # (need to exclude the 'clean' case, otherwise we'll have duplicate nodes)
@@ -92,15 +66,11 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
     # (need to exclude the 'clean' case otherwise there are multiple ways to clean the copies)
     if not env.GetOption('clean'):
         if extra_sources:
-            env.Depends(doc,
-                        [ env.CopyToDir( source=source, target=doc[0].dir )
-                          for source in extra_sources ])
+            env.Depends(doc, env.CopyToDir(doc[0].dir, extra_sources))
 
     # Install documentation into DOCINSTALLDIR
     l = len(env.Dir('#').abspath)
-    env.Alias('install_all',
-              env.Command('$DOCINSTALLDIR' + doc[0].dir.abspath[l:], doc[0].dir,
-                          [ SCons.Defaults.Copy('$TARGET','$SOURCE') ]))
+    env.Install(env.Dir('$DOCINSTALLDIR').Dir(doc[0].dir.get_path('#')), doc[0].dir)
 
     # Useful aliases
     env.Alias('all_docs', doc)
@@ -109,36 +79,9 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
 
     return doc
 
-def Lib(env, sources, testSources = None, OBJECTS = []):
-    objects = Objects(env,sources,testSources)
-    env.Append(ALLOBJECTS = objects)
-    return objects
-
-def Object(env, target, sources, testSources = None, OBJECTS = []):
-    objects = Objects(env,sources,testSources)
-    ob = env.Command(target+"${OBJADDSUFFIX}${OBJSUFFIX}", objects+OBJECTS, 
-                     [ "ld -r -o $TARGET $SOURCES" ])
-    env.Default(ob)
-    env.Alias('default', ob)
-    env.Alias('install_all', env.Install("$OBJINSTALLDIR", ob))
-    return ob
-
-def Binary(env, binary, sources, testSources = None, OBJECTS = []):
-    objects = Objects(env, sources, testSources)
-    program = env.Program(target = binary, 
-                          source = objects+OBJECTS,
-                          LIBS   = [ '$LIBSENF$LIBADDSUFFIX' ] + env['LIBS'])
-    env.Default(program)
-    env.Alias('default', program)
-    env.Alias('install_all', env.Install('$BININSTALLDIR', program))
-    return program
-
 def AllIncludesHH(env, headers):
     headers.sort()
     target = env.File("all_includes.hh")
     file(target.abspath,"w").write("".join([ '#include "%s"\n' % f
                                              for f in headers ]))
     env.Clean('all', target)
-
-def PhonyTarget(env, target, action, sources=[]):
-    env.AlwaysBuild(env.Alias(target, sources, env.Action(action)))