]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix handling of man pages with meson
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 11 Feb 2025 09:47:41 +0000 (10:47 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 11 Feb 2025 10:06:37 +0000 (11:06 +0100)
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.

docs/generate-man-pages.py
pdns/dnsdistdist/meson.build

index ddf7e0d73bd1c77422c773b442fb25067c08eb43..22a718d44ce347a1540db564d2c35c984338edc0 100755 (executable)
@@ -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,
index 2227f8a6673655ffdd0532e8e860c68e0b4ae6d6..32d403cb6ae74902ac94fa76dc1437697b197638 100644 (file)
@@ -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