source: rtems-docs/common/waf.py @ d389819

4.115
Last change on this file since d389819 was 3a71759, checked in by Amar Takhar <amar@…>, on 01/18/16 at 05:05:50

Rework how conf.py is handled.

Needed to switch due to increasing complexity.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import sys, os
2
3
4
5def cmd_configure(ctx):
6        ctx.find_program("sphinx-build", var="SPHINX_BUILD")
7
8def cmd_build(ctx, conf_dir=".", source_dir="."):
9        srcnode = ctx.srcnode.abspath()
10
11        # Copy resources.
12        for dir in ["_static", "_templates"]:
13                files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir)
14                ctx.path.get_bld().make_node(dir).mkdir() # dirs
15
16                ctx(
17                        features    = "subst",
18                        is_copy     = True,
19                        source      = files,
20                        target      = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files]
21                )
22
23        ctx(
24                rule   = "${SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir),
25                cwd     = ctx.path.abspath(),
26                source =  ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'),
27                target = ctx.path.find_or_declare('html/index.html')
28        )
29
30def cmd_options_path(ctx):
31        ctx.add_option('--rtems-path-py', type='string', help="Path to py/ in RTEMS.")
32
33
34def cmd_configure_path(ctx):
35        if not ctx.options.rtems_path_py:
36                ctx.fatal("--rtems-path-py is required")
37
38        ctx.env.RTEMS_PATH = ctx.options.rtems_path_py
39
40        cmd_configure(ctx)
41
42
43CONF_FRAG = """
44sys.path.append(os.path.abspath('../../common/'))
45sys.path.append('%s')
46templates_path = ['_templates']
47html_static_path = ['_static']
48"""
49
50
51# XXX: fix this ugly hack.  No time to waste on it.
52def cmd_build_path(ctx):
53        def run(task):
54
55                with open("conf.py") as fp:
56                        conf = "import sys, os\nsys.path.append(os.path.abspath('../../common/'))\n"
57                        conf += fp.read()
58
59                task.inputs[0].abspath()
60                task.outputs[0].write(conf + (CONF_FRAG % ctx.env.RTEMS_PATH))
61
62        ctx(
63                rule   = run,
64                source = [ctx.path.parent.find_node("common/conf.py"), ctx.path.find_node("./conf.py")],
65                target = ctx.path.get_bld().make_node('conf.py')
66    )
67
68        cmd_build(ctx, conf_dir="build", source_dir="build")
Note: See TracBrowser for help on using the repository browser.