From 4907635f8f8c32cc02342f1933f9ca33f5a2540b Mon Sep 17 00:00:00 2001 From: Frantisek Tobias Date: Tue, 31 Dec 2024 13:24:18 +0100 Subject: [PATCH] Module filter: make libidn2 and libpcre2 optional. If they are missing filter module will not be built --- meson.build | 5 +++-- modules/filter/filter.test.lua | 8 ++++++-- modules/filter/meson.build | 28 +++++++++++++++------------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/meson.build b/meson.build index d65014370..543a5e3ac 100644 --- a/meson.build +++ b/meson.build @@ -27,8 +27,6 @@ lmdb = dependency('lmdb', required: false) if not lmdb.found() # darwin workaround: missing pkgconfig lmdb = meson.get_compiler('c').find_library('lmdb') endif -libidn2 = dependency('libidn2', version: '>=2.0.0') -libpcre2 = dependency('libpcre2-8', version: '>=10.00') gnutls = dependency('gnutls', version: '>=3.4') luajit = dependency('luajit') # https://mesonbuild.com/howtox.html#add-math-library-lm-portably @@ -166,6 +164,9 @@ malloc = meson.get_compiler('c').find_library( # Fortunately it seems unlikely that dynamic wouldn't be found and static would be. ) +### filter module +libidn2 = dependency('libidn2', version: '>=2.0.0', required: false) +libpcre2 = dependency('libpcre2-8', version: '>=10.00', required: false) message('---------------------------') ## Compiler args diff --git a/modules/filter/filter.test.lua b/modules/filter/filter.test.lua index c59424881..061804362 100644 --- a/modules/filter/filter.test.lua +++ b/modules/filter/filter.test.lua @@ -1,9 +1,13 @@ -- SPDX-License-Identifier: GPL-3.0-or-later +-- try loading the module +local has_filter = pcall(modules.load, 'filter') +if not has_filter then + os.exit(77) -- SKIP filter tests +end + local kres = require('kres') local condition = require('cqueues.condition') -modules = { 'filter' } - -- helper to wait for query resolution local function wait_resolve(qname) local waiting, done, cond = false, false, condition.new() diff --git a/modules/filter/meson.build b/modules/filter/meson.build index fe8a5a1e9..82fb216aa 100644 --- a/modules/filter/meson.build +++ b/modules/filter/meson.build @@ -10,16 +10,18 @@ config_tests += [ ['filter', files('filter.test.lua')], ] -filter_mod = shared_module( - 'filter', - filter_src, - dependencies: mod_deps + [ - libidn2, - libpcre2 - ], - include_directories: mod_inc_dir, - name_prefix: '', - install: true, - install_dir: modules_dir, - link_with: kresd, -) +if libidn2.found() and libpcre2.found() + filter_mod = shared_module( + 'filter', + filter_src, + dependencies: mod_deps + [ + libidn2, + libpcre2, + ], + include_directories: mod_inc_dir, + name_prefix: '', + install: true, + install_dir: modules_dir, + link_with: kresd, + ) +endif