build: introduce sd-bus-provider option

This allows to select a specific provider for the sd-bus library.
This commit is contained in:
Simon Ser 2020-12-02 23:46:49 +01:00 committed by Brian Ashworth
parent 968c005760
commit fdbe98512a
5 changed files with 29 additions and 16 deletions

View file

@ -24,7 +24,7 @@ tasks:
sudo ninja -C build install
- setup: |
cd sway
meson build -Dauto_features=enabled
meson build -Dauto_features=enabled -Dsd-bus-provider=libsystemd
- build: |
cd sway
ninja -C build

View file

@ -2,9 +2,9 @@
#define _SWAYBAR_TRAY_TRAY_H
#include "config.h"
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LIBSYSTEMD
#include <systemd/sd-bus.h>
#elif HAVE_ELOGIND
#elif HAVE_LIBELOGIND
#include <elogind/sd-bus.h>
#endif
#include <cairo.h>

View file

@ -51,8 +51,6 @@ pixman = dependency('pixman-1')
glesv2 = dependency('glesv2')
libevdev = dependency('libevdev')
libinput = dependency('libinput', version: '>=1.6.0')
systemd = dependency('libsystemd', version: '>=239', required: false)
elogind = dependency('libelogind', version: '>=239', required: false)
xcb = dependency('xcb', required: get_option('xwayland'))
bash_comp = dependency('bash-completion', required: false)
fish_comp = dependency('fish', required: false)
@ -93,9 +91,28 @@ if get_option('xwayland').enabled() and not wlroots_features['xwayland']
endif
have_xwayland = xcb.found() and wlroots_features['xwayland']
tray_deps_found = systemd.found() or elogind.found()
if get_option('sd-bus-provider') == 'auto'
if not get_option('tray').disabled()
assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
endif
sdbus = dependency('libsystemd',
required: false,
version: '>=239',
not_found_message: 'libsystemd not found, trying libelogind',
)
if not sdbus.found()
sdbus = dependency('libelogind',
required: false,
version: '>=239',
)
endif
else
sdbus = dependency(get_option('sd-bus-provider'), required: get_option('tray'))
endif
tray_deps_found = sdbus.found()
if get_option('tray').enabled() and not tray_deps_found
error('Building with -Dtray=enabled, but libsystemd and libelogind have not been not found')
error('Building with -Dtray=enabled, but sd-bus has not been not found')
endif
have_tray = (not get_option('tray').disabled()) and tray_deps_found
@ -103,8 +120,8 @@ conf_data = configuration_data()
conf_data.set10('HAVE_XWAYLAND', have_xwayland)
conf_data.set10('HAVE_GDK_PIXBUF', gdk_pixbuf.found())
conf_data.set10('HAVE_SYSTEMD', systemd.found())
conf_data.set10('HAVE_ELOGIND', elogind.found())
conf_data.set10('HAVE_LIBSYSTEMD', sdbus.found() and sdbus.name() == 'libsystemd')
conf_data.set10('HAVE_LIBELOGIND', sdbus.found() and sdbus.name() == 'libelogind')
conf_data.set10('HAVE_TRAY', have_tray)
scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
@ -291,8 +308,7 @@ endif
summary({
'xwayland': have_xwayland,
'gdk-pixbuf': gdk_pixbuf.found(),
'systemd': systemd.found(),
'elogind': elogind.found(),
'sd-bus': sdbus.found(),
'tray': have_tray,
'man-pages': scdoc.found(),
}, bool_yn: true)

View file

@ -6,3 +6,4 @@ option('xwayland', type: 'feature', value: 'auto', description: 'Enable support
option('tray', type: 'feature', value: 'auto', description: 'Enable support for swaybar tray')
option('gdk-pixbuf', type: 'feature', value: 'auto', description: 'Enable support for more image formats in swaybg')
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind'], value: 'auto', description: 'Provider of the sd-bus library')

View file

@ -19,11 +19,7 @@ swaybar_deps = [
wayland_cursor
]
if have_tray
if systemd.found()
swaybar_deps += systemd
elif elogind.found()
swaybar_deps += elogind
endif
swaybar_deps += sdbus
endif
executable(