diff options
author | Simon McVittie <smcv@collabora.com> | 2022-06-27 15:37:17 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-07-13 20:36:13 +0100 |
commit | 398820d1fe45f85ac0a22971b88ce8a9903e4d70 (patch) | |
tree | df09528018bc8bba9373d4beaeeb0687e934121a | |
parent | e2f2c5dd42e193d4bddb0bda49b07bf254cff248 (diff) | |
download | dbus-398820d1fe45f85ac0a22971b88ce8a9903e4d70.tar.gz |
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 <smcv@collabora.com>
-rw-r--r-- | bus/meson.build | 13 | ||||
-rw-r--r-- | meson.build | 14 | ||||
-rwxr-xr-x | meson_post_install.py | 18 | ||||
-rw-r--r-- | tools/Makefile.am | 1 | ||||
-rwxr-xr-x | tools/meson-compat-install-emptydirs.py | 19 |
5 files changed, 46 insertions, 19 deletions
diff --git a/bus/meson.build b/bus/meson.build index 06e293b8..1aaaf48d 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 edd20dfa..ad0e6d7b 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 22f0539a..3b083130 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 e9c066ba..dee5f862 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 00000000..0fc76287 --- /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) |