From 7ac3151dba659011178da29302c7b7207010454a Mon Sep 17 00:00:00 2001 From: Marek Szuba Date: Mon, 5 Oct 2020 19:12:27 +0200 Subject: lua-utils.eclass: Support luajit 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 --- eclass/lua-utils.eclass | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'eclass') diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass index 490d19a00198..24ef67635d55 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}" ;; -- cgit v1.2.3-65-gdbad