meson.build 4.0 KB

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