diff mbox series

[RFC,14/14] lib: allow disabling optional libraries

Message ID 20210401115009.1063844-15-bruce.richardson@intel.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series Build file update proposals | expand

Checks

Context Check Description
ci/intel-Testing success Testing PASS
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson April 1, 2021, 11:50 a.m. UTC
Add support for the disable_libs option, to allow disabling the build of
particular libraries. As part of this, maintain a list of what libraries
can safely be disabled, without breaking the build - for now this list is
solely those libraries which are not built on FreeBSD, kni, power and
vhost. This list can be expanded by future patches.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/meson.build   | 24 +++++++++++++++++++++++-
 meson_options.txt |  2 ++
 2 files changed, 25 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/meson.build b/lib/meson.build
index dc236c06de..aedc345c7f 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -49,6 +49,23 @@  if is_windows
     ] # only supported libraries for windows
 endif
 
+optional_libs = [
+    'kni',
+    'power',
+    'vhost',
+]
+
+disabled_libs = []
+opt_disabled_libs = run_command(list_dir_globs, get_option('disable_libs')).stdout().split()
+foreach l:opt_disabled_libs
+    if not optional_libs.contains(l)
+        warning('Cannot disable mandatory library "@0@"'.format(l))
+        continue
+    endif
+    disabled_libs += l
+endforeach
+
+
 default_cflags = machine_args
 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
 default_cflags += ['-DALLOW_INTERNAL_API']
@@ -81,7 +98,12 @@  foreach l:libraries
         deps += ['eal']
     endif
 
-    subdir(l)
+    if disabled_libs.contains(l)
+        build = false
+        reason = 'explicitly disabled via build config'
+    else
+        subdir(l)
+    endif
     if name != l
         warning('Library name, "@0@", and directory name, "@1@", do not match'.format(name, l))
     endif
diff --git a/meson_options.txt b/meson_options.txt
index f22db9fb7d..4a9d41127d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,6 +4,8 @@  option('check_includes', type: 'boolean', value: false,
     description: 'build "chkincs" to verify each header file can compile alone')
 option('disable_drivers', type: 'string', value: '',
     description: 'Comma-separated list of drivers to explicitly disable.')
+option('disable_libs', type: 'string', value: '',
+    description: 'Comma-separated list of libraries to explicitly disable. [NOTE: not all libs can be disabled]')
 option('drivers_install_subdir', type: 'string', value: 'dpdk/pmds-<VERSION>',
     description: 'Subdirectory of libdir where to install PMDs. Defaults to using a versioned subdirectory.')
 option('enable_docs', type: 'boolean', value: false,