combine no-daemon, elogind and systemd option

Signed-off-by: Stephan Lachnit <stephanlachnit@protonmail.com>
This commit is contained in:
Stephan Lachnit 2020-04-27 10:20:49 +02:00 committed by afayaz-feral
parent 953792b4a5
commit ce6485ef97
4 changed files with 19 additions and 26 deletions

View File

@ -17,11 +17,11 @@ gamemoded_includes += config_h_dir
gamemoded = executable( gamemoded = executable(
'gamemoded', 'gamemoded',
sources: daemon_sources, sources: daemon_sources,
c_args: elogind_args, c_args: sd_bus_args,
dependencies: [ dependencies: [
link_daemon_common, link_daemon_common,
dep_threads, dep_threads,
dep_systemd, sd_bus_dep,
inih_dependency, inih_dependency,
libdl, libdl,
], ],

View File

@ -18,7 +18,7 @@ config_example = run_command(
).stdout().strip() ).stdout().strip()
data_conf.set('GAMEMODE_EXAMPLE_CONFIG', config_example) data_conf.set('GAMEMODE_EXAMPLE_CONFIG', config_example)
if with_systemd == true if sd_bus_provider == 'systemd'
# Install systemd user unit # Install systemd user unit
configure_file( configure_file(
input: 'gamemoded.service.in', input: 'gamemoded.service.in',

View File

@ -80,20 +80,15 @@ path_libexecdir = join_paths(path_prefix, get_option('libexecdir'))
path_sysconfdir = join_paths(path_prefix, get_option('sysconfdir')) path_sysconfdir = join_paths(path_prefix, get_option('sysconfdir'))
# Find systemd / elogind via pkgconfig # Find systemd / elogind via pkgconfig
with_systemd = get_option('with-systemd') sd_bus_provider = get_option('with-sd-bus-provider')
with_elogind = get_option('with-elogind')
elogind_args = [] sd_bus_args = []
dep_systemd = [] sd_bus_dep = []
if with_systemd == true if sd_bus_provider == 'systemd'
if with_elogind == true sd_bus_dep = dependency('libsystemd')
error('you can\'t use systemd and elogind at the same time') elif sd_bus_provider == 'elogind'
endif sd_bus_args += ['-DUSE_ELOGIND']
dep_systemd = dependency('libsystemd') sd_bus_dep = dependency('libelogind')
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')
endif endif
# For the client, libdbus is used # For the client, libdbus is used
@ -106,7 +101,7 @@ dep_threads = dependency('threads')
libdl = cc.find_library('dl', required: false) libdl = cc.find_library('dl', required: false)
# Determine the location for the systemd unit # 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 # 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') path_systemd_unit_dir = get_option('with-systemd-user-unit-dir')
if path_systemd_unit_dir == '' if path_systemd_unit_dir == ''
@ -137,7 +132,6 @@ endif
path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions') path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions')
with_daemon = get_option('with-daemon')
with_examples = get_option('with-examples') with_examples = get_option('with-examples')
with_util = get_option('with-util') with_util = get_option('with-util')
@ -169,7 +163,7 @@ endif
# The daemon can be disabled if necessary, allowing multilib builds of the # The daemon can be disabled if necessary, allowing multilib builds of the
# main library # main library
if with_daemon == true if sd_bus_provider != 'no-daemon'
# inih currently only needed by the daemon # inih currently only needed by the daemon
inih_dependency = dependency( inih_dependency = dependency(
'inih', 'inih',
@ -200,7 +194,7 @@ report = [
' includedir: @0@'.format(path_includedir), ' includedir: @0@'.format(path_includedir),
] ]
if with_systemd == true if sd_bus_provider == 'systemd'
report += [ report += [
' systemd user unit directory: @0@'.format(path_systemd_unit_dir), ' systemd user unit directory: @0@'.format(path_systemd_unit_dir),
] ]
@ -216,10 +210,9 @@ report += [
' Options:', ' Options:',
' ========', ' ========',
'', '',
' daemon: @0@'.format(with_daemon), ' sd-bus provier: @0@'.format(sd_bus_provider),
' examples: @0@'.format(with_examples), ' examples: @0@'.format(with_examples),
' util: @0@'.format(with_util), ' util: @0@'.format(with_util),
' systemd: @0@'.format(with_systemd),
] ]
# Output some stuff to validate the build config # Output some stuff to validate the build config

View File

@ -1,12 +1,13 @@
# limits.d # 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') 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 # 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') option('with-systemd-user-unit-dir', type: 'string', description: 'Explicitly set the systemd user unit directory')
# Not using systemd # 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') option('with-dbus-service-dir', type: 'string', description: 'Explicitly set the D-BUS session directory')
# lib dir in gamemoderun # lib dir in gamemoderun
@ -14,5 +15,4 @@ option('with-gamemoderun-lib-dir', type: 'string', value: 'default', description
# General options # General options
option('with-examples', type: 'boolean', description: 'Build sample programs', value: 'true') 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') option('with-util', type: 'boolean', description: 'Build the utilities', value: 'true')