lua-users home
lua-l archive

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


2015-03-02 18:12 GMT+00:00  <mchalkley@mail.com>:
> My objective is to decrease the number of files necessary to deploy
> and also to keep folks from mucking about with the code and screwing
> up something, so compressing/obfuscating/something along those lines
> would be necessary.
>
> Is there currently a "best way" to do this?

I don't think there's a best way, but there are many solutions.

What I've done in the past is write a custom launcher binary. All the
Lua modules and the main script were embedded as PE resources inside
the executable. All the binary modules were statically linked (but
with the luaopen_modname entry points still exported). The C main
function would be similar from the one in lua.c, except it would
replace the Lua and C searchers/loaders with a couple a custom ones.
One would look for luaopen_modname functions in the current executable
instead of separate DLLs, and the other would look for Lua modules in
resources. Then it would load a resource with a predefined name as the
main script.

One advantage of doing it that way is that you can edit an exe file
resources without recompiling it. So as long as the set of binary
modules you use stays the same, you can reuse the single binary for
multiple programs.

The code (undocumented and maybe outdated) is available online if
you're interested: https://bitbucket.org/doub/launcher and
https://bitbucket.org/doub/launcher2