1 | # |
---|
2 | # RTEMS Project Documentation |
---|
3 | # |
---|
4 | |
---|
5 | from sys import path |
---|
6 | from os.path import abspath |
---|
7 | path.append(abspath('common')) |
---|
8 | |
---|
9 | import waflib |
---|
10 | import waf as docs_waf |
---|
11 | |
---|
12 | build_all = ['user', |
---|
13 | 'rsb', |
---|
14 | 'c-user', |
---|
15 | 'bsp-howto', |
---|
16 | 'posix-users', |
---|
17 | 'posix-compliance', |
---|
18 | 'eng', |
---|
19 | 'filesystem', |
---|
20 | 'networking', |
---|
21 | 'shell', |
---|
22 | 'cpu-supplement', |
---|
23 | 'develenv', |
---|
24 | 'eclipse'] |
---|
25 | |
---|
26 | building = build_all |
---|
27 | |
---|
28 | def options(opt): |
---|
29 | docs_waf.cmd_options(opt) |
---|
30 | |
---|
31 | def configure(conf): |
---|
32 | for b in building: |
---|
33 | conf.recurse(b) |
---|
34 | conf.env['BUILD_FROM_TOP'] = 'yes' |
---|
35 | |
---|
36 | def catalogue(ctx): |
---|
37 | docs_waf.xml_catalogue(ctx, building) |
---|
38 | |
---|
39 | def coverpage_js(ctx): |
---|
40 | js = None |
---|
41 | xml = None |
---|
42 | for f in ctx.inputs: |
---|
43 | if f.abspath().endswith('.js'): |
---|
44 | with open(f.abspath()) as i: |
---|
45 | js = i.read() |
---|
46 | elif f.abspath().endswith('.xml'): |
---|
47 | with open(f.abspath()) as i: |
---|
48 | xml = i.read() |
---|
49 | xml = xml.replace('\n', ' \\\n'); |
---|
50 | with open(ctx.outputs[0].abspath(), 'w') as o: |
---|
51 | o.write(js.replace('@CATALOGUE', xml)) |
---|
52 | |
---|
53 | def pretty_day(day): |
---|
54 | if day == 3: |
---|
55 | s = 'rd' |
---|
56 | elif day == 11: |
---|
57 | s = 'th' |
---|
58 | elif day == 12: |
---|
59 | s = 'th' |
---|
60 | elif day == 13: |
---|
61 | s = 'th' |
---|
62 | elif day % 10 == 1: |
---|
63 | s = 'st' |
---|
64 | elif day % 10 == 2: |
---|
65 | s = 'nd' |
---|
66 | else: |
---|
67 | s = 'th' |
---|
68 | return str(day) + s |
---|
69 | |
---|
70 | def build(ctx): |
---|
71 | # |
---|
72 | # Get date and version from Git |
---|
73 | # |
---|
74 | version = '5.0.0' |
---|
75 | if ctx.exec_command(['git', 'diff-index', '--quiet', 'HEAD']) == 0: |
---|
76 | modified = '' |
---|
77 | else: |
---|
78 | modified = '-modified' |
---|
79 | try: |
---|
80 | out = ctx.cmd_and_log(['git', 'log', '-1', '--format=%H,%cd', '--date=format:%e,%B,%Y']) |
---|
81 | f = out.strip('\n').split(',') |
---|
82 | version = version + '.' + f[0] + modified |
---|
83 | date = pretty_day(int(f[1])) + ' ' + f[2] + ' ' + f[3] |
---|
84 | except waflib.Build.Errors.WafError: |
---|
85 | date = 'unknown date' |
---|
86 | ctx.env.DATE = date |
---|
87 | ctx.env.RELEASE = version + ' (' + date + ')' |
---|
88 | ctx.env.VERSION = version |
---|
89 | |
---|
90 | # |
---|
91 | # Generate any PlantUML images if enabled. |
---|
92 | # |
---|
93 | ctx.recurse('images') |
---|
94 | ctx.add_group('images') |
---|
95 | |
---|
96 | for b in building: |
---|
97 | ctx.recurse(b) |
---|
98 | |
---|
99 | # |
---|
100 | # Build the catalogue, coverpage.js and install. |
---|
101 | # |
---|
102 | ctx(rule = catalogue, |
---|
103 | target = 'catalogue.xml', |
---|
104 | source = ['wscript', 'common/waf.py'] + ['%s/conf.py' % x for x in building]) |
---|
105 | ctx.install_files('${PREFIX}', 'catalogue.xml') |
---|
106 | ctx(rule = coverpage_js, |
---|
107 | target = 'coverpage.js', |
---|
108 | source = ['wscript', 'catalogue.xml', 'common/coverpage/coverpage.js']) |
---|
109 | ctx.install_as('${PREFIX}/coverpage.js', 'coverpage.js') |
---|
110 | # |
---|
111 | # Install the static content. |
---|
112 | # |
---|
113 | ctx.install_as('${PREFIX}/index.html', 'common/coverpage/coverpage.html') |
---|
114 | static_dir = ctx.path.find_dir('common/coverpage/static') |
---|
115 | ctx.install_files('${PREFIX}/static', |
---|
116 | static_dir.ant_glob('**'), |
---|
117 | cwd = static_dir, |
---|
118 | relative_trick = True) |
---|
119 | |
---|
120 | def install(ctx): |
---|
121 | for b in building: |
---|
122 | ctx.recurse(b) |
---|
123 | |
---|
124 | def cmd_spell(ctx): |
---|
125 | for b in building: |
---|
126 | ctx.recurse(b) |
---|
127 | |
---|
128 | def cmd_linkcheck(ctx): |
---|
129 | for b in building: |
---|
130 | ctx.recurse(b) |
---|