lua-users home
lua-l archive

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


Am 28.10.2013 22:18 schröbte AllanPfalzgraf@Eaton.com:
We would like to compile Lua scripts and all their 'required' .lua files into a single output file that would have no dependencies other than .dll files.
Any thoughts?

Collect all `require`d Lua modules and paste them together wrapping every module file in

    local _ENV = _ENV -- every module needs it's own _ENV upvalue
    package.preload[ "module1" ] = function( ... )
      _ENV = _ENV -- _ENV upvalue must be the first upvalue

      --
      -- contents of file `module1.lua` inserted here
      --

    end

Finally, strip the shebang line of your main script, paste it at the end, and feed the whole thing to `luac`.

... or you could use squish[1], or LOOP[2] (both Lua 5.1 only, I think).

  [1]: http://code.matthewwild.co.uk/squish
  [2]: http://loop.luaforge.net/release/preload.html



Allan Pfalzgraf

Philipp