meson: make it possible to compile without dbus

Make an option to disable dbus and all the code that depends on
it.

Fixes #1685
This commit is contained in:
Wim Taymans 2021-10-09 15:00:04 +02:00
parent caf0b2df19
commit 5f7c4dec34
8 changed files with 39 additions and 20 deletions

View file

@ -322,7 +322,11 @@ mathlib = cc.find_library('m', required : false)
rt_lib = cc.find_library('rt', required : false) # clock_gettime rt_lib = cc.find_library('rt', required : false) # clock_gettime
dl_lib = cc.find_library('dl', required : false) dl_lib = cc.find_library('dl', required : false)
pthread_lib = dependency('threads') pthread_lib = dependency('threads')
dbus_dep = dependency('dbus-1') dbus_dep = dependency('dbus-1', required : get_option('dbus'))
summary({'dbus (Bluetooth, rtkit, portal, pw-reserve)': dbus_dep.found()}, bool_yn: true, section: 'Misc dependencies')
if dbus_dep.found()
cdata.set('HAVE_DBUS', 1)
endif
sdl_dep = dependency('sdl2', required : get_option('sdl2')) sdl_dep = dependency('sdl2', required : get_option('sdl2'))
summary({'SDL 2': sdl_dep.found()}, bool_yn: true, section: 'Misc dependencies') summary({'SDL 2': sdl_dep.found()}, bool_yn: true, section: 'Misc dependencies')
readline_dep = dependency('readline', required : false) readline_dep = dependency('readline', required : false)

View file

@ -137,6 +137,10 @@ option('v4l2',
description: 'Enable v4l2 spa plugin integration', description: 'Enable v4l2 spa plugin integration',
type: 'feature', type: 'feature',
value: 'auto') value: 'auto')
option('dbus',
description: 'Enable code that depends on dbus',
type: 'feature',
value: 'enabled')
option('libcamera', option('libcamera',
description: 'Enable libcamera spa plugin integration', description: 'Enable libcamera spa plugin integration',
type: 'feature', type: 'feature',

View file

@ -34,14 +34,16 @@ if not get_option('evl').disabled()
install_dir : spa_plugindir / 'support') install_dir : spa_plugindir / 'support')
endif endif
spa_dbus_sources = ['dbus.c'] if dbus_dep.found()
spa_dbus_sources = ['dbus.c']
spa_dbus_lib = shared_library('spa-dbus', spa_dbus_lib = shared_library('spa-dbus',
spa_dbus_sources, spa_dbus_sources,
include_directories : [ spa_inc], include_directories : [ spa_inc],
dependencies : [dbus_dep, ], dependencies : [dbus_dep, ],
install : true, install : true,
install_dir : spa_plugindir / 'support') install_dir : spa_plugindir / 'support')
endif
if systemd_dep.found() if systemd_dep.found()

View file

@ -201,15 +201,10 @@ pipewire_module_protocol_native = shared_library('pipewire-module-protocol-nativ
pipewire_module_protocol_pulse_deps = pipewire_module_protocol_deps pipewire_module_protocol_pulse_deps = pipewire_module_protocol_deps
if dbus_dep.found()
pipewire_module_protocol_pulse_deps += dbus_dep
endif
pipewire_module_protocol_pulse_sources = [ pipewire_module_protocol_pulse_sources = [
'module-protocol-pulse.c', 'module-protocol-pulse.c',
'module-protocol-pulse/client.c', 'module-protocol-pulse/client.c',
'module-protocol-pulse/collect.c', 'module-protocol-pulse/collect.c',
'module-protocol-pulse/dbus-name.c',
'module-protocol-pulse/extension.c', 'module-protocol-pulse/extension.c',
'module-protocol-pulse/format.c', 'module-protocol-pulse/format.c',
'module-protocol-pulse/manager.c', 'module-protocol-pulse/manager.c',
@ -246,6 +241,14 @@ pipewire_module_protocol_pulse_sources = [
'module-protocol-pulse/modules/module-zeroconf-discover.c', 'module-protocol-pulse/modules/module-zeroconf-discover.c',
] ]
if dbus_dep.found()
pipewire_module_protocol_pulse_sources += [
'module-protocol-pulse/dbus-name.c',
]
pipewire_module_protocol_pulse_deps += dbus_dep
cdata.set('HAVE_DBUS', 1)
endif
if avahi_dep.found() if avahi_dep.found()
pipewire_module_protocol_pulse_sources += [ pipewire_module_protocol_pulse_sources += [
'module-protocol-pulse/modules/module-zeroconf-publish.c', 'module-protocol-pulse/modules/module-zeroconf-publish.c',

View file

@ -4936,8 +4936,10 @@ static void impl_free(struct impl *impl)
struct client *c; struct client *c;
struct message *msg; struct message *msg;
#if HAVE_DBUS
if (impl->dbus_name) if (impl->dbus_name)
dbus_release_name(impl->dbus_name); dbus_release_name(impl->dbus_name);
#endif
spa_list_consume(msg, &impl->free_messages, link) spa_list_consume(msg, &impl->free_messages, link)
message_free(impl, msg, true, true); message_free(impl, msg, true, true);
@ -5111,7 +5113,9 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
pw_context_add_listener(context, &impl->context_listener, pw_context_add_listener(context, &impl->context_listener,
&context_events, impl); &context_events, impl);
#if HAVE_DBUS
impl->dbus_name = dbus_request_name(context, "org.pulseaudio.Server"); impl->dbus_name = dbus_request_name(context, "org.pulseaudio.Server");
#endif
return (struct pw_protocol_pulse *) impl; return (struct pw_protocol_pulse *) impl;

View file

@ -67,8 +67,10 @@ elif not sndfile_dep.found() and get_option('pw-cat').enabled()
endif endif
summary({'Build pw-cat tool': build_pw_cat}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump tool') summary({'Build pw-cat tool': build_pw_cat}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump tool')
executable('pw-reserve', if dbus_dep.found()
'pw-reserve.c', executable('pw-reserve',
install: true, 'pw-reserve.c',
dependencies : [dbus_dep, pipewire_dep], install: true,
) dependencies : [dbus_dep, pipewire_dep],
)
endif

View file

@ -74,8 +74,6 @@ test('test context',
'test-config.c', 'test-config.c',
include_directories: pwtest_inc, include_directories: pwtest_inc,
link_with: [pwtest_lib, link_with: [pwtest_lib,
spa_support_lib,
spa_dbus_lib,
pipewire_module_protocol_native, pipewire_module_protocol_native,
pipewire_module_client_node, pipewire_module_client_node,
pipewire_module_client_device, pipewire_module_client_device,

View file

@ -227,7 +227,9 @@ PWTEST(context_support)
SPA_TYPE_INTERFACE_Loop, SPA_TYPE_INTERFACE_Loop,
SPA_TYPE_INTERFACE_LoopUtils, SPA_TYPE_INTERFACE_LoopUtils,
SPA_TYPE_INTERFACE_Log, SPA_TYPE_INTERFACE_Log,
#if HAVE_DBUS
SPA_TYPE_INTERFACE_DBus, SPA_TYPE_INTERFACE_DBus,
#endif
SPA_TYPE_INTERFACE_CPU SPA_TYPE_INTERFACE_CPU
}; };