lua-users home
lua-l archive

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


On Wed, Jan 19, 2000 at 03:23:39PM -0200, Siome Klein Goldenstein wrote:
> Many times the C code has to execute a
> initialization chunck of Lua,  like
> a TKLua interface,  or some predefined
> functions.
> 
> It would be interesting to have a LTN 
> of how to, in a Makefile-like structure, get
> rid of the requirement of having the lua
> file hanging around with the executable.
> If I'm not mistaken tolua has that,  (it puts
> lua-bytecode in a char*  and then uses
> lua_dobuffer)

I did just this in one project. I used luac.exe during the build to
compile "builtin.lua" into bytecode, and then I converted the bytecode
into a C-constant in "builtin.c" which was then compiled into the
program, and run with "lua_dostring". Back then I actually had some
problems with lua_dostring and compiled bytecode, so it could
optionally skip the compile step and just throw the source in
there. However, that was long ago.

All it required was:

1) The luac executable
2) a simple program which read in a file and output 
   a c-file with a c-constant containing the data.
   (i.e.   char builtin_data[] = { xx,yy,zz ...}; )
   I wrote this in lua as well.
3) a few lines in the makefile


-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net