lua-users home
lua-l archive

Re: Embed extra search paths into Lua build?

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


> Ideally, I would be able to add in a preprocessor definition like
> -DLUA_PATH_EXTRA="./modules/?.lua" when compiling and wouldn't have to
> change the actual source (so we can keep the same build process for
> subsequent versions).
> 
> Is something like this already provided? Am I stuck with changing
> LUA_PATH_DEFAULT and LUA_CPATH_DEFAULT in luaconf.h?
You can write your definitions in a file, say mydefs.h, and then
build Lua with -DLUA_USER_H='"mydefs.h"'.
In mydefs.h, you need to do
#undef LUA_PATH_DEFAULT
#define LUA_PATH_DEFAULT ...
#undef LUA_CPATH_DEFAULT
#define LUA_CPATH_DEFAULT ...
If you're using the Makefile in the source distribution, you can say
something like
	make linux MYCFLAGS='-DLUA_USER_H='"'"'"mydefs.h"'"'"
Yes, it's a mess of quotes because one layer is stripped by the shell,
another by make, another by the shell that makes invokes, etc...

AltStyle によって変換されたページ (->オリジナル) /