From 7586d4d858dbc346806b45f93f12ffa9bd657c2e Mon Sep 17 00:00:00 2001 From: "Tom A. Wagner" Date: Wed, 16 Nov 2022 11:29:13 +0100 Subject: [PATCH] meson: Add options to configure whether to build daemon, tools and modules. This adds three meson options to enable or disable building daemon, tools, and modules. Building the daemon or tools depends on building the modules, and disabling modules without disabling the other two will result in meson giving an appropriate error. These new options will let users skip building and installing unneeded items when they are not needed, e.g. when only using the C API in another application. --- docs/rst/installing-wireplumber.rst | 22 ++++++ meson.build | 102 ++++++++++++++++------------ meson_options.txt | 6 ++ src/meson.build | 51 +++++++------- tests/meson.build | 6 +- 5 files changed, 119 insertions(+), 68 deletions(-) diff --git a/docs/rst/installing-wireplumber.rst b/docs/rst/installing-wireplumber.rst index 5fb76603..bf6a116c 100644 --- a/docs/rst/installing-wireplumber.rst +++ b/docs/rst/installing-wireplumber.rst @@ -64,6 +64,28 @@ Additional options The default value is **auto**, which means that documentation will be built if **doxygen**, **sphinx** and **breathe** are found and skipped otherwise. +.. option:: -Dmodules=[true|false] + + Build the wireplumber modules. + + The default value is **true**. + +.. option:: -Ddaemon=[true|false] + + Build the session manager daemon. + + The default value is **true**. + + Requires **modules** option to be **true**. + +.. option:: -Dtools=[true|false] + + Enable or disable building tools. + + The default value is **true**. + + Requires **modules** option to be **true**. + .. option:: -Dsystem-lua=[enabled|disabled|auto] Force using lua from the system instead of the bundled one. diff --git a/meson.build b/meson.build index 7e54fc7b..1e0e8518 100644 --- a/meson.build +++ b/meson.build @@ -33,6 +33,16 @@ add_project_arguments([ ], language: 'c' ) +build_modules = get_option('modules') +build_daemon = get_option('daemon') +if build_daemon and not build_modules + error('\'modules\' option is required to be true when the \'daemon\' option is true') +endif +build_tools = get_option('tools') +if build_tools and not build_modules + error('\'modules\' option is required to be true when the \'tools\' option is enabled') +endif + glib_dep = dependency('glib-2.0', version : glib_req_version) gobject_dep = dependency('gobject-2.0', version : glib_req_version) gmodule_dep = dependency('gmodule-2.0', version : glib_req_version) @@ -44,54 +54,58 @@ mathlib = cc.find_library('m') threads_dep = dependency('threads') libintl_dep = dependency('intl') -system_lua = get_option('system-lua') -if system_lua - if get_option('system-lua-version') != 'auto' - lua_version_requested = get_option('system-lua-version') - lua_dep = dependency('lua-' + lua_version_requested, required: false) - if not lua_dep.found() - lua_dep = dependency('lua' + lua_version_requested, required: false) - endif +if build_modules + system_lua = get_option('system-lua') + if system_lua + if get_option('system-lua-version') != 'auto' + lua_version_requested = get_option('system-lua-version') + lua_dep = dependency('lua-' + lua_version_requested, required: false) + if not lua_dep.found() + lua_dep = dependency('lua' + lua_version_requested, required: false) + endif - if not lua_dep.found() - error('Specified Lua version "' + lua_version_requested + '" not found') + if not lua_dep.found() + error('Specified Lua version "' + lua_version_requested + '" not found') + endif + else + lua_dep = dependency('lua-5.4', required: false) + if not lua_dep.found() + lua_dep = dependency('lua5.4', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua54', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua-5.3', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua5.3', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua53', required: false) + endif + if not lua_dep.found() + lua_dep = dependency('lua', version: ['>=5.3.0'], required: false) + endif + if not lua_dep.found() + error ('Could not find lua. Lua version 5.4 or 5.3 required') + endif endif else - lua_dep = dependency('lua-5.4', required: false) - if not lua_dep.found() - lua_dep = dependency('lua5.4', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua54', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua-5.3', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua5.3', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua53', required: false) - endif - if not lua_dep.found() - lua_dep = dependency('lua', version: ['>=5.3.0'], required: false) - endif - if not lua_dep.found() - error ('Could not find lua. Lua version 5.4 or 5.3 required') - endif + lua_proj = subproject('lua', default_options: ['default_library=static']) + lua_dep = lua_proj.get_variable('lua_dep') endif -else - lua_proj = subproject('lua', default_options: ['default_library=static']) - lua_dep = lua_proj.get_variable('lua_dep') + summary({'Lua version': lua_dep.version() + (system_lua ? ' (system)' : ' (built-in)')}) endif -summary({'Lua version': lua_dep.version() + (system_lua ? ' (system)' : ' (built-in)')}) -systemd = dependency('systemd', required: get_option('systemd')) -libsystemd_dep = dependency('libsystemd',required: get_option('systemd')) -libelogind_dep = dependency('libelogind', required: get_option('elogind')) -summary({'systemd conf data': systemd.found(), - 'libsystemd': libsystemd_dep.found(), - 'libelogind': libelogind_dep.found()}, bool_yn: true) +if build_modules + systemd = dependency('systemd', required: get_option('systemd')) + libsystemd_dep = dependency('libsystemd',required: get_option('systemd')) + libelogind_dep = dependency('libelogind', required: get_option('elogind')) + summary({'systemd conf data': systemd.found(), + 'libsystemd': libsystemd_dep.found(), + 'libelogind': libelogind_dep.found()}, bool_yn: true) +endif gnome = import('gnome') pkgconfig = import('pkgconfig') @@ -121,7 +135,9 @@ add_project_arguments(cc.get_supported_arguments(common_flags), language: 'c') subdir('lib') subdir('docs') -subdir('modules') +if build_modules + subdir('modules') +endif subdir('src') subdir('po') diff --git a/meson_options.txt b/meson_options.txt index 5fef47d8..76bd8a97 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,6 +2,12 @@ option('introspection', type : 'feature', value : 'auto', description : 'Generate gobject-introspection bindings') option('doc', type : 'feature', value : 'auto', description: 'Enable documentation.') +option('modules', type : 'boolean', value: 'true', + description : 'Build modules') +option('daemon', type : 'boolean', value: 'true', + description : 'Build session manager daemon') +option('tools', type : 'boolean', value: 'true', + description : 'Build CLI tools') option('system-lua', type : 'boolean', value : 'false', description : 'Use lua from the system instead of the bundled one') option('system-lua-version', diff --git a/src/meson.build b/src/meson.build index 08e9ae2a..2cc70794 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,26 +1,31 @@ -wp_sources = [ - 'main.c', -] +if build_tools + subdir('tools') +endif -install_subdir('config', - install_dir: wireplumber_data_dir, - strip_directory : true -) -install_subdir('scripts', - install_dir: wireplumber_data_dir, - strip_directory : false -) +if build_daemon + subdir('systemd') -subdir('systemd') -subdir('tools') + install_subdir('config', + install_dir: wireplumber_data_dir, + strip_directory : true + ) + install_subdir('scripts', + install_dir: wireplumber_data_dir, + strip_directory : false + ) -wireplumber = executable('wireplumber', - wp_sources, - c_args : [ - '-D_GNU_SOURCE', - '-DG_LOG_USE_STRUCTURED', - '-DG_LOG_DOMAIN="wireplumber"', - ], - install: true, - dependencies : [gobject_dep, gio_dep, wp_dep, pipewire_dep], -) + wp_sources = [ + 'main.c', + ] + + wireplumber = executable('wireplumber', + wp_sources, + c_args : [ + '-D_GNU_SOURCE', + '-DG_LOG_USE_STRUCTURED', + '-DG_LOG_DOMAIN="wireplumber"', + ], + install: true, + dependencies : [gobject_dep, gio_dep, wp_dep, pipewire_dep], + ) +endif diff --git a/tests/meson.build b/tests/meson.build index 0e065682..de77cf06 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -60,6 +60,8 @@ if pipewire_confdatadir != '' endif subdir('wp') -subdir('wplua') -subdir('modules') +if build_modules + subdir('wplua') + subdir('modules') +endif subdir('examples')