lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Mar 30, 2012 at 6:30 PM, Robert G. Jakabosky
<bobby@sharedrealm.com> wrote:
> This could be done by modifying the Lua compiler written in Lua [1].
> 1. http://lua-users.org/wiki/LuaCompilerInLua

Maybe something along these lines:

MODULES = \
    HTTP.lua \
    Template.lua \
    . . . etc . . .
RUN_CODE=pre.lua Nanoki.lua
Nanoki.luac: $(MODULES) $(RUN_MODULES)
	mkdir -p tmp
	for x in $(MODULES) ; do \
	(echo -n "local _ENV = _ENV; package.preload['$${x%.*}']=function() "; \
	cat $$x; echo 'end') >tmp/$$x ; done
	$(LUAC) -o $@ $(addprefix tmp/, $(MODULES)) $(RUN_MODULES)

but you would need to do something about the multiple module
quirkiness in HTTPExtra.lua.

BTW, anyone have a Lua 5.2 version of lhf's luac.lua? [1]  That does
something similar.

[1] http://lua-users.org/lists/lua-l/2008-08/msg00092.html