commit: d8c9fc9c0da6e54f19779704ce833af9215b19f3
Author: Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 12 13:15:13 2020 +0000
Commit: Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Thu Oct 15 16:27:05 2020 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d8c9fc9c
lua-utils.eclass: Add lua_get_shared_lib()
For build systems which must be pointed directly to the relevant files,
e.g. CMake.
Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
eclass/lua-utils.eclass | 52 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
index 8f54e57dbd7..100be14cb08 100644
--- a/eclass/lua-utils.eclass
+++ b/eclass/lua-utils.eclass
@@ -190,6 +190,34 @@ _lua_wrapper_setup() {
# /usr/bin/lua5.1
# @CODE
+# @FUNCTION: _lua_get_library_file
+# @USAGE: <impl>
+# @INTERNAL
+# @DESCRIPTION:
+# Get the core part (i.e. without the extension) of the library name,
+# with path, of the given Lua implementation.
+# Used internally by _lua_export().
+_lua_get_library_file() {
+ local impl="${1}"
+ local libdir libname
+
+ case ${impl} in
+ luajit)
+ libname=lib$($(tc-getPKG_CONFIG) --variable libname
${impl}) || die
+ ;;
+ lua*)
+ libname=lib${impl}
+ ;;
+ *)
+ die "Invalid implementation: ${impl}"
+ ;;
+ esac
+ libdir=$($(tc-getPKG_CONFIG) --variable libdir ${impl}) || die
+
+ debug-print "${FUNCNAME}: libdir = ${libdir}, libname = ${libname}"
+ echo "${libdir}/${libname}"
+}
+
# @FUNCTION: _lua_export
# @USAGE: [<impl>] <variables>...
# @INTERNAL
@@ -296,6 +324,11 @@ _lua_export() {
export LUA_PKG_DEP
debug-print "${FUNCNAME}: LUA_PKG_DEP =
${LUA_PKG_DEP}"
;;
+ LUA_SHARED_LIB)
+ local val=$(_lua_get_library_file ${impl})
+ export LUA_SHARED_LIB="${val}".so
+ debug-print "${FUNCNAME}: LUA_SHARED_LIB =
${LUA_SHARED_LIB}"
+ ;;
LUA_VERSION)
local val
@@ -391,6 +424,25 @@ lua_get_lmod_dir() {
echo "${LUA_LMOD_DIR}"
}
+# @FUNCTION: lua_get_shared_lib
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the expected name, with path, of the main shared library
+# of the given Lua implementation. If no implementation is provided,
+# ${ELUA} will be used.
+#
+# Note that it is up to the ebuild maintainer to ensure Lua actually
+# provides a shared library.
+#
+# Please note that this function requires Lua and pkg-config installed,
+# and therefore proper build-time dependencies need be added to the ebuild.
+lua_get_shared_lib() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ _lua_export "${@}" LUA_SHARED_LIB
+ echo "${LUA_SHARED_LIB}"
+}
+
# @FUNCTION: lua_get_version
# @USAGE: [<impl>]
# @DESCRIPTION: