From 75314098095bccb0bdae7aad02dd79e7a00ca891 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Wed, 4 May 2011 13:03:58 +0000 Subject: [PATCH] use conventional exectuble integration methods --- Makefile.am | 17 +++++------------ bin2carray.lua | 5 +++-- lsyncd.c | 7 +++---- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Makefile.am b/Makefile.am index 957ec17..f437b90 100644 --- a/Makefile.am +++ b/Makefile.am @@ -45,20 +45,13 @@ else # or compiles it into the binary lsyncd_LDADD += luac.o -objarch: | lsyncd.o - objdump -f lsyncd.o | grep architecture | \ - sed -e "s/,.*$$//" -e "s/[^ ]* \(.*\)/\1/" > $@ || rm $@ - -objtarget: | lsyncd.o - objdump -f lsyncd.o | grep "file format" | \ - sed -e "s/.* \(.*\)/\1/" > $@ || rm $@ - -luac.o: luac.out objarch objtarget - objcopy --input-target=binary \ - --output-target=`cat objtarget` \ - --binary-architecture=`cat objarch` $< $@ +luac.o: luac.c luac.out: lsyncd.lua luac $< + +luac.c: lsyncd.lua bin2carray.lua + lua ./bin2carray.lua lsyncd.lua luac luac.c + endif diff --git a/bin2carray.lua b/bin2carray.lua index eb9127c..b216b5a 100755 --- a/bin2carray.lua +++ b/bin2carray.lua @@ -25,7 +25,8 @@ if fout == nil then end fout:write("/* created by "..arg[0].." from file "..arg[1].." */\n") -fout:write("const unsigned char "..arg[2].."[] = {\n") +fout:write("#include \n") +fout:write("const unsigned char "..arg[2].."_out[] = {\n") while true do local block = fin:read(16) if block == nil then @@ -40,7 +41,7 @@ while true do end fout:write("\n") end -fout:write("};"); +fout:write("};\n\nsize_t "..arg[2].."_size = sizeof("..arg[2].."_out);\n"); fin:close(); fout:close(); diff --git a/lsyncd.c b/lsyncd.c index 1b07642..82dea2a 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -45,8 +45,8 @@ * The Lua part of lsyncd if compiled into the binary. */ #ifndef LSYNCD_DEFAULT_RUNNER_FILE - extern char _binary_luac_out_start; - extern char _binary_luac_out_end; + extern unsigned char * luac_out; + extern size_t luac_size; #endif /** @@ -1837,8 +1837,7 @@ main1(int argc, char *argv[]) } else { #ifndef LSYNCD_DEFAULT_RUNNER_FILE /* loads the runner from binary */ - if (luaL_loadbuffer(L, &_binary_luac_out_start, - &_binary_luac_out_end - &_binary_luac_out_start, "lsyncd.lua")) + if (luaL_loadbuffer(L, luac_out, luac_size, "lsyncd.lua")) { printlogf(L, "Error", "error loading precompiled lsyncd.lua runner: %s",