Debian Codegraph @

doc/meson.build

raw
1 sphinx = find_program('sphinx-build', native : true, required : get_option('man-pages').enabled() or get_option('documentation').enabled())
2 sphinx_wrapper = meson.current_source_dir() / 'sphinx-wrapper.sh'
3 collect_authors = meson.current_source_dir() / 'collect-authors.sh'
4
5 man_pages = [
6 'flashrom.8'
7 ]
8
9 if sphinx.found()
10 if get_option('man-pages').auto() or get_option('man-pages').enabled()
11 man_outputs = []
12 foreach page : man_pages
13 man_outputs += 'man' + page.substring(-1)
14 endforeach
15
16 custom_target(
17 'man-pages',
18 command : [sphinx_wrapper, '@OUTDIR@', ' '.join(man_outputs), sphinx, '-b', 'man', '-q', '-d', '@PRIVATE_DIR@', '-Drelease=' + flashrom_version, '@CURRENT_SOURCE_DIR@', '@OUTDIR@'],
19 build_always_stale : true, # sphinx handles rebuilds
20 output : man_outputs,
21 install : true,
22 install_dir : get_option('mandir'),
23 )
24 endif
25
26 if get_option('documentation').auto() or get_option('documentation').enabled()
27
28 with_authors_list = get_option('generate_authors_list')
29 git = find_program('git', native : true, required : with_authors_list)
30 git_dir = meson.project_source_root() / '.git'
31
32 # TODO: investigate whether this version can be lowered.
33 version_for_authors_list = '7.2.0'
34 # TODO: use sphinx.version().version_compare() instead, after we increase min required meson version to 0.62
35 sphinx_for_authors_list = find_program('sphinx-build',
36 native : true,
37 required : false,
38 version : '>=' + version_for_authors_list)
39
40 # When with_authors_list is requested, unsatisfied requirements are an error.
41 if with_authors_list.enabled()
42 if not git.found()
43 error('generate_authors_list was force-enabled but git is not available')
44 endif
45 if not fs.is_dir(git_dir)
46 error('generate_authors_list was force-enabled but a .git directory was not found in the source tree')
47 endif
48 if not sphinx_for_authors_list.found()
49 error('generate_authors_list was force-enabled but sphinx version is too old, min required is '
50 + version_for_authors_list)
51 endif
52 endif
53
54 if (
55 (with_authors_list.enabled() or with_authors_list.auto())
56 and git.found() and fs.is_dir(git_dir)
57 and sphinx_for_authors_list.found()
58 )
59 # If requirements are met and authors list is allowed, generate it.
60 authors_lst = custom_target(
61 'authors_lst',
62 output : 'authors.lst',
63 command : [collect_authors, 'authors', '@OUTPUT0@', git_dir],
64 )
65 reviewers_lst = custom_target(
66 'reviewers_lst',
67 output : 'reviewers.lst',
68 command : [collect_authors, 'reviewers', '@OUTPUT0@', git_dir],
69 )
70 authors_list_options = [
71 '-Dflashrom_authors_list_files.authors=' + authors_lst.full_path(),
72 '-Dflashrom_authors_list_files.reviewers=' + reviewers_lst.full_path(),
73 ]
74 doc_depends = [authors_lst, reviewers_lst]
75 else
76 # Disabled or prerequisites not met. Continue without the authors list.
77 # Checks earlier in this file will raise an error if the feature is enabled
78 # but the prerequisites aren't met.
79 authors_list_options = []
80 doc_depends = []
81
82 if with_authors_list.auto()
83 # Explain what wasn't satisfied to help the user understand why
84 # the authors list is missing.
85 if not git.found()
86 message('git not found; will not generate authors list')
87 elif not fs.is_dir(git_dir)
88 message('.git directory not found in project; will not generate authors list')
89 endif
90 endif
91 endif
92
93 custom_target(
94 'documentation',
95 command : [
96 sphinx, '-b', 'html', '-q', '-d', '@PRIVATE_DIR@',
97 '-Drelease=' + flashrom_version,
98 '@CURRENT_SOURCE_DIR@', '@OUTDIR@/html'
99 ] + authors_list_options,
100 depends : doc_depends,
101 build_always_stale : true, # sphinx handles rebuilds
102 output : 'html',
103 install : true,
104 install_dir : get_option('datadir') + '/doc/flashrom'
105 )
106 endif
107
108 endif