diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 20:22:32 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 20:22:32 (GMT) |
commit | 335d3d25e07ddcf7c00ba3b2550858a2374dd3db (patch) | |
tree | 26a5d95818e3e12ac2811903fe815044fa7f6d73 /BuildTools/DocBook/SCons/FO.py | |
parent | 3afa4f741c26360245dc313bc368f508b26a6b96 (diff) | |
download | swift-contrib-335d3d25e07ddcf7c00ba3b2550858a2374dd3db.zip swift-contrib-335d3d25e07ddcf7c00ba3b2550858a2374dd3db.tar.bz2 |
Moved DocBook module.
Diffstat (limited to 'BuildTools/DocBook/SCons/FO.py')
-rw-r--r-- | BuildTools/DocBook/SCons/FO.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/BuildTools/DocBook/SCons/FO.py b/BuildTools/DocBook/SCons/FO.py new file mode 100644 index 0000000..c7596d6 --- /dev/null +++ b/BuildTools/DocBook/SCons/FO.py @@ -0,0 +1,45 @@ +import SCons.Util +import xml.dom.minidom, re + +################################################################################ +# XSL-FO builder +################################################################################ + +def generate(env) : + def generate_actions(source, target, env, for_signature) : + if len(env["FOCFG"]) > 0 : + cmd = "$FO -c $FOCFG $FOFLAGS $SOURCE $TARGET" + else : + cmd = "$FO $FOFLAGS $SOURCE $TARGET" + return SCons.Action.Action(cmd, cmdstr = "$FOCOMSTR") + + def modify_sources(target, source, env) : + if len(env["FOCFG"]) > 0 : + source.append(env["FOCFG"]) + return target, source + + def scan_fo(node, env, path) : + dependencies = set() + try : + document = xml.dom.minidom.parseString(node.get_contents()) + except xml.parsers.expat.ExpatError: + return [] + for include in document.getElementsByTagNameNS("http://www.w3.org/1999/XSL/Format", "external-graphic") : + m = re.match("url\((.*)\)", include.getAttribute("src")) + if m : + dependencies.add(m.group(1)) + return list(dependencies) + + env["FO"] = "fop" + env["FOFLAGS"] = "" + env["FOCFG"] = "" + env["BUILDERS"]["FO"] = SCons.Builder.Builder( + generator = generate_actions, + emitter = modify_sources, + source_scanner = SCons.Scanner.Scanner(function = scan_fo, skeys = [".fo"]), + suffix = ".pdf", + src_suffix = ".fo" + ) + +def exists(env) : + return True |