Debian Codegraph @

docs/meson.build

raw
1 # Find dependencies
2 pymod = import('python')
3
4 python_doc = pymod.find_installation(
5 'python3',
6 modules: ['sphinx', 'sphinx_rtd_theme', 'breathe', 'sphinx.ext.graphviz'],
7 required: get_option('doc')
8 )
9 summary({'Python 3 Sphinx related modules': python_doc.found()},
10 bool_yn: true,
11 section: 'For documentation'
12 )
13
14 python_gir = pymod.find_installation(
15 'python3',
16 modules: ['lxml'],
17 required: get_option('introspection')
18 )
19 summary({'Python 3 lxml module': python_gir.found()},
20 bool_yn: true,
21 section: 'For introspection'
22 )
23
24 if get_option('doc').enabled() or get_option('introspection').enabled()
25 doxygen_p = find_program('doxygen', version: '>= 1.8.0', required: true)
26 elif get_option('doc').auto() or get_option('introspection').auto()
27 doxygen_p = find_program('doxygen', version: '>= 1.8.0', required: false)
28 else
29 doxygen_p = disabler()
30 endif
31 summary({'Doxygen': doxygen_p.found()}, bool_yn: true, section: 'For introspection')
32 summary({'Doxygen': doxygen_p.found()}, bool_yn: true, section: 'For documentation')
33
34 sphinx_p = find_program('sphinx-build',
35 version: '>= 2.1.0', required: get_option('doc'))
36 summary({'sphinx-build': sphinx_p.found()}, bool_yn: true, section: 'For documentation')
37 gir_p = find_program('g-ir-scanner', required: get_option('introspection'))
38 summary({'g-ir-scanner': gir_p.found()}, bool_yn: true, section: 'For introspection')
39
40 build_doc = python_doc.found() and doxygen_p.found() and sphinx_p.found()
41 build_gir = python_gir.found() and doxygen_p.found() and gir_p.found()
42
43 # Run doxygen (common for docs and g-i)
44
45 if build_doc or build_gir
46 doxy_wp_conf_data = configuration_data()
47 doxy_wp_conf_data.set('OUTPUT_DIR', meson.current_build_dir() / 'wp')
48 doxy_wp_conf_data.set('INPUT', meson.current_source_dir() / '..' / 'lib' / 'wp')
49 doxyfile_wp = configure_file(
50 input: 'Doxyfile.in',
51 output: 'Doxyfile-wp',
52 configuration: doxy_wp_conf_data
53 )
54
55 doxyxml_wp_depfiles = [wp_lib_sources, wp_lib_headers]
56 doxyxml_wp = custom_target('doxyxml_wp',
57 command: [doxygen_p, doxyfile_wp],
58 depend_files: doxyxml_wp_depfiles,
59 output: 'wp',
60 build_by_default: true,
61 )
62 endif
63
64 # Build documentation
65
66 if build_doc
67 sphinx_files = files(
68 '_static'/'custom.css',
69 meson.current_source_dir()/'..'/'README.rst',
70 meson.current_source_dir()/'..'/'NEWS.rst',
71 )
72 sphinx_files += scripts_doc_files
73 subdir('rst')
74
75 sphinx_conf_data = configuration_data()
76 sphinx_conf_data.set('SRCDIR', meson.current_source_dir())
77 sphinx_conf_data.set('OUTDIR', meson.current_build_dir())
78 sphinx_conf_data.set('VERSION', meson.project_version())
79 sphinx_conf = configure_file(
80 input: 'conf.py.in',
81 output: 'conf.py',
82 configuration: sphinx_conf_data
83 )
84
85 custom_target('doc',
86 command: [sphinx_p,
87 '-q', # quiet
88 '-E', # rebuild from scratch
89 '-j', 'auto', # parallel build
90 '-d', '@PRIVATE_DIR@', # doctrees dir
91 '-c', '@OUTDIR@', # conf.py dir
92 '@CURRENT_SOURCE_DIR@/rst', # source dir
93 '@OUTPUT@', # output dir
94 ],
95 depend_files: [
96 sphinx_conf, sphinx_files,
97 doxyfile_wp, doxyxml_wp_depfiles,
98 ],
99 depends: [doxyxml_wp],
100 output: 'html',
101 install: true,
102 install_dir: wireplumber_doc_dir,
103 build_by_default: true,
104 )
105
106 # Generate man pages directory with sphinx
107 custom_target('manpages',
108 command: [sphinx_p,
109 '-q', # quiet
110 '-E', # rebuild from scratch
111 '-b', 'man', # man page builder
112 '-d', '@PRIVATE_DIR@', # doctrees dir
113 '-c', '@OUTDIR@', # conf.py dir
114 '@CURRENT_SOURCE_DIR@/rst', # source dir
115 '@OUTDIR@', # output directory
116 ],
117 depend_files: [
118 sphinx_conf, sphinx_files,
119 ],
120 output: ['wpctl.1'],
121 install: true,
122 install_dir: get_option('mandir') / 'man1',
123 build_by_default: true,
124 )
125 endif
126
127 # Build GObject introspection
128
129 if build_gir
130 wp_gtkdoc_h = custom_target('wp_gtkdoc_h',
131 command: [python_gir,
132 '@CURRENT_SOURCE_DIR@/gen-api-gtkdoc.py',
133 '-o', '@OUTPUT@',
134 '@OUTDIR@/wp/xml',
135 ],
136 depends: [doxyxml_wp],
137 depend_files: [doxyxml_wp_depfiles, 'gen-api-gtkdoc.py'],
138 output: 'wp-gtkdoc.h',
139 build_by_default: true,
140 )
141
142 # A dummy library dependency to force meson to make the gir target
143 # depend on wp-gtkdoc.h, because generate_gir() doesn't add dependencies
144 # on its sources (meson bug)
145 # fixed in 0.59 by https://github.com/mesonbuild/meson/pull/8805
146 dummy_c = custom_target('dummy_c',
147 command: ['echo', 'int dummy(void) { return 0; }'],
148 capture: true,
149 output: 'dummy.c',
150 build_by_default: true,
151 )
152 libdummy = library('dummy',
153 wp_gtkdoc_h, dummy_c,
154 install: false,
155 soversion: '0',
156 version: '0.0.0',
157 )
158 dummy_dep = declare_dependency(link_with: libdummy)
159
160 gnome.generate_gir(wp_lib,
161 dependencies: [wp_dep, dummy_dep],
162 namespace: 'Wp',
163 nsversion: wireplumber_api_version,
164 export_packages: 'wireplumber-' + wireplumber_api_version,
165 header: 'wp/wp.h',
166 sources: [wpenums_h, wp_gtkdoc_h, wp_lib_headers],
167 include_directories: [wpenums_include_dir],
168 includes: ['GLib-2.0', 'GObject-2.0', 'Gio-2.0'],
169 install: true,
170 )
171 endif