mudgangster

Log | Files | Refs

commit c0a09fef53d7ae892837c2b94892ad4728e7fb0f
parent 30d4b625eafbc6264eee00aa41a4327c99d151ce
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Thu,  6 Sep 2018 10:08:53 +0300

Pack a Lua script into the bin instead of bytecode

Diffstat:
Makefile | 8++++----
scripts/pack_lua.sh | 3+--
src/script.cc | 6+++---
3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,19 +1,19 @@ all: debug .PHONY: debug asan release clean -build/lua_bytecode.h: src/lua/action.lua src/lua/alias.lua src/lua/chat.lua src/lua/mud.lua src/lua/event.lua src/lua/gag.lua src/lua/handlers.lua src/lua/intercept.lua src/lua/interval.lua src/lua/macro.lua src/lua/main.lua src/lua/script.lua src/lua/serialize.lua src/lua/status.lua src/lua/sub.lua src/lua/utils.lua src/lua/socket.lua +build/lua_combined.h: src/lua/action.lua src/lua/alias.lua src/lua/chat.lua src/lua/mud.lua src/lua/event.lua src/lua/gag.lua src/lua/handlers.lua src/lua/intercept.lua src/lua/interval.lua src/lua/macro.lua src/lua/main.lua src/lua/script.lua src/lua/serialize.lua src/lua/status.lua src/lua/sub.lua src/lua/utils.lua src/lua/socket.lua @printf "\033[1;33mbuilding $@\033[0m\n" @scripts/pack_lua.sh -debug: build/lua_bytecode.h +debug: build/lua_combined.h @lua make.lua > gen.mk @$(MAKE) -f gen.mk -asan: build/lua_bytecode.h +asan: build/lua_combined.h @lua make.lua asan > gen.mk @$(MAKE) -f gen.mk -release: build/lua_bytecode.h +release: build/lua_combined.h @lua make.lua release > gen.mk @$(MAKE) -f gen.mk diff --git a/scripts/pack_lua.sh b/scripts/pack_lua.sh @@ -4,5 +4,4 @@ set -o pipefail mkdir -p build lua scripts/merge.lua src/lua main.lua > build/lua_combined.lua -#exec lua scripts/merge.lua src/lua main.lua | luac -o - - | lua scripts/bin2arr.lua > build/lua_bytecode.h -exec lua scripts/merge.lua src/lua main.lua | lua scripts/bin2arr.lua > build/lua_bytecode.h +exec lua scripts/merge.lua src/lua main.lua | lua scripts/bin2arr.lua > build/lua_combined.h diff --git a/src/script.cc b/src/script.cc @@ -14,8 +14,8 @@ #define luaL_len lua_objlen #endif -static const uint8_t lua_bytecode[] = { -#include "../build/lua_bytecode.h" +static const uint8_t lua_combined[] = { +#include "../build/lua_combined.h" }; static lua_State * lua; @@ -253,7 +253,7 @@ void script_init() { lua_getfield( lua, -1, "traceback" ); lua_remove( lua, -2 ); - if( luaL_loadbufferx( lua, ( const char * ) lua_bytecode, sizeof( lua_bytecode ), "main", "t" ) != LUA_OK ) { + if( luaL_loadbufferx( lua, ( const char * ) lua_combined, sizeof( lua_combined ), "main", "t" ) != LUA_OK ) { printf( "Error reading main.lua: %s\n", lua_tostring( lua, -1 ) ); exit( 1 ); }