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