According to discussions on IRC, luajit should work as a drop-in replacement for lua5.1 - and indeed, at least for x11-wm/awesome it has worked.
Note that for the time being dev-lang/luajit uses the same module directories as dev-lang/lua:5.1, which may lead to weird behaviour in multi-impl ebuilds supporting both lua5-1 and luajit. Hopefully we will get luajit to use its own directories so that it is fully independent, same as we install pypy3 modules in their own directory hierarchy in spite of compatibility with cpython-3.6. Signed-off-by: Marek Szuba <mare...@gentoo.org> --- eclass/lua-utils.eclass | 21 +++++++++++++++++---- profiles/desc/lua_single_target.desc | 1 + profiles/desc/lua_targets.desc | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass index 490d19a0019..24ef67635d5 100644 --- a/eclass/lua-utils.eclass +++ b/eclass/lua-utils.eclass @@ -14,8 +14,6 @@ # A utility eclass providing functions to query Lua implementations, # install Lua modules and scripts. # -# Please note that for the time being this eclass does NOT support luajit. -# # This eclass neither sets any metadata variables nor exports any phase # functions. It can be inherited safely. @@ -39,6 +37,7 @@ inherit toolchain-funcs # @DESCRIPTION: # All supported Lua implementations, most preferred last _LUA_ALL_IMPLS=( + luajit lua5-1 lua5-2 lua5-3 @@ -141,9 +140,16 @@ _lua_wrapper_setup() { local ELUA LUA _lua_export "${impl}" ELUA LUA - # Lua interpreter and compiler + # Lua interpreter ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die - ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die + + # Lua compiler, or a stub for it in case of luajit + if [[ ${ELUA} == luajit ]]; then + # Just in case + ln -s "${EPREFIX}"/bin/true "${workdir}"/bin/luac || die + else + ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die + fi # pkg-config ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ @@ -201,6 +207,10 @@ _lua_export() { local impl var case "${1}" in + luajit) + impl=${1} + shift + ;; lua*) impl=${1/-/.} shift @@ -259,6 +269,9 @@ _lua_export() { LUA_PKG_DEP) local d case ${impl} in + luajit) + LUA_PKG_DEP="dev-lang/luajit:=" + ;; lua*) LUA_PKG_DEP="dev-lang/lua:${impl#lua}" ;; diff --git a/profiles/desc/lua_single_target.desc b/profiles/desc/lua_single_target.desc index 1bee02b6978..c3d422e434d 100644 --- a/profiles/desc/lua_single_target.desc +++ b/profiles/desc/lua_single_target.desc @@ -7,3 +7,4 @@ lua5-1 - Build for Lua 5.1 only lua5-2 - Build for Lua 5.2 only lua5-3 - Build for Lua 5.3 only lua5-4 - Build for Lua 5.4 only +luajit - Build for LuaJIT only diff --git a/profiles/desc/lua_targets.desc b/profiles/desc/lua_targets.desc index 2575de0bcfd..75b9e0f86af 100644 --- a/profiles/desc/lua_targets.desc +++ b/profiles/desc/lua_targets.desc @@ -7,3 +7,4 @@ lua5-1 - Build with Lua 5.1 lua5-2 - Build with Lua 5.2 lua5-3 - Build with Lua 5.3 lua5-4 - Build with Lua 5.4 +luajit - Build with LuaJIT -- 2.26.2