summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Szuba <marecki@gentoo.org>2020-10-12 15:15:13 +0200
committerMarek Szuba <marecki@gentoo.org>2020-10-15 18:27:05 +0200
commitd8c9fc9c0da6e54f19779704ce833af9215b19f3 (patch)
tree283b513db91cc2e971a971f6519c7791afd7abfb
parentlua-utils.eclass: Add lua_get_include_dir() (diff)
downloadgentoo-d8c9fc9c0da6e54f19779704ce833af9215b19f3.tar.gz
gentoo-d8c9fc9c0da6e54f19779704ce833af9215b19f3.tar.bz2
gentoo-d8c9fc9c0da6e54f19779704ce833af9215b19f3.zip
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@gentoo.org>
-rw-r--r--eclass/lua-utils.eclass52
1 files changed, 52 insertions, 0 deletions
diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
index 8f54e57dbd71..100be14cb08a 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: