From d8c9fc9c0da6e54f19779704ce833af9215b19f3 Mon Sep 17 00:00:00 2001 From: Marek Szuba Date: Mon, 12 Oct 2020 15:15:13 +0200 Subject: 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 --- eclass/lua-utils.eclass | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'eclass/lua-utils.eclass') 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: +# @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: [] ... # @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: [] +# @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: [] # @DESCRIPTION: -- cgit v1.2.3-65-gdbad