summaryrefslogtreecommitdiffstats
path: root/wscript
blob: 5f8464d7521a9c5fa64e6b55f18e92d8797ad3f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# RTEMS Project Documentation
#

import sys
import os.path

import waflib

#
# Set Python's system path to `common` from the top level so the
# conf.py modules in subdirectories can be found. See xml_catalogue in
# common/waf.py.
#
sys.path.append(os.path.abspath('common'))

from common import waf as docs_waf
from common import version

#
# Branch version
#
rtems_major_version = '5'

#
# The documents to build.
#
build_all = ['user',
             'c-user',
             'bsp-howto',
             'posix-users',
             'posix-compliance',
             'eng',
             'filesystem',
             'networking',
             'shell',
             'cpu-supplement',
             'develenv',
             'eclipse']

building = build_all

def options(opt):
    docs_waf.cmd_options(opt)

def configure(conf):
    conf.find_program('git')
    for b in building:
        conf.recurse(b)
    conf.env['BUILD_FROM_TOP'] = 'yes'

def catalogue(ctx):
    docs_waf.xml_catalogue(ctx, building)

def coverpage_js(ctx):
    js = None
    xml = None
    for f in ctx.inputs:
        if f.abspath().endswith('.js'):
            with open(f.abspath()) as i:
                js = i.read()
        elif f.abspath().endswith('.xml'):
            with open(f.abspath()) as i:
                xml = i.read()
    xml = xml.replace('\n', ' \\\n');
    with open(ctx.outputs[0].abspath(), 'w') as o:
        o.write(js.replace('@CATALOGUE', xml))

def index_html(ctx):
    html = ''
    year = ctx.env.DATE.split()[2]
    for f in ctx.inputs:
        if f.abspath().endswith('.html'):
            with open(f.abspath()) as i:
                html += i.read()
    with open(ctx.outputs[0].abspath(), 'w') as o:
        html = html.replace('@COPYRIGHT_YEAR@', year)
        html = html.replace('@VER_DATE@', ctx.env.DATE)
        o.write(html)

def build(ctx):
    #
    # Get the version.
    #
    ver_version, ver_date, ver_released = version.get(ctx, rtems_major_version)
    ctx.env.DATE = ver_date
    ctx.env.RELEASE = ver_version + ' (' + ver_date + ')'
    ctx.env.VERSION = ver_version
    ctx.to_log('Build: %s%s' % (ctx.env.RELEASE, os.linesep))

    #
    #
    # Generate any PlantUML images if enabled.
    #
    ctx.recurse('images')
    ctx.add_group('images')

    for b in building:
        ctx.recurse(b)

    #
    # Build the catalogue, coverpage.js, index.html and install.
    #
    ctx(rule = catalogue,
        target = 'catalogue.xml',
        source = ['wscript', 'common/waf.py'] + ['%s/conf.py' % x for x in building])
    ctx.install_files('${PREFIX}', 'catalogue.xml')
    ctx(rule = coverpage_js,
        target = 'coverpage.js',
        source = ['wscript', 'catalogue.xml', 'common/coverpage/coverpage.js'])
    ctx.install_as('${PREFIX}/coverpage.js', 'coverpage.js')
    ctx(rule = index_html,
        target = 'coverpage.html',
        source = ['wscript', 'common/coverpage/coverpage.html'])
    ctx.install_as('${PREFIX}/index.html', 'coverpage.html')
    #
    # Install the static content.
    #
    static_dir = ctx.path.find_dir('common/coverpage/static')
    ctx.install_files('${PREFIX}/static',
                      static_dir.ant_glob('**'),
                      cwd = static_dir,
                      relative_trick = True)

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)