source: rtems-docs/wscript

Last change on this file was 1599d99, checked in by Chris Johns <chrisj@…>, on Feb 27, 2019 at 10:16:57 PM

waf: Fix python3 issues.

  • Found after updating to FreeBSD-12.0 which defaults to Python3.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1#
2# RTEMS Project Documentation
3#
4
5import sys
6import os.path
7
8import waflib
9
10#
11# Set Python's system path to `common` from the top level so the
12# conf.py modules in subdirectories can be found. See xml_catalogue in
13# common/waf.py.
14#
15sys.path.append(os.path.abspath('common'))
16
17from common import waf as docs_waf
18from common import version
19
20#
21# Branch version
22#
23rtems_major_version = '5'
24
25#
26# The documents to build.
27#
28build_all = ['user',
29             'c-user',
30             'bsp-howto',
31             'posix-users',
32             'posix-compliance',
33             'eng',
34             'filesystem',
35             'networking',
36             'shell',
37             'cpu-supplement',
38             'develenv',
39             'eclipse']
40
41building = build_all
42
43def options(opt):
44    docs_waf.cmd_options(opt)
45
46def configure(conf):
47    conf.find_program('git')
48    for b in building:
49        conf.recurse(b)
50    conf.env['BUILD_FROM_TOP'] = 'yes'
51
52def catalogue(ctx):
53    docs_waf.xml_catalogue(ctx, building)
54
55def coverpage_js(ctx):
56    js = None
57    xml = None
58    for f in ctx.inputs:
59        if f.abspath().endswith('.js'):
60            with open(f.abspath()) as i:
61                js = i.read()
62        elif f.abspath().endswith('.xml'):
63            with open(f.abspath()) as i:
64                xml = i.read()
65    xml = xml.replace('\n', ' \\\n');
66    with open(ctx.outputs[0].abspath(), 'w') as o:
67        o.write(js.replace('@CATALOGUE', xml))
68
69def index_html(ctx):
70    html = ''
71    year = ctx.env.DATE.split()[2]
72    for f in ctx.inputs:
73        if f.abspath().endswith('.html'):
74            with open(f.abspath()) as i:
75                html += i.read()
76    with open(ctx.outputs[0].abspath(), 'w') as o:
77        html = html.replace('@COPYRIGHT_YEAR@', year)
78        html = html.replace('@VER_DATE@', ctx.env.DATE)
79        o.write(html)
80
81def build(ctx):
82    #
83    # Get the version.
84    #
85    ver_version, ver_date, ver_released = version.get(ctx, rtems_major_version)
86    ctx.env.DATE = ver_date
87    ctx.env.RELEASE = ver_version + ' (' + ver_date + ')'
88    ctx.env.VERSION = ver_version
89    ctx.to_log('Build: %s%s' % (ctx.env.RELEASE, os.linesep))
90
91    #
92    #
93    # Generate any PlantUML images if enabled.
94    #
95    ctx.recurse('images')
96    ctx.add_group('images')
97
98    for b in building:
99        ctx.recurse(b)
100
101    #
102    # Build the catalogue, coverpage.js, index.html and install.
103    #
104    ctx(rule = catalogue,
105        target = 'catalogue.xml',
106        source = ['wscript', 'common/waf.py'] + ['%s/conf.py' % x for x in building])
107    ctx.install_files('${PREFIX}', 'catalogue.xml')
108    ctx(rule = coverpage_js,
109        target = 'coverpage.js',
110        source = ['wscript', 'catalogue.xml', 'common/coverpage/coverpage.js'])
111    ctx.install_as('${PREFIX}/coverpage.js', 'coverpage.js')
112    ctx(rule = index_html,
113        target = 'coverpage.html',
114        source = ['wscript', 'common/coverpage/coverpage.html'])
115    ctx.install_as('${PREFIX}/index.html', 'coverpage.html')
116    #
117    # Install the static content.
118    #
119    static_dir = ctx.path.find_dir('common/coverpage/static')
120    ctx.install_files('${PREFIX}/static',
121                      static_dir.ant_glob('**'),
122                      cwd = static_dir,
123                      relative_trick = True)
124
125def install(ctx):
126    for b in building:
127        ctx.recurse(b)
128
129def cmd_spell(ctx):
130    for b in building:
131        ctx.recurse(b)
132
133def cmd_linkcheck(ctx):
134    for b in building:
135        ctx.recurse(b)
Note: See TracBrowser for help on using the repository browser.