Skip to content

Commit

Permalink
Module filter: make libidn2 and libpcre2 optional. If they are missing
Browse files Browse the repository at this point in the history
filter module will not be built
  • Loading branch information
Frantisek Tobias committed Dec 31, 2024
1 parent 47a844d commit 4907635
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
5 changes: 3 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions modules/filter/filter.test.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
28 changes: 15 additions & 13 deletions modules/filter/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4907635

Please sign in to comment.