Skip to content

Commit

Permalink
meson: include pre-generated man pages & HTML docs in dist tarballs
Browse files Browse the repository at this point in the history
iputils is a core utility (hard to avoid on e.g. servers or small images, even)
so it's handy to have a minimal set of build dependencies. Pre-generate
the man pages and HTML docs and include them in the dist tarball so they can
be used without installing libxslt, docbook, and friends.

This is a followup to 83f011a and
72a3687.

Bug: iputils#479
Bug: https://bugs.gentoo.org/908817
Bug: https://bugs.gentoo.org/920901
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
thesamesam authored and pevik committed Feb 12, 2024
1 parent c0658b1 commit 387baad
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ if build_tracepath == true
manpages += ['tracepath']
endif

if meson.version().version_compare('>=0.58.0')
# Use the docs included in a dist tarball if available
fs = import('fs')
out_man_pages = []
out_html_pages = []
generated_docs_exist = true
foreach page : manpages
man_page_name = page.replace('.xml', '.8')
html_page_name = page.replace('.xml', '.html')
out_man_pages += man_page_name
out_html_pages += html_page_name
if not fs.exists(man_page_name) or not fs.exists(html_page_name)
generated_docs_exist = false
endif
endforeach
if generated_docs_exist
install_man(out_man_pages)
install_data(out_html_pages, install_dir : join_paths(get_option('datadir'), meson.project_name()))
subdir_done()
endif
else
warning('Will not attempt to use pre-generated man pages with <0.58.0')
endif

xsltproc = find_program('xsltproc', required : build_mans or build_html_mans)
xsltproc_args = [
'--nonet',
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ endif

if build_mans == true or build_html_mans == true
subdir ('doc')

if meson.version().version_compare('>=0.48.0')
meson.add_dist_script('tools/meson-build-dist-man.sh')
endif
endif

if run_tests
Expand Down
12 changes: 12 additions & 0 deletions tools/meson-build-dist-man.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# This script should be invoked by meson itself (via 'meson dist')
# See https://github.com/mesonbuild/meson/issues/2166 and more specifically,
# https://github.com/mesonbuild/meson/issues/2166#issuecomment-629696911.
set -eu

cd "$MESON_DIST_ROOT"
DIR=$(mktemp -d)
meson setup "$DIR" -DBUILD_MANS=true -DBUILD_HTML_MANS=true
meson compile -C "$DIR"
cp "$DIR"/doc/* doc/
rm -rf "$DIR"

0 comments on commit 387baad

Please sign in to comment.