summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-04-25 19:43:29 (GMT)
committerTobias Markmann <tm@ayena.de>2016-04-25 19:43:29 (GMT)
commit857791adda753a0f94da8317bbc019378b1f09bd (patch)
tree96aa2e4d863d50888a16527f9fbb38712e97d8ee /BuildTools/DocBook/SCons
parentb58ad7f4b01623a8807b8c268208bd9c8496f4e2 (diff)
downloadswift-857791adda753a0f94da8317bbc019378b1f09bd.zip
swift-857791adda753a0f94da8317bbc019378b1f09bd.tar.bz2
Convert hard tabs to four spaces in all our SConscript/*.py files
Test-Information: Test that it still builds and unit test pass on OS X 10.11.4. Change-Id: I2eb4a0b707991aee553db36a8cd1ae28b813acab
Diffstat (limited to 'BuildTools/DocBook/SCons')
-rw-r--r--BuildTools/DocBook/SCons/DocBook.py162
-rw-r--r--BuildTools/DocBook/SCons/FO.py64
-rw-r--r--BuildTools/DocBook/SCons/XSLT.py106
3 files changed, 166 insertions, 166 deletions
diff --git a/BuildTools/DocBook/SCons/DocBook.py b/BuildTools/DocBook/SCons/DocBook.py
index 7641b65..ffb0bfc 100644
--- a/BuildTools/DocBook/SCons/DocBook.py
+++ b/BuildTools/DocBook/SCons/DocBook.py
@@ -6,100 +6,100 @@ import SCons.Util, SCons.Action
import xml.dom.minidom, re, os.path, sys
def generate(env) :
- # Location of stylesheets and catalogs
- docbook_dir = "#/BuildTools/DocBook"
- docbook_xsl_style_dir = env.Dir(docbook_dir + "/Stylesheets").abspath
- docbook_xml_catalog = env.File("catalog.xml").abspath
- if "DOCBOOK_XML_DIR" in env :
- docbook_xml_dir = env.Dir("$DOCBOOK_XML_DIR").abspath
- else :
- docbook_xml_dir = env.Dir("#/3rdParty/DocBook/XML").abspath
- if "DOCBOOK_XSL_DIR" in env :
- docbook_xsl_dir = env.Dir("$DOCBOOK_XSL_DIR").abspath
- else :
- docbook_xsl_dir = env.Dir("#/3rdParty/DocBook/XSL").abspath
- fop_fonts_dir = env.Dir(docbook_dir + "/Fonts").abspath
-
- # Generates a catalog from paths to external tools
- def buildCatalog(target, source, env) :
- catalog = """<?xml version='1.0'?>
+ # Location of stylesheets and catalogs
+ docbook_dir = "#/BuildTools/DocBook"
+ docbook_xsl_style_dir = env.Dir(docbook_dir + "/Stylesheets").abspath
+ docbook_xml_catalog = env.File("catalog.xml").abspath
+ if "DOCBOOK_XML_DIR" in env :
+ docbook_xml_dir = env.Dir("$DOCBOOK_XML_DIR").abspath
+ else :
+ docbook_xml_dir = env.Dir("#/3rdParty/DocBook/XML").abspath
+ if "DOCBOOK_XSL_DIR" in env :
+ docbook_xsl_dir = env.Dir("$DOCBOOK_XSL_DIR").abspath
+ else :
+ docbook_xsl_dir = env.Dir("#/3rdParty/DocBook/XSL").abspath
+ fop_fonts_dir = env.Dir(docbook_dir + "/Fonts").abspath
+
+ # Generates a catalog from paths to external tools
+ def buildCatalog(target, source, env) :
+ catalog = """<?xml version='1.0'?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public">
- <rewriteSystem
- systemIdStartString="http://www.oasis-open.org/docbook/xml/4.5/"
- rewritePrefix="%(docbook_xml_dir)s/" />
- <rewriteSystem
- systemIdStartString="docbook-xsl:/"
- rewritePrefix="%(docbook_xsl_dir)s/" />
+ <rewriteSystem
+ systemIdStartString="http://www.oasis-open.org/docbook/xml/4.5/"
+ rewritePrefix="%(docbook_xml_dir)s/" />
+ <rewriteSystem
+ systemIdStartString="docbook-xsl:/"
+ rewritePrefix="%(docbook_xsl_dir)s/" />
</catalog>"""
- docbook_xml_dir = source[0].get_contents()
- docbook_xsl_dir = source[1].get_contents()
- if env["PLATFORM"] == "win32" :
- docbook_xml_dir = docbook_xml_dir.replace("\\","/")
- docbook_xsl_dir = docbook_xsl_dir.replace("\\","/")
- file = open(target[0].abspath, "w")
- file.write(catalog % {
- "docbook_xml_dir" : docbook_xml_dir,
- "docbook_xsl_dir" : docbook_xsl_dir,
- })
- file.close()
-
- # Generates a FOP config file
- def buildFopConfig(target, source, env) :
- fopcfg = """<fop version=\"1.0\">
- <renderers>
- <renderer mime=\"application/pdf\">
- <fonts>
- <directory recursive=\"true\">%(fonts_dir)s</directory>
- </fonts>
- </renderer>
- </renderers>
+ docbook_xml_dir = source[0].get_contents()
+ docbook_xsl_dir = source[1].get_contents()
+ if env["PLATFORM"] == "win32" :
+ docbook_xml_dir = docbook_xml_dir.replace("\\","/")
+ docbook_xsl_dir = docbook_xsl_dir.replace("\\","/")
+ file = open(target[0].abspath, "w")
+ file.write(catalog % {
+ "docbook_xml_dir" : docbook_xml_dir,
+ "docbook_xsl_dir" : docbook_xsl_dir,
+ })
+ file.close()
+
+ # Generates a FOP config file
+ def buildFopConfig(target, source, env) :
+ fopcfg = """<fop version=\"1.0\">
+ <renderers>
+ <renderer mime=\"application/pdf\">
+ <fonts>
+ <directory recursive=\"true\">%(fonts_dir)s</directory>
+ </fonts>
+ </renderer>
+ </renderers>
</fop>"""
- file = open(target[0].abspath, "w")
- file.write(fopcfg % {
- "fonts_dir" : source[0].get_contents()
- })
- file.close()
+ file = open(target[0].abspath, "w")
+ file.write(fopcfg % {
+ "fonts_dir" : source[0].get_contents()
+ })
+ file.close()
- # Builds a DocBook file
- def buildDocBook(env, source) :
- db_env = env.Clone()
- db_env["XMLCATALOGS"] = [docbook_xml_catalog]
- db_env["ENV"].update({"OS" : os.environ.get("OS", "")})
+ # Builds a DocBook file
+ def buildDocBook(env, source) :
+ db_env = env.Clone()
+ db_env["XMLCATALOGS"] = [docbook_xml_catalog]
+ db_env["ENV"].update({"OS" : os.environ.get("OS", "")})
- db_env["XMLLINT"] = env.WhereIs("xmllint")
- db_env["XSLT"] = env.WhereIs("xsltproc")
- db_env["FO"] = env.WhereIs("fop")
+ db_env["XMLLINT"] = env.WhereIs("xmllint")
+ db_env["XSLT"] = env.WhereIs("xsltproc")
+ db_env["FO"] = env.WhereIs("fop")
- if not db_env["XMLLINT"] or not db_env["XSLT"] :
- return
+ if not db_env["XMLLINT"] or not db_env["XSLT"] :
+ return
- # PDF generation
- if db_env["FO"] :
- fo = db_env.XSLT(os.path.splitext(source)[0] + ".fo", source,
- XSLTSTYLESHEET = db_env["DOCBOOK_XSL_FO"])
- pdf = db_env.FO(fo)
+ # PDF generation
+ if db_env["FO"] :
+ fo = db_env.XSLT(os.path.splitext(source)[0] + ".fo", source,
+ XSLTSTYLESHEET = db_env["DOCBOOK_XSL_FO"])
+ pdf = db_env.FO(fo)
- # HTML generation
- db_env.XSLT(os.path.splitext(source)[0] + ".html", source,
- XSLTSTYLESHEET = db_env["DOCBOOK_XSL_HTML"])
+ # HTML generation
+ db_env.XSLT(os.path.splitext(source)[0] + ".html", source,
+ XSLTSTYLESHEET = db_env["DOCBOOK_XSL_HTML"])
- # Import tools
- env.Tool("FO", toolpath = [docbook_dir + "/SCons"])
- env.Tool("XSLT", toolpath = [docbook_dir + "/SCons"])
+ # Import tools
+ env.Tool("FO", toolpath = [docbook_dir + "/SCons"])
+ env.Tool("XSLT", toolpath = [docbook_dir + "/SCons"])
- # Catalog file generation
- env.Command("catalog.xml", [env.Value(docbook_xml_dir), env.Value(docbook_xsl_dir)], SCons.Action.Action(buildCatalog, cmdstr = "$GENCOMSTR"))
+ # Catalog file generation
+ env.Command("catalog.xml", [env.Value(docbook_xml_dir), env.Value(docbook_xsl_dir)], SCons.Action.Action(buildCatalog, cmdstr = "$GENCOMSTR"))
- # FO config file generation
- env["FOCFG"] = env.File("fop.cfg").abspath
- env.Command("fop.cfg", [env.Value(fop_fonts_dir)], SCons.Action.Action(buildFopConfig, cmdstr = "$GENCOMSTR"))
+ # FO config file generation
+ env["FOCFG"] = env.File("fop.cfg").abspath
+ env.Command("fop.cfg", [env.Value(fop_fonts_dir)], SCons.Action.Action(buildFopConfig, cmdstr = "$GENCOMSTR"))
- # DocBook stylesheets
- env["DOCBOOK_XSL_FO"] = docbook_xsl_style_dir + "/fo/docbook.xsl"
- env["DOCBOOK_XSL_HTML"] = docbook_xsl_style_dir + "/html/docbook.xsl"
- env.AddMethod(buildDocBook, "DocBook")
+ # DocBook stylesheets
+ env["DOCBOOK_XSL_FO"] = docbook_xsl_style_dir + "/fo/docbook.xsl"
+ env["DOCBOOK_XSL_HTML"] = docbook_xsl_style_dir + "/html/docbook.xsl"
+ env.AddMethod(buildDocBook, "DocBook")
def exists(env) :
- return True
+ return True
diff --git a/BuildTools/DocBook/SCons/FO.py b/BuildTools/DocBook/SCons/FO.py
index a4079d7..c1c5614 100644
--- a/BuildTools/DocBook/SCons/FO.py
+++ b/BuildTools/DocBook/SCons/FO.py
@@ -6,40 +6,40 @@ import xml.dom.minidom, re
################################################################################
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 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 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)
+ 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"
- )
+ 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
+ return True
diff --git a/BuildTools/DocBook/SCons/XSLT.py b/BuildTools/DocBook/SCons/XSLT.py
index 825f129..38e36c5 100644
--- a/BuildTools/DocBook/SCons/XSLT.py
+++ b/BuildTools/DocBook/SCons/XSLT.py
@@ -6,58 +6,58 @@ import xml.dom.minidom, os, os.path
################################################################################
def generate(env) :
- def generate_actions(source, target, env, for_signature) :
- if not env.has_key("XSLTSTYLESHEET") :
- raise SCons.Errors.UserError, "The XSLTSTYLESHEET construction variable must be defined"
-
- # Process the XML catalog files
- # FIXME: It's probably not clean to do an ENV assignment globally
- env["ENV"]["XML_CATALOG_FILES"] = " ".join(env.get("XMLCATALOGS", ""))
-
- # Build the XMLLint command
- xmllintcmd = ["$XMLLINT", "--nonet", "--xinclude", "--postvalid", "--noout", "$SOURCE"]
-
- # Build the XSLT command
- xsltcmd = ["$XSLT", "--nonet", "--xinclude"]
- for (param, value) in env["XSLTPARAMS"] :
- xsltcmd += ["--stringparam", param, value]
- xsltcmd += ["-o", "$TARGET", "$XSLTSTYLESHEET", "$SOURCE"]
-
- return [
- SCons.Action.Action([xmllintcmd], cmdstr = "$XMLLINTCOMSTR"),
- SCons.Action.Action([xsltcmd], cmdstr = "$XSLTCOMSTR")]
-
- def modify_sources(target, source, env) :
- if len(env["FOCFG"]) > 0 :
- source.append(env["FOCFG"])
- source.append(env.get("XMLCATALOGS", []))
- return target, source
-
- def scan_xml(node, env, path) :
- dependencies = set()
- nodes = [node]
- while len(nodes) > 0 :
- node = nodes.pop()
- try :
- document = xml.dom.minidom.parseString(node.get_contents())
- except xml.parsers.expat.ExpatError:
- continue
- for include in document.getElementsByTagNameNS("http://www.w3.org/2001/XInclude", "include") :
- include_file = include.getAttribute("href")
- dependencies.add(include_file)
- if include.getAttribute("parse") != "text" :
- nodes.append(env.File(include_file))
- return list(dependencies)
-
- env["XMLLINT"] = "xmllint"
- env["XSLT"] = "xsltproc"
- env["XSLTPARAMS"] = []
- env["BUILDERS"]["XSLT"] = SCons.Builder.Builder(
- generator = generate_actions,
- emitter = modify_sources,
- source_scanner = SCons.Scanner.Scanner(function = scan_xml),
- src_suffix = ".xml"
- )
+ def generate_actions(source, target, env, for_signature) :
+ if not env.has_key("XSLTSTYLESHEET") :
+ raise SCons.Errors.UserError, "The XSLTSTYLESHEET construction variable must be defined"
+
+ # Process the XML catalog files
+ # FIXME: It's probably not clean to do an ENV assignment globally
+ env["ENV"]["XML_CATALOG_FILES"] = " ".join(env.get("XMLCATALOGS", ""))
+
+ # Build the XMLLint command
+ xmllintcmd = ["$XMLLINT", "--nonet", "--xinclude", "--postvalid", "--noout", "$SOURCE"]
+
+ # Build the XSLT command
+ xsltcmd = ["$XSLT", "--nonet", "--xinclude"]
+ for (param, value) in env["XSLTPARAMS"] :
+ xsltcmd += ["--stringparam", param, value]
+ xsltcmd += ["-o", "$TARGET", "$XSLTSTYLESHEET", "$SOURCE"]
+
+ return [
+ SCons.Action.Action([xmllintcmd], cmdstr = "$XMLLINTCOMSTR"),
+ SCons.Action.Action([xsltcmd], cmdstr = "$XSLTCOMSTR")]
+
+ def modify_sources(target, source, env) :
+ if len(env["FOCFG"]) > 0 :
+ source.append(env["FOCFG"])
+ source.append(env.get("XMLCATALOGS", []))
+ return target, source
+
+ def scan_xml(node, env, path) :
+ dependencies = set()
+ nodes = [node]
+ while len(nodes) > 0 :
+ node = nodes.pop()
+ try :
+ document = xml.dom.minidom.parseString(node.get_contents())
+ except xml.parsers.expat.ExpatError:
+ continue
+ for include in document.getElementsByTagNameNS("http://www.w3.org/2001/XInclude", "include") :
+ include_file = include.getAttribute("href")
+ dependencies.add(include_file)
+ if include.getAttribute("parse") != "text" :
+ nodes.append(env.File(include_file))
+ return list(dependencies)
+
+ env["XMLLINT"] = "xmllint"
+ env["XSLT"] = "xsltproc"
+ env["XSLTPARAMS"] = []
+ env["BUILDERS"]["XSLT"] = SCons.Builder.Builder(
+ generator = generate_actions,
+ emitter = modify_sources,
+ source_scanner = SCons.Scanner.Scanner(function = scan_xml),
+ src_suffix = ".xml"
+ )
def exists(env) :
- return True
+ return True