#!/bin/bash
set -o pipefail -o errexit
+cd "$(dirname ${0})"
+CDEFS="../../scripts/gen-cdefs.sh"
+
+# Write to .kres-gen.lua.tmp instead of STDOUT
+exec 1<&-
+exec 1<>.kres-gen.lua.tmp
+err_handle() {
+ (>&2 echo "Failed to re-generate kres-gen.lua! Missing debugsymbols?")
+ rm -f .kres-gen.lua.tmp
+}
+trap err_handle ERR INT TERM
+
### Dev's guide
#
# C declarations for lua are (mostly) generated to simplify maintenance.
typedef void (*trace_callback_f)(struct kr_request *);
"
-./scripts/gen-cdefs.sh libkres types <<-EOF
+${CDEFS} libkres types <<-EOF
knot_section_t
knot_rrinfo_t
knot_dname_t
EOF
genResType() {
- echo "$1" | ./scripts/gen-cdefs.sh 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/'
-./scripts/gen-cdefs.sh libkres types <<-EOF
+${CDEFS} libkres types <<-EOF
knot_pkt_t
knot_edns_options_t
knot_pktsection_t
printf "\tchar _stub[];\n};\n"
## libknot API
-./scripts/gen-cdefs.sh libknot functions <<-EOF
+${CDEFS} libknot functions <<-EOF
# Utils
knot_strerror
# Domain names
EOF
## libkres API
-./scripts/gen-cdefs.sh libkres functions <<-EOF
+${CDEFS} libkres functions <<-EOF
# Resolution request
kr_resolve_plan
kr_resolve_pool
## libzscanner API for ./zonefile.lua
-./scripts/gen-cdefs.sh libzscanner types <<-EOF
+${CDEFS} libzscanner types <<-EOF
zs_win_t
zs_apl_t
zs_loc_t
zs_scanner_t
struct zs_scanner
EOF
-./scripts/gen-cdefs.sh libzscanner functions <<-EOF
+${CDEFS} libzscanner functions <<-EOF
zs_deinit
zs_init
zs_parse_record
printf "]]\n"
+mv .kres-gen-lua.tmp kres-gen.lua
+(>&2 echo "Successfully re-generated "${PWD}/kres-gen.lua")
+
exit 0