Gentoo Archives: gentoo-dev

From: Marek Szuba <marecki@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH 2/3] lua-utils.eclass: Add lua_get_shared_lib()
Date: Mon, 12 Oct 2020 14:06:28
Message-Id: 20201012140534.113655-3-marecki@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations by Marek Szuba
1 For build systems which must be pointed directly to the relevant files,
2 e.g. CMake.
3
4 Signed-off-by: Marek Szuba <marecki@g.o>
5 ---
6 eclass/lua-utils.eclass | 52 +++++++++++++++++++++++++++++++++++++++++
7 1 file changed, 52 insertions(+)
8
9 diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
10 index 8f54e57dbd7..100be14cb08 100644
11 --- a/eclass/lua-utils.eclass
12 +++ b/eclass/lua-utils.eclass
13 @@ -190,6 +190,34 @@ _lua_wrapper_setup() {
14 # /usr/bin/lua5.1
15 # @CODE
16
17 +# @FUNCTION: _lua_get_library_file
18 +# @USAGE: <impl>
19 +# @INTERNAL
20 +# @DESCRIPTION:
21 +# Get the core part (i.e. without the extension) of the library name,
22 +# with path, of the given Lua implementation.
23 +# Used internally by _lua_export().
24 +_lua_get_library_file() {
25 + local impl="${1}"
26 + local libdir libname
27 +
28 + case ${impl} in
29 + luajit)
30 + libname=lib$($(tc-getPKG_CONFIG) --variable libname ${impl}) || die
31 + ;;
32 + lua*)
33 + libname=lib${impl}
34 + ;;
35 + *)
36 + die "Invalid implementation: ${impl}"
37 + ;;
38 + esac
39 + libdir=$($(tc-getPKG_CONFIG) --variable libdir ${impl}) || die
40 +
41 + debug-print "${FUNCNAME}: libdir = ${libdir}, libname = ${libname}"
42 + echo "${libdir}/${libname}"
43 +}
44 +
45 # @FUNCTION: _lua_export
46 # @USAGE: [<impl>] <variables>...
47 # @INTERNAL
48 @@ -296,6 +324,11 @@ _lua_export() {
49 export LUA_PKG_DEP
50 debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}"
51 ;;
52 + LUA_SHARED_LIB)
53 + local val=$(_lua_get_library_file ${impl})
54 + export LUA_SHARED_LIB="${val}".so
55 + debug-print "${FUNCNAME}: LUA_SHARED_LIB = ${LUA_SHARED_LIB}"
56 + ;;
57 LUA_VERSION)
58 local val
59
60 @@ -391,6 +424,25 @@ lua_get_lmod_dir() {
61 echo "${LUA_LMOD_DIR}"
62 }
63
64 +# @FUNCTION: lua_get_shared_lib
65 +# @USAGE: [<impl>]
66 +# @DESCRIPTION:
67 +# Obtain and print the expected name, with path, of the main shared library
68 +# of the given Lua implementation. If no implementation is provided,
69 +# ${ELUA} will be used.
70 +#
71 +# Note that it is up to the ebuild maintainer to ensure Lua actually
72 +# provides a shared library.
73 +#
74 +# Please note that this function requires Lua and pkg-config installed,
75 +# and therefore proper build-time dependencies need be added to the ebuild.
76 +lua_get_shared_lib() {
77 + debug-print-function ${FUNCNAME} "${@}"
78 +
79 + _lua_export "${@}" LUA_SHARED_LIB
80 + echo "${LUA_SHARED_LIB}"
81 +}
82 +
83 # @FUNCTION: lua_get_version
84 # @USAGE: [<impl>]
85 # @DESCRIPTION:
86 --
87 2.26.2