weston/doc/sphinx/meson.build
Marius Vlad 402d9a81c9 doc/sphinx: Make doxygen warn as error depend on meson werror flag
As seen previous times, with newer doxygen version we seem to be
generating warnings and with it to stop generating documentation
entirely as we have enabled warning as error in the doxygen
configuration file.

By default meson werror build option is not enabled, so users can still
generate documentation when building regularly, and when we'll update to
the same doxygen version we should be able to catch those errors up if
any of them will pile up in between.

Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2022-09-23 11:37:06 +00:00

96 lines
2.9 KiB
Meson

sphinx = find_program('sphinx-build', required: true)
doxygen = find_program('doxygen', required: true)
dot = find_program('dot', required: true)
breathe = find_program('breathe-apidoc', required: true)
sphinx_c = run_command(sphinx, '--version')
breathe_c = run_command(breathe, '--version')
doxygen_c = run_command(doxygen, '--version')
sphinx_v = sphinx_c.stdout().split(' ')[1].strip()
breathe_v = breathe_c.stdout().split(' ')[2].strip()
doxygen_v = doxygen_c.stdout().strip()
if sphinx_v.version_compare('< 2.1.0')
error('Use at least sphinx version 2.1.0, found ' + sphinx_v)
endif
if breathe_v.version_compare('< 4.11')
error('Use at least breathe version 4.11, found ' + breathe_v)
endif
if doxygen_v.version_compare('< 1.8')
error('Use at least doxygen version 1.8, found ' + doxygen_v)
endif
doxygen_database = meson.current_build_dir() + '/doxygen_doc'
# modify the sphinx configuration and the breathe doxygen XML database
# to point where its being generated by doxygen
sphinx_conf_data = configuration_data()
sphinx_conf_data.set('BUILD_ROOT', doxygen_database)
sphinx_conf_data.set('VERSION', meson.project_version())
sphinx_conf = configure_file(
input: 'conf.py.in',
output: 'conf.py',
configuration: sphinx_conf_data
)
doxy_conf_data = configuration_data()
doxy_conf_data.set('SRC_ROOT', meson.source_root())
doxy_conf_data.set('OUTPUT_DIR', doxygen_database)
doxy_conf_data.set('MESON_WERROR', get_option('werror') == true ? 'YES' : 'NO')
doxygen_conf_weston = configure_file(
input: 'doxygen.ini.in',
output: 'doxygen.ini',
configuration: doxy_conf_data
)
script_data = configuration_data()
script_data.set('SRCDIR', meson.current_build_dir())
script_data.set('OUTDIR', meson.current_build_dir() + '/doc')
# Set a different directory for doctrees to avoid installing them
script_data.set('DOCTREES_DIR', meson.current_build_dir() + '/doctrees')
script_data.set('DOXYGEN_CONF', meson.current_build_dir() + '/doxygen.ini')
script_data.set('DOXYGEN_CMD', doxygen.path())
script_data.set('SPHINX_CMD', sphinx.path())
script_doxy_sphinx = configure_file(
input: 'run_doxygen_sphinx.sh.in',
output: 'run_doxygen_sphinx.sh',
configuration: script_data
)
# copy everything to build_dir, if you plan on adding other files in the top
# rootdir of sourcedir, please add them here as well, otherwise use 'toc/'s
# meson.build file
sphinx_files = ['index.rst']
foreach file : sphinx_files
configure_file(input: file, output: file, copy: true)
endforeach
# and those in toc
subdir('toc')
sphinx_doc = custom_target(
'weston-doc-breathe',
command: script_doxy_sphinx,
output: 'doc',
build_by_default: true,
)
# we need this because we will have a stale 'doc' directory
# and this forces it to be rebuilt
docs = run_target(
'docs',
command: script_doxy_sphinx,
)
install_subdir(
sphinx_doc.full_path(),
install_dir: join_paths(dir_data, 'doc', 'weston'),
exclude_files: '.buildinfo',
strip_directory: true,
)