[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Trying Pallene
- From: "Pierre Chapuis" <lua@...>
- Date: Thu, 13 Oct 2022 10:40:34 +0200
> Do you have suggestions for what would be a good way for us to solve
> that CFLAGS problem? One idea I have been experimenting with in the
> development branch is to teach Pallene to invoke the C compiler through
> Luarocks. Luarocks knows how to compile on several operating systems
> (not just Linux, which is the only supported one currently) and Luarocks
> also knows the right CFLAGS. That said, it also feels a bit like trying
> to fit a square peg in a round hole because Luarocks wants to build a
> whole rock, not individual files...
There are many solutions, that could be one.
The way I would do it would be:
- Refactor so that the "c_compiler" module does not call os.getenv directly,
but instead pass the flags through function arguments and only call
os.getenv in `bin/pallenec`.
- Customize `bin/pallenec` at "build" time (the same way Luarocks has
a --with-lua flag). You could probably do it automatically in the rockspec.
Or I could customize it myself, it's easy.
However note that there are already way to make it work, for instance
I could write a wrapper script for pallenec (or modify the one from
Luarocks) like this:
#!/bin/bash
pwd="$(dirname "$0")"
lua_incdir="$(lua -e "$("$pwd"/luarocks config); print(variables.LUA_INCDIR)")"
CFLAGS="${CFLAGS:--O2} -I "$lua_incdir"" "$pwd"/pallenec "$@"
It's just a little too magic for my taste. =)
--
Pierre Chapuis