From e723b039ad50485dc70fecb7e59553633c28a2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislav=20Ochotnick=C3=BD?= Date: Thu, 16 Sep 2021 10:24:53 +0200 Subject: [PATCH] Make libmpdclient an optional dependency Without this change yambar can't be installed/used without libmpdclient even for people who do not use MPD. Let's make this optional. We could put the optional module summary in the module meson.build but we'd have to move summary() in main meson.build so that they appear in proper order. --- CHANGELOG.md | 4 ++++ meson.build | 7 +++++++ meson_options.txt | 3 +++ modules/meson.build | 10 ++++++++-- plugin.c | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e46d99f..8f4100b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ ## Unreleased ### Added ### Changed + +* Made `libmpdclient` an optional dependency + ### Deprecated ### Removed ### Fixed @@ -22,6 +25,7 @@ ### Security ### Contributors +* [sochotnicky](https://codeberg.org/sochotnicky) ## 1.7.0 diff --git a/meson.build b/meson.build index b7065e6..08d21bc 100644 --- a/meson.build +++ b/meson.build @@ -119,6 +119,7 @@ yambar = executable( version, dependencies: [bar, pixman, yaml, threads, dl, tllist, fcft] + decorations + particles + modules, + c_args: [plugin_mpd_enabled? '-DPLUGIN_ENABLED_MPD':[]], build_rpath: '$ORIGIN/modules:$ORIGIN/decorations:$ORIGIN/particles', export_dynamic: true, install: true, @@ -153,3 +154,9 @@ summary( }, bool_yn: true ) + +summary( + {'Music Player Daemon (MPD)': plugin_mpd_enabled}, + section: 'Optional modules', + bool_yn: true +) diff --git a/meson_options.txt b/meson_options.txt index f293c6f..15dc3e9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,3 +5,6 @@ option( option( 'core-plugins-as-shared-libraries', type: 'boolean', value: false, description: 'Compiles modules, particles and decorations as shared libraries, which are loaded on-demand') +option( + 'plugin-mpd', type: 'feature', value: 'auto', + description: 'Music Player Daemon (MPD) support') diff --git a/modules/meson.build b/modules/meson.build index dbaa7a7..6b64958 100644 --- a/modules/meson.build +++ b/modules/meson.build @@ -5,9 +5,12 @@ modules = [] alsa = dependency('alsa') udev = dependency('libudev') json = dependency('json-c') -mpd = dependency('libmpdclient') xcb_xkb = dependency('xcb-xkb', required: get_option('backend-x11')) +# Optional deps +mpd = dependency('libmpdclient', required: get_option('plugin-mpd')) +plugin_mpd_enabled = mpd.found() + # Module name -> (source-list, dep-list) mod_data = { 'alsa': [[], [m, alsa]], @@ -16,13 +19,16 @@ mod_data = { 'clock': [[], []], 'i3': [['i3-common.c', 'i3-common.h'], [dynlist, json]], 'label': [[], []], - 'mpd': [[], [mpd]], 'network': [[], []], 'removables': [[], [dynlist, udev]], 'script': [[], []], 'sway-xkb': [['i3-common.c', 'i3-common.h'], [dynlist, json]], } +if plugin_mpd_enabled + mod_data += {'mpd': [[], [mpd]]} +endif + if backend_x11 mod_data += { 'xkb': [[], [xcb_stuff, xcb_xkb]], diff --git a/plugin.c b/plugin.c index 5e0e4bc..00b0061 100644 --- a/plugin.c +++ b/plugin.c @@ -39,7 +39,9 @@ EXTERN_MODULE(clock); EXTERN_MODULE(foreign_toplevel); EXTERN_MODULE(i3); EXTERN_MODULE(label); +#if defined(PLUGIN_ENABLED_MPD) EXTERN_MODULE(mpd); +#endif EXTERN_MODULE(network); EXTERN_MODULE(removables); EXTERN_MODULE(river); @@ -117,7 +119,9 @@ init(void) #endif REGISTER_CORE_MODULE(i3, i3); REGISTER_CORE_MODULE(label, label); +#if defined(PLUGIN_ENABLED_MPD) REGISTER_CORE_MODULE(mpd, mpd); +#endif REGISTER_CORE_MODULE(network, network); REGISTER_CORE_MODULE(removables, removables); #if defined(HAVE_PLUGIN_river)