[gnome-shell] build: Pre-generate man pages at dist time



commit 9ef9a5ff8a147c5ef90ffce86468f1ccf8f94a6e
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Dec 15 19:23:14 2020 +0100

    build: Pre-generate man pages at dist time
    
    The man pages don't change very often, but draw in both docbook and
    asciidoc. The latter is particularly problematic, as some distros
    still ship only a python2 version of the tool.
    
    Address this by generating the man pages at dist time, and including
    the result in the tarball.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1553>

 meson.build                             | 10 ++++++++--
 meson/generate-manpages.py              | 24 ++++++++++++++++++++++++
 subprojects/extensions-tool/meson.build | 10 +++++++---
 3 files changed, 39 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index 71b3ca4717..4c913ff863 100644
--- a/meson.build
+++ b/meson.build
@@ -37,6 +37,7 @@ gst_req = '>= 0.11.92'
 nm_req = '>= 1.10.4'
 secret_req = '>= 0.18'
 
+fs = import('fs')
 gnome = import('gnome')
 i18n  = import('i18n')
 
@@ -126,8 +127,12 @@ else
 endif
 
 if get_option('man')
-  a2x = find_program('a2x')
-  subdir('man')
+  if fs.exists('man/gnome-shell.1')
+    install_man('man/gnome-shell.1')
+  else
+    a2x = find_program('a2x')
+    subdir('man')
+  endif
 endif
 
 mutter_typelibdir = mutter_dep.get_pkgconfig_variable('typelibdir')
@@ -287,6 +292,7 @@ if get_option('gtk_doc')
 endif
 
 meson.add_install_script('meson/postinstall.py')
+meson.add_dist_script('meson/generate-manpages.py')
 
 summary_options = {
   'networkmanager': get_option('networkmanager'),
diff --git a/meson/generate-manpages.py b/meson/generate-manpages.py
new file mode 100644
index 0000000000..ce2ca28282
--- /dev/null
+++ b/meson/generate-manpages.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import os
+from pathlib import PurePath
+from asciidocapi import AsciiDocAPI
+
+man_pages = [
+    'man/gnome-shell.1',
+    'subprojects/extensions-tool/man/gnome-extensions.1',
+]
+
+sourceroot = os.environ.get('MESON_SOURCE_ROOT')
+distroot = os.environ.get('MESON_DIST_ROOT')
+
+asciidoc = AsciiDocAPI()
+
+for man_page in man_pages:
+    page_path = PurePath(man_page)
+    src = PurePath(sourceroot, page_path.with_suffix('.txt'))
+    dst = PurePath(distroot, page_path)
+    stylesheet = src.with_name('stylesheet.xsl')
+
+    asciidoc.options('--xsl-file', os.fspath(stylesheet))
+    asciidoc.execute(os.fspath(src), outfile=os.fspath(dst))
diff --git a/subprojects/extensions-tool/meson.build b/subprojects/extensions-tool/meson.build
index 5460f626d9..18a38a0234 100644
--- a/subprojects/extensions-tool/meson.build
+++ b/subprojects/extensions-tool/meson.build
@@ -6,6 +6,7 @@ project('gnome-extensions-tool', 'c',
 
 gio_req = '>= 2.56.0'
 
+fs = import('fs')
 gnome = import('gnome')
 i18n  = import('i18n')
 
@@ -46,9 +47,12 @@ if bash_completion.found()
 endif
 
 if get_option('man')
-  a2x = find_program('a2x')
-
-  subdir('man')
+  if fs.exists('man/gnome-extensions.1')
+    install_man('man/gnome-extensions.1')
+  else
+    a2x = find_program('a2x')
+    subdir('man')
+  endif
 endif
 
 if not meson.is_subproject()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]