Gentoo Archives: gentoo-dev

From: Marek Szuba <marecki@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH 1/2] lua-utils.eclass: Support luajit
Date: Mon, 05 Oct 2020 18:01:37
Message-Id: 20201005180105.217724-2-marecki@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/2] lua-utils.eclass: support LuaJIT and unslotted Lua by Marek Szuba
1 According to discussions on IRC, luajit should work as a drop-in
2 replacement for lua5.1 - and indeed, at least for x11-wm/awesome
3 it has worked.
4
5 Note that for the time being dev-lang/luajit uses the same module
6 directories as dev-lang/lua:5.1, which may lead to weird behaviour in
7 multi-impl ebuilds supporting both lua5-1 and luajit. Hopefully we will
8 get luajit to use its own directories so that it is fully independent,
9 same as we install pypy3 modules in their own directory hierarchy in
10 spite of compatibility with cpython-3.6.
11
12 Signed-off-by: Marek Szuba <marecki@g.o>
13 ---
14 eclass/lua-utils.eclass | 21 +++++++++++++++++----
15 profiles/desc/lua_single_target.desc | 1 +
16 profiles/desc/lua_targets.desc | 1 +
17 3 files changed, 19 insertions(+), 4 deletions(-)
18
19 diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
20 index 490d19a0019..24ef67635d5 100644
21 --- a/eclass/lua-utils.eclass
22 +++ b/eclass/lua-utils.eclass
23 @@ -14,8 +14,6 @@
24 # A utility eclass providing functions to query Lua implementations,
25 # install Lua modules and scripts.
26 #
27 -# Please note that for the time being this eclass does NOT support luajit.
28 -#
29 # This eclass neither sets any metadata variables nor exports any phase
30 # functions. It can be inherited safely.
31
32 @@ -39,6 +37,7 @@ inherit toolchain-funcs
33 # @DESCRIPTION:
34 # All supported Lua implementations, most preferred last
35 _LUA_ALL_IMPLS=(
36 + luajit
37 lua5-1
38 lua5-2
39 lua5-3
40 @@ -141,9 +140,16 @@ _lua_wrapper_setup() {
41 local ELUA LUA
42 _lua_export "${impl}" ELUA LUA
43
44 - # Lua interpreter and compiler
45 + # Lua interpreter
46 ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die
47 - ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
48 +
49 + # Lua compiler, or a stub for it in case of luajit
50 + if [[ ${ELUA} == luajit ]]; then
51 + # Just in case
52 + ln -s "${EPREFIX}"/bin/true "${workdir}"/bin/luac || die
53 + else
54 + ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
55 + fi
56
57 # pkg-config
58 ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \
59 @@ -201,6 +207,10 @@ _lua_export() {
60 local impl var
61
62 case "${1}" in
63 + luajit)
64 + impl=${1}
65 + shift
66 + ;;
67 lua*)
68 impl=${1/-/.}
69 shift
70 @@ -259,6 +269,9 @@ _lua_export() {
71 LUA_PKG_DEP)
72 local d
73 case ${impl} in
74 + luajit)
75 + LUA_PKG_DEP="dev-lang/luajit:="
76 + ;;
77 lua*)
78 LUA_PKG_DEP="dev-lang/lua:${impl#lua}"
79 ;;
80 diff --git a/profiles/desc/lua_single_target.desc b/profiles/desc/lua_single_target.desc
81 index 1bee02b6978..c3d422e434d 100644
82 --- a/profiles/desc/lua_single_target.desc
83 +++ b/profiles/desc/lua_single_target.desc
84 @@ -7,3 +7,4 @@ lua5-1 - Build for Lua 5.1 only
85 lua5-2 - Build for Lua 5.2 only
86 lua5-3 - Build for Lua 5.3 only
87 lua5-4 - Build for Lua 5.4 only
88 +luajit - Build for LuaJIT only
89 diff --git a/profiles/desc/lua_targets.desc b/profiles/desc/lua_targets.desc
90 index 2575de0bcfd..75b9e0f86af 100644
91 --- a/profiles/desc/lua_targets.desc
92 +++ b/profiles/desc/lua_targets.desc
93 @@ -7,3 +7,4 @@ lua5-1 - Build with Lua 5.1
94 lua5-2 - Build with Lua 5.2
95 lua5-3 - Build with Lua 5.3
96 lua5-4 - Build with Lua 5.4
97 +luajit - Build with LuaJIT
98 --
99 2.26.2