From ce6485ef97239c06b606585698defad00e25ad19 Mon Sep 17 00:00:00 2001 From: Stephan Lachnit Date: Mon, 27 Apr 2020 10:20:49 +0200 Subject: [PATCH] combine no-daemon, elogind and systemd option Signed-off-by: Stephan Lachnit --- daemon/meson.build | 4 ++-- data/meson.build | 2 +- meson.build | 33 +++++++++++++-------------------- meson_options.txt | 6 +++--- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/daemon/meson.build b/daemon/meson.build index d328122..c9ab0b9 100644 --- a/daemon/meson.build +++ b/daemon/meson.build @@ -17,11 +17,11 @@ gamemoded_includes += config_h_dir gamemoded = executable( 'gamemoded', sources: daemon_sources, - c_args: elogind_args, + c_args: sd_bus_args, dependencies: [ link_daemon_common, dep_threads, - dep_systemd, + sd_bus_dep, inih_dependency, libdl, ], diff --git a/data/meson.build b/data/meson.build index bb3d014..f2f01f5 100644 --- a/data/meson.build +++ b/data/meson.build @@ -18,7 +18,7 @@ config_example = run_command( ).stdout().strip() data_conf.set('GAMEMODE_EXAMPLE_CONFIG', config_example) -if with_systemd == true +if sd_bus_provider == 'systemd' # Install systemd user unit configure_file( input: 'gamemoded.service.in', diff --git a/meson.build b/meson.build index 5334f28..9648757 100644 --- a/meson.build +++ b/meson.build @@ -80,20 +80,15 @@ path_libexecdir = join_paths(path_prefix, get_option('libexecdir')) path_sysconfdir = join_paths(path_prefix, get_option('sysconfdir')) # Find systemd / elogind via pkgconfig -with_systemd = get_option('with-systemd') -with_elogind = get_option('with-elogind') -elogind_args = [] -dep_systemd = [] -if with_systemd == true - if with_elogind == true - error('you can\'t use systemd and elogind at the same time') - endif - dep_systemd = dependency('libsystemd') -elif with_elogind == true - elogind_args += ['-DUSE_ELOGIND'] - dep_systemd = dependency('libelogind') -else - error('you need to use either sd-bus.h from systemd or elogind') +sd_bus_provider = get_option('with-sd-bus-provider') + +sd_bus_args = [] +sd_bus_dep = [] +if sd_bus_provider == 'systemd' + sd_bus_dep = dependency('libsystemd') +elif sd_bus_provider == 'elogind' + sd_bus_args += ['-DUSE_ELOGIND'] + sd_bus_dep = dependency('libelogind') endif # For the client, libdbus is used @@ -106,7 +101,7 @@ dep_threads = dependency('threads') libdl = cc.find_library('dl', required: false) # Determine the location for the systemd unit -if with_systemd == true +if sd_bus_provider == 'systemd' # If the path isn't explicitly set, ask systemd for the systemd user unit directory path_systemd_unit_dir = get_option('with-systemd-user-unit-dir') if path_systemd_unit_dir == '' @@ -137,7 +132,6 @@ endif path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions') -with_daemon = get_option('with-daemon') with_examples = get_option('with-examples') with_util = get_option('with-util') @@ -169,7 +163,7 @@ endif # The daemon can be disabled if necessary, allowing multilib builds of the # main library -if with_daemon == true +if sd_bus_provider != 'no-daemon' # inih currently only needed by the daemon inih_dependency = dependency( 'inih', @@ -200,7 +194,7 @@ report = [ ' includedir: @0@'.format(path_includedir), ] -if with_systemd == true +if sd_bus_provider == 'systemd' report += [ ' systemd user unit directory: @0@'.format(path_systemd_unit_dir), ] @@ -216,10 +210,9 @@ report += [ ' Options:', ' ========', '', - ' daemon: @0@'.format(with_daemon), + ' sd-bus provier: @0@'.format(sd_bus_provider), ' examples: @0@'.format(with_examples), ' util: @0@'.format(with_util), - ' systemd: @0@'.format(with_systemd), ] # Output some stuff to validate the build config diff --git a/meson_options.txt b/meson_options.txt index 1c4b85c..2afb767 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,12 +1,13 @@ # limits.d option('with-pam-group', type: 'string', description: 'Install the limits.d configuration file to allow renicing as an unpriviledged user being part of the specified group') +# sd-bus provider +option('with-sd-bus-provider', type: 'combo', choices: ['systemd', 'elogind', 'no-daemon'], value: 'systemd') + # systemd specific -option('with-systemd', type: 'boolean', description: 'Use systemd support (unit, etc)', value: true) option('with-systemd-user-unit-dir', type: 'string', description: 'Explicitly set the systemd user unit directory') # Not using systemd -option('with-elogind', type: 'boolean', description: 'Use elogind\'s Dbus library', value: false) option('with-dbus-service-dir', type: 'string', description: 'Explicitly set the D-BUS session directory') # lib dir in gamemoderun @@ -14,5 +15,4 @@ option('with-gamemoderun-lib-dir', type: 'string', value: 'default', description # General options option('with-examples', type: 'boolean', description: 'Build sample programs', value: 'true') -option('with-daemon', type: 'boolean', description: 'Build the daemon', value: 'true') option('with-util', type: 'boolean', description: 'Build the utilities', value: 'true')