summaryrefslogtreecommitdiffstats
path: root/common/waf.py
diff options
context:
space:
mode:
authorAmar Takhar <amar@rtems.org>2016-01-18 00:05:50 -0500
committerAmar Takhar <verm@darkbeer.org>2016-05-02 20:51:24 -0400
commit3a717592a9d13f7668c7fd3f9638adcc197d873d (patch)
tree6501d65ad6faba8e19be7f3c8d34f66536a70ec6 /common/waf.py
parentFix rtemsconfig building. (diff)
downloadrtems-docs-3a717592a9d13f7668c7fd3f9638adcc197d873d.tar.bz2
Rework how conf.py is handled.
Needed to switch due to increasing complexity.
Diffstat (limited to 'common/waf.py')
-rw-r--r--common/waf.py57
1 files changed, 44 insertions, 13 deletions
diff --git a/common/waf.py b/common/waf.py
index bd5243a..5437ab3 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -1,21 +1,13 @@
import sys, os
+
+
def cmd_configure(ctx):
ctx.find_program("sphinx-build", var="SPHINX_BUILD")
-def cmd_build(ctx, sub, source_dir="."):
+def cmd_build(ctx, conf_dir=".", source_dir="."):
srcnode = ctx.srcnode.abspath()
- file_conf = ctx.path.parent.find_node("common/conf.py")
- tg = ctx(
- features = "subst",
- source = file_conf,
- target = file_conf.name
- )
-
- tg.__dict__.update(sub)
-
-
# Copy resources.
for dir in ["_static", "_templates"]:
files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir)
@@ -29,9 +21,48 @@ def cmd_build(ctx, sub, source_dir="."):
)
ctx(
- rule = "${SPHINX_BUILD} -b html -c build -j %s -d build/doctrees %s build/html" % (ctx.options.jobs, source_dir),
+ rule = "${SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir),
cwd = ctx.path.abspath(),
- source = ctx.path.ant_glob('**/*.rst') + ctx.path.ant_glob('conf.py'),
+ source = ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'),
target = ctx.path.find_or_declare('html/index.html')
)
+def cmd_options_path(ctx):
+ ctx.add_option('--rtems-path-py', type='string', help="Path to py/ in RTEMS.")
+
+
+def cmd_configure_path(ctx):
+ if not ctx.options.rtems_path_py:
+ ctx.fatal("--rtems-path-py is required")
+
+ ctx.env.RTEMS_PATH = ctx.options.rtems_path_py
+
+ cmd_configure(ctx)
+
+
+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")