From 1c41066a40d9cdb39904798c1caf220d6234e882 Mon Sep 17 00:00:00 2001 From: Jan Vaclav Date: Mon, 18 Dec 2023 10:45:19 +0100 Subject: [PATCH] build: include documentation in meson dist Previously, the tarball generated by `meson dist` did not contain the autogenerated documentation due to the way meson works (packaging the latest revision control commit). This introduces a dist script which builds & copies the generated documentation into the distribution tarball. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1811 --- meson.build | 6 +++++- tools/meson-dist-data.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 tools/meson-dist-data.sh diff --git a/meson.build b/meson.build index 9048a3db1a..b485810107 100644 --- a/meson.build +++ b/meson.build @@ -978,9 +978,13 @@ endif if enable_docs assert(enable_introspection, '-Ddocs=true requires -Dintrospection=true') - assert(meson.version().version_compare('>= 0.46.0'), '-Ddocs requires meson >= 0.46') + assert(meson.version().version_compare('>= 0.49.0'), '-Ddocs requires meson >= 0.49') subdir('man') subdir('docs') + meson.add_dist_script( + 'tools/meson-dist-data.sh', + '--build-root', build_root + ) endif configure_file( diff --git a/tools/meson-dist-data.sh b/tools/meson-dist-data.sh new file mode 100755 index 0000000000..1b5d3b03f2 --- /dev/null +++ b/tools/meson-dist-data.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +ensure_var_path() { + if [ "${!1}" = "" ]; then + echo "$0: Required variable $1 is not set, aborting" >&2 + exit 1 + fi + + if [ ! -d "${!1}" ]; then + echo "$0: Path '${!1}' in $1 does not exist or is not directory, aborting" >&2 + exit 1 + fi +} + +copy_from_build() { + cp -Tr "$MESON_BUILD_ROOT/$1" "$MESON_DIST_ROOT/$1" +} + +if [ "$MESON_BUILD_ROOT" = "" ]; then + if [ "$1" = "--build-root" ]; then + MESON_BUILD_ROOT="$2" + fi +fi + +ensure_var_path "MESON_DIST_ROOT" +ensure_var_path "MESON_BUILD_ROOT" +ensure_var_path "MESON_SOURCE_ROOT" + +ninja -C "$MESON_BUILD_ROOT" all libnm-doc NetworkManager-doc + +mkdir -p "$MESON_DIST_ROOT/docs/" +copy_from_build /docs/api/ +copy_from_build /docs/libnm/ +copy_from_build /man/