Script for modifying luaconf.h

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Script for modifying luaconf.h

William Ahern
I was upgrading my local install of Lua 5.3 and had to deal with modifying
luaconf.h yet again. Usually I just apply a patch, but today I wrote a shell
script that can translate the LUA_ROOT, LUA_LDIR, and LUA_CDIR definitions
in upstream luaconf.h.

        https://github.com/wahern/lua-5.3/blob/luaconf-subst/src/luaconf.sh

The script can import INSTALL_TOP, INSTALL_LMOD, INSTALL_CMOD, etc from the
Makefile by parsing MAKEFLAGS, which make exports to subshell environments.
Variables can also be passed via the environment directly or by command-line
options. It should be relatively easy to drop into custom builds, assuming
it supports a unix shell environment.

The following branch modifies the Lua makefiles to generate luaconf.h at
build time

        https://github.com/wahern/lua-5.3/tree/luaconf-subst

One caveat is that you want to make sure that you're specifying INSTALL_TOP
both when building and when installing.


Reply | Threaded
Open this post in threaded view
|

Re: Script for modifying luaconf.h

Luiz Henrique de Figueiredo
> I was upgrading my local install of Lua 5.3 and had to deal with modifying
> luaconf.h yet again. Usually I just apply a patch, but today I wrote a shell
> script

If you don't want to edit luaconf.h to reapply your customizations, just
add them at the end. You may have to do something like

     #undef LUA_ROOT
     #undef LUA_LDIR
     #undef LUA_CDIR
     ...

     #define LUA_ROOT        ...
     #define LUA_LDIR        ...
     #define LUA_CDIR        ...
     ...


Reply | Threaded
Open this post in threaded view
|

Re: Script for modifying luaconf.h

William Ahern
On Wed, Jul 06, 2016 at 06:19:37PM -0300, Luiz Henrique de Figueiredo wrote:

> > I was upgrading my local install of Lua 5.3 and had to deal with modifying
> > luaconf.h yet again. Usually I just apply a patch, but today I wrote a shell
> > script
>
> If you don't want to edit luaconf.h to reapply your customizations, just
> add them at the end. You may have to do something like
>
>      #undef LUA_ROOT
>      #undef LUA_LDIR
>      #undef LUA_CDIR
>      ...
>
>      #define LUA_ROOT        ...
>      #define LUA_LDIR        ...
>      #define LUA_CDIR        ...
>      ...

For my purposes, defining those is an indirect way to modify
LUA_PATH_DEFAULT and LUA_CPATH_DEFAULT. I didn't want to define them
directly because the default definitions also include implicit semantics of
module loading (priority, etc).

But reading through the 5.1, 5.2, and 5.3 sources they do seem rather
stable, though 5.1 differs from 5.2. Appending definitions for
LUA_PATH_DEFAULT and LUA_CPATH_DEFAULT sure would be much cleaner.

I probably shouldn't have posted to the list to advertise the script.
Requirements and preferences vary widely. Sorry for the noise.


Reply | Threaded
Open this post in threaded view
|

Re: Script for modifying luaconf.h

Luiz Henrique de Figueiredo
> I probably shouldn't have posted to the list to advertise the script.
> Requirements and preferences vary widely. Sorry for the noise.

Not at all. Tools are always welcome, especially open-source ones.