[rtems-docs commit] waf: Fix linkcheck and spell commands.

Chris Johns chrisj at rtems.org
Sun Mar 26 23:28:51 UTC 2017


Module:    rtems-docs
Branch:    master
Commit:    02635812f63bba63e679b55737f6feffaec3f7a0
Changeset: http://git.rtems.org/rtems-docs/commit/?id=02635812f63bba63e679b55737f6feffaec3f7a0

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Mar 27 10:27:29 2017 +1100

waf: Fix linkcheck and spell commands.

Clean up and remove code that is not needed.

Fix sphinx-build quoting to work on Windows.

---

 common/waf.py | 64 ++++++++++++++++++-----------------------------------------
 wscript       |  8 ++++++++
 2 files changed, 27 insertions(+), 45 deletions(-)

diff --git a/common/waf.py b/common/waf.py
index ad7900b..7845f05 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -21,6 +21,15 @@ def build_date():
     d = '%2d%s' % (now.day, s)
     return '%s %s %s' % (d, m, y)
 
+def version_cmdline(ctx):
+    return "-Drelease='%s' -Dversion='%s'" % (ctx.env.VERSION, ctx.env.VERSION)
+
+def sphinx_cmdline(ctx, build_type, conf_dir, doctrees, source_dir, output_dir):
+    rule = "${BIN_SPHINX_BUILD} %s -b %s -c %s %s -d %s %s %s" % \
+           (sphinx_verbose(ctx), build_type, conf_dir, version_cmdline(ctx),
+            doctrees, source_dir, output_dir)
+    return rule
+
 def cmd_spell(ctx):
     from waflib import Options
     from sys import argv
@@ -48,14 +57,14 @@ def cmd_spell(ctx):
         print("running:", cmd)
         call(cmd)
 
-
-def cmd_linkcheck(ctx, conf_dir=".", source_dir="."):
-    ctx_rule = "${BIN_SPHINX_BUILD} -b linkcheck -c %s -j %d " + \
-               "-d build/doctrees %s build/linkcheck" % (conf_dir,
-                                                         ctx.options.jobs,
-                                                             source_dir)
+def cmd_linkcheck(ctx):
+    conf_dir = ctx.path.get_src()
+    source_dir = ctx.path.get_src()
+    buildtype = 'linkcheck'
+    build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
+    rule = sphinx_cmdline(ctx, buildtype, conf_dir, doctrees, source_dir, output_dir)
     ctx(
-        rule   = ctx_rule,
+        rule   = rule,
         cwd    = ctx.path.abspath(),
         source = ctx.path.ant_glob('**/*.rst'),
         target = "linkcheck/output.txt"
@@ -104,9 +113,6 @@ def build_dir_setup(ctx, buildtype):
     doctrees = os.path.join(os.path.dirname(output_dir), 'doctrees', buildtype)
     return build_dir, output_node, output_dir, doctrees
 
-def version_cmdline(ctx):
-    return "-Drelease='%s' -Dversion='%s'" % (ctx.env.VERSION, ctx.env.VERSION)
-
 def pdf_resources(ctx, buildtype):
     packages_base = ctx.path.parent.find_dir('common/latex')
     if packages_base is None:
@@ -228,12 +234,6 @@ def cmd_configure(ctx):
                 ctx.fatal("Node inliner is required install with 'npm install -g inliner' " +
                           "(https://github.com/remy/inliner)")
 
-def sphinx_cmdline(ctx, build_type, conf_dir, doctrees, source_dir, output_dir):
-    rule = "${BIN_SPHINX_BUILD} %s -b %s -c %s %s -d %s %s %s" % \
-           (sphinx_verbose(ctx), build_type, conf_dir, version_cmdline(ctx),
-            doctrees, source_dir, output_dir)
-    return rule
-
 def doc_pdf(ctx, source_dir, conf_dir):
     buildtype = 'latex'
     build_dir, output_node, output_dir, doctrees = build_dir_setup(ctx, buildtype)
@@ -322,8 +322,9 @@ def doc_html(ctx, conf_dir, source_dir):
                       relative_trick = True,
                       quiet = True)
 
-def cmd_build(ctx, conf_dir = ".", source_dir = "."):
-    srcnode = ctx.srcnode.abspath()
+def cmd_build(ctx):
+    conf_dir = ctx.path.get_src()
+    source_dir = ctx.path.get_src()
 
     if ctx.env.BUILD_PDF == 'yes':
         doc_pdf(ctx, source_dir, conf_dir)
@@ -445,30 +446,3 @@ def xml_catalogue(ctx, building):
     catnode.write(cat.toprettyxml(indent = ' ' * 2, newl = os.linesep))
 
     cat.unlink()
-
-CONF_FRAG = """
-sys.path.append(os.path.abspath('../../common/'))
-sys.path.append('%s')
-templates_path = ['_templates']
-html_static_path = ['_static']
-"""
-
-# XXX: fix this ugly hack.  No time to waste on it.
-def cmd_build_path(ctx):
-    def run(task):
-
-        with open("conf.py") as fp:
-            conf = "import sys, os\nsys.path.append(os.path.abspath('../../common/'))\n"
-            conf += fp.read()
-
-        task.inputs[0].abspath()
-        task.outputs[0].write(conf + (CONF_FRAG % ctx.env.RTEMS_PATH))
-
-    ctx(
-        rule   = run,
-        source = [ctx.path.parent.find_node("common/conf.py"),
-                  ctx.path.find_node("./conf.py")],
-        target = ctx.path.get_bld().make_node('conf.py')
-    )
-
-    cmd_build(ctx, conf_dir = "build", source_dir = "build")
diff --git a/wscript b/wscript
index 28ebec5..2e83afe 100644
--- a/wscript
+++ b/wscript
@@ -79,3 +79,11 @@ def build(ctx):
 def install(ctx):
     for b in building:
         ctx.recurse(b)
+
+def cmd_spell(ctx):
+    for b in building:
+        ctx.recurse(b)
+
+def cmd_linkcheck(ctx):
+    for b in building:
+        ctx.recurse(b)



More information about the vc mailing list