]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
build: compile Lua bytecode for embedded code
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 8 Apr 2015 14:21:24 +0000 (16:21 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 8 Apr 2015 14:21:24 +0000 (16:21 +0200)
config.mk
daemon/daemon.mk
daemon/engine.c

index 004fced6a3b3d5db5217fe264ff9692bfdc1503e..78d1340d8397279d9c8aba10fab36c7124eb932f 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -17,5 +17,6 @@ CFLAGS  += -DPACKAGE_VERSION="\"$(MAJOR).$(MINOR)\"" -DPREFIX="\"$(PREFIX)\"" -D
 RM     := rm -f
 LN      := ln -s
 XXD     ?= xxd
+LUAC    ?= luac
 INSTALL := install
 PYTHON  := python
index 918738d55713c17b63d8db57aee3e45edb12a894..64510f0dfdab6aa2de041e98e98da49a7d21ef0f 100644 (file)
@@ -10,8 +10,9 @@ kresolved_SOURCES := \
 # Embed resources
 daemon/engine.o: daemon/lua/init.inc daemon/lua/config.inc
 %.inc: %.lua
-       @$(call quiet,XXD,$<) -i < $< > $@
-       @echo ', 0x00' >> $@
+       @$(call quiet,LUAC,$<) -o $<.out $<
+       @$(call quiet,XXD,$<) -i - < $<.out > $@
+       @$(RM) $<.out
 
 # Dependencies
 kresolved_DEPEND := $(libkresolve)
index 8d33a4d2f77c4c7b2dad3acda7ec3446e54e0424..ae94b09daf19fa92b0c9ce9a28004daea2616f9e 100644 (file)
@@ -192,6 +192,9 @@ int engine_cmd(struct engine *engine, const char *str)
        return kr_ok();
 }
 
+/* Execute byte code */
+#define l_dobytecode(L, arr, len, name) \
+       (luaL_loadbuffer((L), (arr), (len), (name)) || lua_pcall((L), 0, LUA_MULTRET, 0))
 static int engine_loadconf(struct engine *engine)
 {
        /* Init environment */