lua-users home
lua-l archive

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


It was thus said that the Great Bulat Ziganshin once stated:
> Hello Lua,
> 
> Note: i found solution and described it at the end of message
> 
> I  have  200-line Lua script included in C++ code. In order to use Lua
> syntax  higlightning,  I  placed this script into file Startup.lua and
> wrote a trivial script that converts it to the C++ code like that:

  [ snip ]

> PS: on the second thought, i resolved it into the C++ code:
> 
>     LuaInstance() {int a=0;
>     #include "Startup.lua"
>     }
>     const char* startup_code;
> 
> with corresponding Lua code:
> 
> --a; startup_code = R"fsdfw43r4(
> ..............
> -- )fsdfw43r4";
> 
> Do  you  have  better  ideas?  Should i publish this trick on Lua wiki
> and what is the best place?

  You gave no indication of the operating system or compiler you are using. 
I can describe what I do, but that's under Linux.

  I use the GNU compiler chain.  In my Makefile, I have an implicit rule to
compile Lua files into object files (warning:  uses GNU features):

%.o : %.lua
	$(BIN2C) -o $(@D)/$(*F).c -t $(*F) $<
	$(CC) $(CFLAGS) -c -o $@ $(@D)/$(*F).c
	$(RM) $(@D)/$(*F).c

This generates a .o file directly from a .lua file (and removes the
temporary .c file since it's not needed anymore).  It works for me.  Your
milage may vary.

  -spc