Browse Source

combine no-daemon, elogind and systemd option

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
Stephan Lachnit 4 years ago
parent
commit
ce6485ef97
4 changed files with 19 additions and 26 deletions
  1. 2 2
      daemon/meson.build
  2. 1 1
      data/meson.build
  3. 13 20
      meson.build
  4. 3 3
      meson_options.txt

+ 2 - 2
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,
     ],

+ 1 - 1
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',

+ 13 - 20
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

+ 3 - 3
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')