From: Simon McVittie Date: Mon, 27 Jun 2022 14:37:17 +0000 (+0100) Subject: build: Change how we create empty directories from Meson X-Git-Tag: dbus-1.15.0~32^2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=398820d1fe45f85ac0a22971b88ce8a9903e4d70;p=thirdparty%2Fdbus.git build: Change how we create empty directories from Meson Use install_emptydir() in Meson versions that support it, or a script with similar invocation in versions that do not. This will make it straightforward to migrate to install_emptydir() when we drop support for Meson versions older than 0.60.0. Signed-off-by: Simon McVittie --- diff --git a/bus/meson.build b/bus/meson.build index 06e293b84..1aaaf48dc 100644 --- a/bus/meson.build +++ b/bus/meson.build @@ -184,6 +184,19 @@ if platform_unix and use_traditional_activation ) endif +install_emptydirs += [ + get_option('datadir') / 'dbus-1' / 'session.d', + get_option('datadir') / 'dbus-1' / 'services', +] + +if platform_unix + install_emptydirs += [ + get_option('localstatedir') / 'run' / 'dbus', + get_option('datadir') / 'dbus-1' / 'system.d', + get_option('datadir') / 'dbus-1' / 'system-services', + ] +endif + if use_systemd install_symlinks += [ { diff --git a/meson.build b/meson.build index edd20dfa8..ad0e6d7bd 100644 --- a/meson.build +++ b/meson.build @@ -42,6 +42,7 @@ data_config = configuration_data() compile_args = [] link_args = [] +install_emptydirs = [] install_symlinks = [] ############################################################################### @@ -980,9 +981,7 @@ subdir('doc') subdir('cmake') meson.add_install_script('meson_post_install.py', - '@0@'.format(platform_unix), '@0@'.format(relocation), - '@0@'.format(use_systemd), ) pkgconfig.generate( @@ -1011,6 +1010,17 @@ pkgconfig.generate( } ) +if meson.version().version_compare('>=0.60.0') + foreach dir : install_emptydirs + install_emptydir(dir) + endforeach +else + meson.add_install_script( + 'tools/meson-compat-install-emptydirs.py', + ':'.join(install_emptydirs), + ) +endif + foreach symlink : install_symlinks if not platform_unix warning( diff --git a/meson_post_install.py b/meson_post_install.py index 22f0539ac..3b083130b 100755 --- a/meson_post_install.py +++ b/meson_post_install.py @@ -57,23 +57,8 @@ def to_destdir(path): # Define paths here abs_libdir = destdir_prefix / get_option('libdir') -dbus_data_dir = destdir_prefix / get_option('datadir') / 'dbus-1' -platform_unix = sys.argv[1].lower() == 'true' -relocation = sys.argv[2].lower() == 'true' - -def post_install_data(): - (dbus_data_dir / 'session.d').mkdir(parents=True, exist_ok=True) - (dbus_data_dir / 'services').mkdir(parents=True, exist_ok=True) - (dbus_data_dir / 'session.d').mkdir(parents=True, exist_ok=True) - - localstatedir = Path(get_option('localstatedir')) - if destdir: - localstatedir = destdir / localstatedir.relative_to(localstatedir.anchor) - if platform_unix: - (localstatedir / 'run' / 'dbus').mkdir(parents=True, exist_ok=True) - (dbus_data_dir / 'system.d').mkdir(parents=True, exist_ok=True) - (dbus_data_dir / 'system-services').mkdir(parents=True, exist_ok=True) +relocation = sys.argv[1].lower() == 'true' def post_install_relocation(): # Edit pkg-config file to replace the prefix @@ -116,6 +101,5 @@ def post_install_exe(): if __name__ == "__main__": - post_install_data() post_install_relocation() post_install_exe() diff --git a/tools/Makefile.am b/tools/Makefile.am index e9c066bad..dee5f8621 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -154,4 +154,5 @@ installcheck-local: EXTRA_DIST += build-timestamp.py EXTRA_DIST += meson.build +EXTRA_DIST += meson-compat-install-emptydirs.py EXTRA_DIST += meson-compat-install-symlink.py diff --git a/tools/meson-compat-install-emptydirs.py b/tools/meson-compat-install-emptydirs.py new file mode 100755 index 000000000..0fc76287a --- /dev/null +++ b/tools/meson-compat-install-emptydirs.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# Copyright 2022 Collabora Ltd. +# SPDX-License-Identifier: MIT + +# Compatibility shim for installing empty directories with Meson < 0.60 + +import os +import sys +from pathlib import Path + +for d in sys.argv[1].split(':'): + if os.path.isabs(d) and 'DESTDIR' in os.environ: + p = Path(d) + d = p.relative_to(p.anchor) + dest = os.path.join(os.environ['DESTDIR'], d) + else: + dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d) + + os.makedirs(dest, mode=0o755, exist_ok=True)