-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",
opts = None
finalizers = []
-basedir = os.path.split(__file__)[0]
+basedir = os.path.abspath(os.path.split(__file__)[0])
def InitOpts():
global opts
def StandardTargets(env):
all = env.Alias('all')
- env.Clean(all, [ '.sconsign', '.sconf_temp', 'config.log', 'ChangeLog.bak', '.clean'
- ] + glob.glob("*~"))
+ env.Clean(all, [ '.sconsign', '.sconf_temp', 'config.log' ])
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
return objects
-def DoxyGlob(exclude=[]):
- sources = [ f
- for ext in ("cci", "ct", "cti", "h", "hh", "ih", "mmc", "dox")
- for f in glob.glob("*."+ext)
- if f not in exclude ]
- return sources
-
-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':
+def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
+ # 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 " +
+ "xsltproc --nonet --html -o $${html}.new %s $${html} && 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 '<?xml version=\"1.0\"?>\\n<xref>' >$TARGET",
+ "cat $SOURCES >> $TARGET",
+ "echo '</xref>' >>$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