X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senfscons%2FSENFSCons.py;h=771d4fadad223a6172cf51bcedbd21d2061db273;hb=d0006132bfcb3ab442cf66b600ed3fad36f1ac2c;hp=7308c0e75c370099910db6540cc30d5811022c4f;hpb=62464586315edf52fbcc613acb4a8a7e919fd8e2;p=senf.git diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index 7308c0e..771d4fa 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -1,4 +1,5 @@ -import os.path, SCons.Options, SCons.Environment, SCons.Script.SConscript, glob +import os.path, glob +import SCons.Options, SCons.Environment, SCons.Script.SConscript, SCons.Node.FS, SCons.Defaults SCONS_TOOLS = [ "Doxygen", @@ -8,7 +9,7 @@ SCONS_TOOLS = [ opts = None finalizers = [] -basedir = os.path.split(__file__)[0] +basedir = os.path.abspath(os.path.split(__file__)[0]) def InitOpts(): global opts @@ -117,12 +118,7 @@ def StandardTargets(env): env.Depends(all, '.') def GlobalTargets(env): - command = "find -name .svn -prune -o \( -name '*.hh' -o -name '*.ih' -o -name '*.cc' -o -name '*.cci' -o -name '*.ct' -o -name '*.cti' -o -name '*.mpp' \) -print " \ - "| xargs -r awk -F '//' '/%s/{print ARGV[ARGIND] \":\" FNR \":\" $2}' > $TARGET" - env.AlwaysBuild(env.Command('TODOS',None,[ command % 'TODO' ])) - env.AlwaysBuild(env.Command('FIXMES',None,[ command % ' FIXME' ])) - env.AlwaysBuild(env.Command('BUGS',None,[ command % 'BUG' ] )) - env.Alias('status',[ 'TODOS', 'FIXMES', 'BUGS' ]) + pass def LibPath(lib): return '$LOCALLIBDIR/lib%s.a' % lib @@ -151,21 +147,102 @@ def Objects(env, sources, testSources = None, LIBS = []): return objects def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []): - docs = env.Doxygen(doxyfile) - # The last target is the (optional) tagfile - if os.path.basename(str(docs[-1])) != '.stamp': + # ARGHHH !!! without the [:] we are changing the target list + # ||| WITHIN THE DOXYGEN BUILDER + docs = env.Doxygen(doxyfile)[:] + xmlnode = None + htmlnode = None + tagnode = None + for doc in docs: + if isinstance(doc,SCons.Node.FS.Dir): continue + if doc.name == 'xml.stamp' : xmlnode = doc + if doc.name == 'html.stamp' : htmlnode = doc + if os.path.splitext(doc.name)[1] == '.stamp' : continue # ignore other file stamps + # otherwise it must be the tag file + tagnode = doc + + if tagnode: # Postprocess the tag file to remove the (broken) namespace # references env.AddPostAction( docs, - env.Action([ "xsltproc -o ${TARGETS[-1]}.temp %s ${TARGETS[-1]}" - % os.path.join(basedir,"tagmunge.xsl"), - "mv ${TARGETS[-1]}.temp ${TARGETS[-1]}" ])) - env.Clean(docs[-1],"$TARGET.temp") + env.Action("xsltproc --nonet -o %(target)s.temp %(template)s %(target)s && mv %(target)s.temp %(target)s" + % { 'target': tagnode.abspath, + 'template': os.path.join(basedir,"tagmunge.xsl") })) + + if htmlnode and env.get('DOXY_HTML_XSL'): + xslfile = env.File(env['DOXY_HTML_XSL']) + env.AddPostAction( + docs, + env.Action(("for html in %s/*.html; do " + + " echo $$html;" + + " sed -e 's/id=\"current\"/class=\"current\"/' $${html}" + + " | tidy -ascii -q --show-warnings no --fix-uri no" + + " | xsltproc --nonet --html -o $${html}.new %s - 2>&1" + + " | grep '^-'" + + " | grep -v 'ID .* already defined';" + + " mv $${html}.new $${html}; " + + "done") + % (htmlnode.dir.abspath, xslfile.abspath))) + for doc in docs: + env.Depends(doc,xslfile) + + if xmlnode: + xrefs = [] + for type in env.get("DOXY_XREF_TYPES",[ "bug", "todo" ]): + xref = os.path.join(xmlnode.dir.abspath,type+".xml") + xref_pp = env.Command(xref+'i', [ xref, os.path.join(basedir,'xrefxtract.xslt'), xmlnode ], + [ "test -s $SOURCE && xsltproc -o $TARGET" + + " --stringparam module $MODULE" + + " --stringparam type $TYPE" + + " ${SOURCES[1]} $SOURCE || touch $TARGET" ], + MODULE = xmlnode.dir.dir.dir.name, + TYPE = type) + env.SideEffect(xref, xmlnode) + env.AddPreAction(docs, "rm -f %s" % (xref,)) + env.AddPostAction(docs, "test -r %s || touch %s" % (xref,xref)) + xrefs.extend(xref_pp) + docs.extend(xrefs) + env.Depends(docs,extra_sources) - env.Alias('all_docs', *docs) + for doc in docs : + env.Alias('all_docs', doc) + env.Clean('all_docs', doc) + env.Clean('all', doc) return docs +def DoxyXRef(env, docs=None, + HTML_HEADER = None, HTML_FOOTER = None, + TITLE = "Cross-reference of action points"): + if docs is None: + docs = env.Alias('all_docs')[0].sources + xrefs = [ doc for doc in docs if os.path.splitext(doc.name)[1] == ".xmli" ] + xref = env.Command("doc/html/xref.xml", xrefs, + [ "echo -e '\\n' >$TARGET", + "cat $SOURCES >> $TARGET", + "echo '' >>$TARGET" ]) + + # Lastly we create the html file + sources = [ xref, "%s/xrefhtml.xslt" % basedir ] + if HTML_HEADER : sources.append(HTML_HEADER) + if HTML_FOOTER : sources.append(HTML_FOOTER) + + commands = [] + if HTML_HEADER: + commands.append( + "sed -e 's/\\$$title/$TITLE/g' -e 's/\\$$projectname/Overview/g' ${SOURCES[2]} > $TARGET") + commands.append("xsltproc --stringparam title '$TITLE' ${SOURCES[1]} $SOURCE >> $TARGET") + if HTML_FOOTER: + commands.append( + "sed -e 's/\\$$title/$TITLE/g' -e 's/\\$$projectname/Overview/g' ${SOURCES[%d]} >> $TARGET" + % (HTML_HEADER and 3 or 2)) + + xref = env.Command("doc/html/xref.html", sources, commands, + TITLE = TITLE) + + env.Alias('all_docs',xref) + return xref + def Lib(env, library, sources, testSources = None, LIBS = []): objects = Objects(env,sources,testSources,LIBS=LIBS) lib = None