From: Remi Gacogne Date: Tue, 11 Feb 2025 09:47:41 +0000 (+0100) Subject: dnsdist: Fix handling of man pages with meson X-Git-Tag: dnsdist-2.0.0-alpha1~99^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7854aef48de9bbf4cdffe5e7a532cfa108a73a48;p=thirdparty%2Fpdns.git dnsdist: Fix handling of man pages with meson This commit moves to `custom_target` to build the man pages since we don't want to have to explicitely run a different meson command to build them. As opposed to `run_target`, `custom_target` does not have access to the build and source roots via env variables, so the man pages generation script now takes these as required parameters. --- diff --git a/docs/generate-man-pages.py b/docs/generate-man-pages.py index ddf7e0d73b..22a718d44c 100755 --- a/docs/generate-man-pages.py +++ b/docs/generate-man-pages.py @@ -3,7 +3,6 @@ import argparse import glob import itertools -import os import subprocess import sys import venv @@ -14,8 +13,8 @@ def main(): """Start the script.""" args = create_argument_parser() - source_root = Path(os.environ["MESON_SOURCE_ROOT"]) - build_root = Path(os.environ["MESON_BUILD_ROOT"]) + source_root = args.source_root + build_root = args.build_root # Create the venv. venv_directory = build_root.joinpath(args.venv_name) @@ -30,8 +29,8 @@ def main(): # Install some stuff into the venv. requirements_file = source_root.joinpath(args.requirements_file) pip = venv_directory.joinpath("bin").joinpath("pip") - subprocess.run([pip, "install", "-U", "pip", "setuptools", "wheel"]) - subprocess.run([pip, "install", "-r", requirements_file]) + subprocess.run([pip, "install", "-U", "pip", "setuptools", "wheel"], check=True) + subprocess.run([pip, "install", "-r", requirements_file], check=True) # Run sphinx to generate the man-pages. source_directory = source_root.joinpath(args.source_directory) @@ -47,7 +46,8 @@ def main(): source_directory, target_directory, ] - + files + + files, + check=True ) @@ -56,6 +56,18 @@ def create_argument_parser(): parser = argparse.ArgumentParser( description="Create a virtualenv from a requirements file" ) + parser.add_argument( + "--build-root", + type=Path, + required=True, + help="Build root", + ) + parser.add_argument( + "--source-root", + type=Path, + required=True, + help="Source root", + ) parser.add_argument( "--venv-name", type=str, diff --git a/pdns/dnsdistdist/meson.build b/pdns/dnsdistdist/meson.build index 2227f8a667..32d403cb6a 100644 --- a/pdns/dnsdistdist/meson.build +++ b/pdns/dnsdistdist/meson.build @@ -546,7 +546,6 @@ foreach tool, info: tools if 'manpages' in info foreach man_page: info['manpages'] man_pages += docs_dir / 'manpages' / (man_page + '.rst') - install_man(man_page) endforeach endif endforeach @@ -564,16 +563,30 @@ summary('Path', python.full_path(), section: 'Manual Pages') summary('Version', python.version(), section: 'Manual Pages') if python.found() - run_target( - 'man-pages', - command: [ - python, - product_source_dir / docs_dir / 'generate-man-pages.py', - '--venv-name', 'venv-dnsdist-man-pages', - '--requirements-file', docs_dir / 'requirements.txt', - '--source-directory', docs_dir, - '--target-directory', 'dnsdist-man-pages', - ] + man_pages, + generated_man_pages = [] + foreach tool, info: tools + if 'manpages' in info + foreach man_page: info['manpages'] + generated_man_pages += man_page + endforeach + endif + endforeach + custom_target( + 'man-pages', + input: man_pages, + output: generated_man_pages, + install: true, + install_dir: join_paths(get_option('mandir'), 'man1'), + command: [ + python, + product_source_dir / docs_dir / 'generate-man-pages.py', + '--build-root', '@BUILD_ROOT@', + '--source-root', '@SOURCE_ROOT@', + '--venv-name', 'venv-dnsdist-man-pages', + '--requirements-file', docs_dir / 'requirements.txt', + '--source-directory', docs_dir, + '--target-directory', 'dnsdist-man-pages', + ] + man_pages, ) endif