From 87678cbd49344dd460b01192b6d6bc02d03260ee Mon Sep 17 00:00:00 2001 From: Tomas Krizek Date: Tue, 19 Feb 2019 14:56:37 +0100 Subject: [PATCH] meson: daemon/kres-gen - fix lua file generation --- daemon/lua/kres-gen.sh | 31 ++++++++++++++++++------------- daemon/lua/meson.build | 5 +++++ scripts/gen-cdefs.sh | 4 +++- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/daemon/lua/kres-gen.sh b/daemon/lua/kres-gen.sh index e87ed2dfe..1f626beb1 100755 --- a/daemon/lua/kres-gen.sh +++ b/daemon/lua/kres-gen.sh @@ -1,17 +1,22 @@ #!/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/; s/\/_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 diff --git a/daemon/lua/meson.build b/daemon/lua/meson.build index 8ea688777..54ce16b9f 100644 --- a/daemon/lua/meson.build +++ b/daemon/lua/meson.build @@ -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, diff --git a/scripts/gen-cdefs.sh b/scripts/gen-cdefs.sh index 0627fa40b..ae7ed9fca 100755 --- a/scripts/gen-cdefs.sh +++ b/scripts/gen-cdefs.sh @@ -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 -- 2.47.2