Skip to content
Snippets Groups Projects

build: fix when knot-dns headers are on non-standard location

Merged Vladimír Čunát requested to merge knot-headers into master
Files
11
+ 16
8
@@ -59,24 +59,32 @@ run_target( # run manually to re-generate kres-gen.lua
# but this basic sanity check could be ran always, except for cross compilation,
# as we *run* luajit to find out the real sizes.
if get_option('kres_gen_test') and not meson.is_cross_build()
types_to_check = {
'time_t' : '#include <sys/time.h>',
'struct timeval' : '#include <sys/time.h>',
'zs_scanner_t' : '#include <libzscanner/scanner.h>',
'knot_pkt_t' : '#include <libknot/packet/pkt.h>',
}
types_to_check = [
{ 'tname': 'time_t', 'incl': '#include <sys/time.h>' },
{ 'tname': 'struct timeval', 'incl' : '#include <sys/time.h>' },
{ 'tname': 'zs_scanner_t', 'incl': '#include <libzscanner/scanner.h>', 'dep': libzscanner },
{ 'tname': 'knot_pkt_t', 'incl' : '#include <libknot/packet/pkt.h>', 'dep': libknot },
]
# Construct the lua tester as a meson string.
kres_gen_test_luastr = '''
dofile('@0@')
local ffi = require('ffi')
'''.format(meson.current_source_dir() / kres_gen_fname)
foreach tname, tinclude: types_to_check
foreach ttc: types_to_check
# We're careful with adding just includes; otherwise it's more fragile (e.g. linking flags).
if 'dep' in ttc
dep = ttc.get('dep').partial_dependency(includes: true, compile_args: true)
else
dep = []
endif
tsize = meson.get_compiler('c').sizeof(ttc.get('tname'), prefix: ttc.get('incl'),
dependencies: dep)
kres_gen_test_luastr += '''
assert(ffi.sizeof(ffi.typeof('@0@')) == @1@,
'Lua binding for C type ' .. '@0@' .. ' has incorrect size: '
.. ffi.sizeof(ffi.typeof('@0@'))
)
'''.format(tname, meson.get_compiler('c').sizeof(tname, prefix : tinclude))
'''.format(ttc.get('tname'), tsize)
endforeach
# Now feed it directly into luajit.
kres_gen_test = run_command(find_program('luajit'), '-e', kres_gen_test_luastr)
Loading