Commit 87678cbd authored by Tomas Krizek's avatar Tomas Krizek

meson: daemon/kres-gen - fix lua file generation

parent 2b5e5659
#!/bin/bash
set -o pipefail -o errexit
# Run with "ninja kres-gen" to re-generate kres-gen.lua
set -o pipefail -o errexit -o nounset
cd "$(dirname ${0})"
CDEFS="../../scripts/gen-cdefs.sh"
LIBKRES="${MESON_BUILD_ROOT}/lib/libkres.so"
# Write to .kres-gen.lua.tmp instead of STDOUT
exec 1<&-
exec 1<>.kres-gen.lua.tmp
err_handle() {
# Write to kres-gen.lua instead of stdout
mv kres-gen.lua{,.bak} ||:
exec 1>&-
exec 1<>kres-gen.lua
restore() {
exec 1>&-
mv kres-gen.lua{.bak,} ||:
(>&2 echo "Failed to re-generate kres-gen.lua! Missing debugsymbols?")
rm -f .kres-gen.lua.tmp
}
trap err_handle ERR INT TERM
trap restore ERR INT TERM
### Dev's guide
#
......@@ -52,7 +57,7 @@ typedef void (*trace_log_f) (const struct kr_query *, const char *, const char *
typedef void (*trace_callback_f)(struct kr_request *);
"
${CDEFS} libkres types <<-EOF
${CDEFS} ${LIBKRES} types <<-EOF
knot_section_t
knot_rrinfo_t
knot_dname_t
......@@ -61,13 +66,13 @@ ${CDEFS} libkres types <<-EOF
EOF
genResType() {
echo "$1" | ${CDEFS} libkres types
echo "$1" | ${CDEFS} ${LIBKRES} types
}
# No simple way to fixup this rename in ./kres.lua AFAIK.
genResType "knot_rrset_t" | sed 's/\<owner\>/_owner/; s/\<ttl\>/_ttl/'
${CDEFS} libkres types <<-EOF
${CDEFS} ${LIBKRES} types <<-EOF
knot_pkt_t
knot_edns_options_t
knot_pktsection_t
......@@ -141,7 +146,7 @@ ${CDEFS} libknot functions <<-EOF
EOF
## libkres API
${CDEFS} libkres functions <<-EOF
${CDEFS} ${LIBKRES} functions <<-EOF
# Resolution request
kr_resolve_plan
kr_resolve_pool
......@@ -228,7 +233,7 @@ EOF
printf "]]\n"
mv .kres-gen-lua.tmp kres-gen.lua
(>&2 echo "Successfully re-generated "${PWD}/kres-gen.lua")
rm kres-gen.lua.bak ||:
(>&2 echo "Successfully re-generated ${PWD}/kres-gen.lua")
exit 0
......@@ -20,6 +20,11 @@ config_lua = configure_file(
configuration: ta_config,
)
run_target( # run manually to re-generate kres-gen.lua
'kres-gen',
command: find_program('./kres-gen.sh'),
)
# install daemon lua sources
install_data([
config_lua,
......
......@@ -26,7 +26,7 @@ fi
case "$1" in
libknot) library="$(PATH="$(pkg-config libknot --variable=libdir)" command -v "$1.so")" ;;
libzscanner) library="$(PATH="$(pkg-config libzscanner --variable=libdir)" command -v "$1.so")" ;;
*) library="$(PATH="$(pwd)/lib" command -v "$1.so")"
*) library="$(command -v "$1")" # use absolute path to library
esac
if [ -z "$library" ]; then
......@@ -60,6 +60,8 @@ grep -v '^#\|^$' | while read -r ident; do
output="$(echo "$output" | sed 's/\buint\b/unsigned int/g')"
# GDB 8.2+ added source line prefix to output
output="$(echo "$output" | sed 's/^[0-9]\+:[[:space:]]*//g')"
# use tabs instead of spaces
output="$(echo "$output" | sed 's/ /\t/g')"
# abort on empty output
if [ -z "$(echo "$output" | tr -d "\n;")" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment