I've embedded lua together with a bytecode chunk into a project written in C. Now when I extend my lua code base by adding .lua files, is there a way to keep this code in a single bytecode chunk?
(I know how to load multiple bytecode chunks. But making it load a single chunk and then forgetting about the glue code would just seem comfortable.)
I tried to use textual inclusion, but it seems there's no keyword for this in Lua. "Require" and "dofile" look at the files at run time, so the resulting bytecode after running "lua -b ..." won't include the code of those files.
And there's no way for combining bytecode files either, is there? I mean so that, when creating a bytecode file, the "require" command would add the code of all those files into one bytecode file.
PS: Michal Kottman's answer works for Lua, which is what I asked for. I thought Lua and LuaJIT would work the same way. They don't. To combine multiple .lua files to one LuaJIT bytecode file, should one
- use "LuaJIT -b" (seems not to work)
- compile Lua's luac.c with LuaJIT sources
- emulate luac.c with lua commands (without C API) ?