]>
Commit | Line | Data |
---|---|---|
e3667660 YL |
1 | if get_option('sphinx_build') == '' |
2 | sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'], | |
3 | required: get_option('docs')) | |
4 | else | |
5 | sphinx_build = find_program(get_option('sphinx_build'), | |
6 | required: get_option('docs')) | |
7 | endif | |
8 | ||
9 | # Check if tools are available to build documentation. | |
10 | build_docs = false | |
11 | if sphinx_build.found() | |
2e880198 | 12 | SPHINX_ARGS = ['env', 'CONFDIR=' + qemu_confdir, sphinx_build, '-q'] |
e3667660 YL |
13 | # If we're making warnings fatal, apply this to Sphinx runs as well |
14 | if get_option('werror') | |
15 | SPHINX_ARGS += [ '-W' ] | |
16 | endif | |
17 | ||
18 | # This is a bit awkward but works: create a trivial document and | |
19 | # try to run it with our configuration file (which enforces a | |
20 | # version requirement). This will fail if sphinx-build is too old. | |
b20a7ee6 PB |
21 | run_command('mkdir', ['-p', tmpdir / 'sphinx'], check: true) |
22 | run_command('touch', [tmpdir / 'sphinx/index.rst'], check: true) | |
e3667660 YL |
23 | sphinx_build_test_out = run_command(SPHINX_ARGS + [ |
24 | '-c', meson.current_source_dir(), | |
25 | '-b', 'html', tmpdir / 'sphinx', | |
b20a7ee6 | 26 | tmpdir / 'sphinx/out'], check: false) |
e3667660 YL |
27 | build_docs = (sphinx_build_test_out.returncode() == 0) |
28 | ||
29 | if not build_docs | |
73e6aec6 | 30 | warning('@0@: @1@'.format(sphinx_build.full_path(), sphinx_build_test_out.stderr())) |
e3667660 | 31 | if get_option('docs').enabled() |
73e6aec6 | 32 | error('Install a Python 3 version of python-sphinx and the readthedoc theme') |
e3667660 YL |
33 | endif |
34 | endif | |
35 | endif | |
36 | ||
f8aa24ea | 37 | if build_docs |
e3667660 YL |
38 | SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']] |
39 | ||
f8aa24ea | 40 | man_pages = { |
e0f7fc58 SR |
41 | 'qemu-ga.8': (have_ga ? 'man8' : ''), |
42 | 'qemu-ga-ref.7': (have_ga ? 'man7' : ''), | |
4ac2ee19 | 43 | 'qemu-qmp-ref.7': 'man7', |
23c02ace | 44 | 'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''), |
f8aa24ea PB |
45 | 'qemu-img.1': (have_tools ? 'man1' : ''), |
46 | 'qemu-nbd.8': (have_tools ? 'man8' : ''), | |
773ee3f1 | 47 | 'qemu-pr-helper.8': (have_tools ? 'man8' : ''), |
fa56cf7e | 48 | 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''), |
9c29b741 | 49 | 'qemu-trace-stap.1': (stap.found() ? 'man1' : ''), |
f8aa24ea PB |
50 | 'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''), |
51 | 'virtiofsd.1': (have_virtiofsd ? 'man1' : ''), | |
f8aa24ea PB |
52 | 'qemu.1': 'man1', |
53 | 'qemu-block-drivers.7': 'man7', | |
54 | 'qemu-cpu-models.7': 'man7' | |
f8aa24ea PB |
55 | } |
56 | ||
57 | sphinxdocs = [] | |
58 | sphinxmans = [] | |
bac35bf5 | 59 | |
b93f4fbd PM |
60 | private_dir = meson.current_build_dir() / 'manual.p' |
61 | output_dir = meson.current_build_dir() / 'manual' | |
62 | input_dir = meson.current_source_dir() | |
63 | ||
64 | this_manual = custom_target('QEMU manual', | |
f8aa24ea | 65 | build_by_default: build_docs, |
b93f4fbd PM |
66 | output: 'docs.stamp', |
67 | input: files('conf.py'), | |
68 | depfile: 'docs.d', | |
bac35bf5 PB |
69 | command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@', |
70 | '-Ddepfile_stamp=@OUTPUT0@', | |
71 | '-b', 'html', '-d', private_dir, | |
72 | input_dir, output_dir]) | |
b93f4fbd PM |
73 | sphinxdocs += this_manual |
74 | install_subdir(output_dir, install_dir: qemu_docdir, strip_directory: true) | |
f8aa24ea | 75 | |
b93f4fbd PM |
76 | these_man_pages = [] |
77 | install_dirs = [] | |
78 | foreach page, section : man_pages | |
79 | these_man_pages += page | |
80 | install_dirs += section == '' ? false : get_option('mandir') / section | |
f8aa24ea | 81 | endforeach |
b93f4fbd PM |
82 | |
83 | sphinxmans += custom_target('QEMU man pages', | |
84 | build_by_default: build_docs, | |
85 | output: these_man_pages, | |
86 | input: this_manual, | |
87 | install: build_docs, | |
88 | install_dir: install_dirs, | |
89 | command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir, | |
90 | input_dir, meson.current_build_dir()]) | |
91 | ||
f8aa24ea | 92 | alias_target('sphinxdocs', sphinxdocs) |
4ac2ee19 | 93 | alias_target('html', sphinxdocs) |
f8aa24ea PB |
94 | alias_target('man', sphinxmans) |
95 | endif |