]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: Change how we create empty directories from Meson
authorSimon McVittie <smcv@collabora.com>
Mon, 27 Jun 2022 14:37:17 +0000 (15:37 +0100)
committerSimon McVittie <smcv@collabora.com>
Wed, 13 Jul 2022 19:36:13 +0000 (20:36 +0100)
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>
bus/meson.build
meson.build
meson_post_install.py
tools/Makefile.am
tools/meson-compat-install-emptydirs.py [new file with mode: 0755]

index 06e293b84ebb801d2e81fba7b286e4398c4a3cff..1aaaf48dc9487f7351290b78cc0133facea5e9b2 100644 (file)
@@ -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 += [
         {
index edd20dfa8cde487a0f0753d40ac47a62f22e8c08..ad0e6d7bd1aa4e94bb463bc0b3e67fd31ead23cf 100644 (file)
@@ -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(
index 22f0539acafca4d0121dccc592c336e8db3a858c..3b083130b1bed832de4a46b46224881a6f290dbe 100755 (executable)
@@ -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()
index e9c066badda615e07c15f89f516bb502372ec416..dee5f8621346a70d1c430592eac185f5ae74e084 100644 (file)
@@ -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 (executable)
index 0000000..0fc7628
--- /dev/null
@@ -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)