public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations
@ 2020-10-12 14:05 Marek Szuba
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 1/3] lua-utils.eclass: Add lua_get_include_dir() Marek Szuba
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Marek Szuba @ 2020-10-12 14:05 UTC (permalink / raw
  To: gentoo-dev

Having had a gander at some of the revdeps of dev-lang/lua{,jit}
currently present in the tree, it is fairly common to force the use of
the right Lua version by pointing src_configure() to the right include
directory and library files. Unfortunately doing it this way seems to
be the sanest way of dealing with Lua detection in CMake so it is
unlikely to go away any time soon... Therefore, provide functions
returning this information in an implementation-independent way.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gentoo-dev] [PATCH 1/3] lua-utils.eclass: Add lua_get_include_dir()
  2020-10-12 14:05 [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
@ 2020-10-12 14:05 ` Marek Szuba
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 2/3] lua-utils.eclass: Add lua_get_shared_lib() Marek Szuba
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Marek Szuba @ 2020-10-12 14:05 UTC (permalink / raw
  To: gentoo-dev

For build systems which must be pointed directly to the relevant files,
e.g. CMake.

Signed-off-by: Marek Szuba <marecki@gentoo.org>
---
 eclass/lua-utils.eclass | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
index 24ef67635d5..8f54e57dbd7 100644
--- a/eclass/lua-utils.eclass
+++ b/eclass/lua-utils.eclass
@@ -250,6 +250,14 @@ _lua_export() {
 				export LUA_CMOD_DIR=${val}
 				debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}"
 				;;
+			LUA_INCLUDE_DIR)
+				local val
+
+				val=$($(tc-getPKG_CONFIG) --variable includedir ${impl}) || die
+
+				export LUA_INCLUDE_DIR=${val}
+				debug-print "${FUNCNAME}: LUA_INCLUDE_DIR = ${LUA_INCLUDE_DIR}"
+				;;
 			LUA_LIBS)
 				local val
 
@@ -335,6 +343,22 @@ lua_get_cmod_dir() {
 	echo "${LUA_CMOD_DIR}"
 }
 
+# @FUNCTION: lua_get_include_dir
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the name of the directory containing header files
+# of the given Lua implementation. If no implementation is provided,
+# ${ELUA} will be used.
+#
+# 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_include_dir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_INCLUDE_DIR
+	echo "${LUA_INCLUDE_DIR}"
+}
+
 # @FUNCTION: lua_get_LIBS
 # @USAGE: [<impl>]
 # @DESCRIPTION:
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-dev] [PATCH 2/3] lua-utils.eclass: Add lua_get_shared_lib()
  2020-10-12 14:05 [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 1/3] lua-utils.eclass: Add lua_get_include_dir() Marek Szuba
@ 2020-10-12 14:05 ` Marek Szuba
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib() Marek Szuba
  2020-10-15 16:28 ` [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
  3 siblings, 0 replies; 8+ messages in thread
From: Marek Szuba @ 2020-10-12 14:05 UTC (permalink / raw
  To: gentoo-dev

For build systems which must be pointed directly to the relevant files,
e.g. CMake.

Signed-off-by: Marek Szuba <marecki@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:
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib()
  2020-10-12 14:05 [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 1/3] lua-utils.eclass: Add lua_get_include_dir() Marek Szuba
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 2/3] lua-utils.eclass: Add lua_get_shared_lib() Marek Szuba
@ 2020-10-12 14:05 ` Marek Szuba
  2020-10-12 15:39   ` David Seifert
  2020-10-15 16:28 ` [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
  3 siblings, 1 reply; 8+ messages in thread
From: Marek Szuba @ 2020-10-12 14:05 UTC (permalink / raw
  To: gentoo-dev

For build systems which must be pointed directly to the relevant files,
e.g. CMake.

Signed-off-by: Marek Szuba <marecki@gentoo.org>
---
 eclass/lua-utils.eclass | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
index 100be14cb08..922f72b80d6 100644
--- a/eclass/lua-utils.eclass
+++ b/eclass/lua-utils.eclass
@@ -329,6 +329,11 @@ _lua_export() {
 				export LUA_SHARED_LIB="${val}".so
 				debug-print "${FUNCNAME}: LUA_SHARED_LIB = ${LUA_SHARED_LIB}"
 				;;
+			LUA_STATIC_LIB)
+				local val=$(_lua_get_library_file ${impl})
+				export LUA_STATIC_LIB="${val}".a
+				debug-print "${FUNCNAME}: LUA_STATIC_LIB = ${LUA_STATIC_LIB}"
+				;;
 			LUA_VERSION)
 				local val
 
@@ -443,6 +448,25 @@ lua_get_shared_lib() {
 	echo "${LUA_SHARED_LIB}"
 }
 
+# @FUNCTION: lua_get_static_lib
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the expected name, with path, of the main static 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 static 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_static_lib() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	_lua_export "${@}" LUA_STATIC_LIB
+	echo "${LUA_STATIC_LIB}"
+}
+
 # @FUNCTION: lua_get_version
 # @USAGE: [<impl>]
 # @DESCRIPTION:
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib()
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib() Marek Szuba
@ 2020-10-12 15:39   ` David Seifert
  2020-10-12 15:57     ` Marek Szuba
  0 siblings, 1 reply; 8+ messages in thread
From: David Seifert @ 2020-10-12 15:39 UTC (permalink / raw
  To: gentoo-dev

On Mon, 2020-10-12 at 16:05 +0200, Marek Szuba wrote:
> For build systems which must be pointed directly to the relevant
> files,
> e.g. CMake.
> 
> Signed-off-by: Marek Szuba <marecki@gentoo.org>
> ---
>  eclass/lua-utils.eclass | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
> index 100be14cb08..922f72b80d6 100644
> --- a/eclass/lua-utils.eclass
> +++ b/eclass/lua-utils.eclass
> @@ -329,6 +329,11 @@ _lua_export() {
>  				export LUA_SHARED_LIB="${val}".so
>  				debug-print "${FUNCNAME}:
> LUA_SHARED_LIB = ${LUA_SHARED_LIB}"
>  				;;
> +			LUA_STATIC_LIB)
> +				local val=$(_lua_get_library_file
> ${impl})
> +				export LUA_STATIC_LIB="${val}".a
> +				debug-print "${FUNCNAME}:
> LUA_STATIC_LIB = ${LUA_STATIC_LIB}"
> +				;;
>  			LUA_VERSION)
>  				local val
>  
> @@ -443,6 +448,25 @@ lua_get_shared_lib() {
>  	echo "${LUA_SHARED_LIB}"
>  }
>  
> +# @FUNCTION: lua_get_static_lib
> +# @USAGE: [<impl>]
> +# @DESCRIPTION:
> +# Obtain and print the expected name, with path, of the main static
> 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 static 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_static_lib() {
> +	debug-print-function ${FUNCNAME} "${@}"
> +
> +	_lua_export "${@}" LUA_STATIC_LIB
> +	echo "${LUA_STATIC_LIB}"
> +}
> +
>  # @FUNCTION: lua_get_version
>  # @USAGE: [<impl>]
>  # @DESCRIPTION:

When is passing static libs ever useful for Lua?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib()
  2020-10-12 15:39   ` David Seifert
@ 2020-10-12 15:57     ` Marek Szuba
  2020-10-12 16:09       ` David Seifert
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Szuba @ 2020-10-12 15:57 UTC (permalink / raw
  To: gentoo-dev


[-- Attachment #1.1.1: Type: text/plain, Size: 217 bytes --]

On 2020-10-12 17:39, David Seifert wrote:

> When is passing static libs ever useful for Lua?

No idea - but both Lua and LuaJIT install them, if conditionally on 
USE=static-libs in the latter case.

-- 
MS

[-- Attachment #1.1.2: OpenPGP_0xD4945FFDD7FE7E37_and_old_rev.asc --]
[-- Type: application/pgp-keys, Size: 122125 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib()
  2020-10-12 15:57     ` Marek Szuba
@ 2020-10-12 16:09       ` David Seifert
  0 siblings, 0 replies; 8+ messages in thread
From: David Seifert @ 2020-10-12 16:09 UTC (permalink / raw
  To: gentoo-dev

On Mon, 2020-10-12 at 17:57 +0200, Marek Szuba wrote:
> On 2020-10-12 17:39, David Seifert wrote:
> 
> > When is passing static libs ever useful for Lua?
> 
> No idea - but both Lua and LuaJIT install them, if conditionally on 
> USE=static-libs in the latter case.
> 

Then please don't provide this helper function. Consumers should just
use lua_get_shared_lib(). We similarly don't provide getters for
libpythonX.Y.a either, for the same reason.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations
  2020-10-12 14:05 [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
                   ` (2 preceding siblings ...)
  2020-10-12 14:05 ` [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib() Marek Szuba
@ 2020-10-15 16:28 ` Marek Szuba
  3 siblings, 0 replies; 8+ messages in thread
From: Marek Szuba @ 2020-10-15 16:28 UTC (permalink / raw
  To: gentoo-dev


[-- Attachment #1.1.1: Type: text/plain, Size: 642 bytes --]

On 2020-10-12 16:05, Marek Szuba wrote:

> Having had a gander at some of the revdeps of dev-lang/lua{,jit}
> currently present in the tree, it is fairly common to force the use of
> the right Lua version by pointing src_configure() to the right include
> directory and library files. Unfortunately doing it this way seems to
> be the sanest way of dealing with Lua detection in CMake so it is
> unlikely to go away any time soon... Therefore, provide functions
> returning this information in an implementation-independent way.

Merged in lua_get_include_dir() and lua_get_shared_lib(), dropped 
lua_get_static_lib().

-- 
MS

[-- Attachment #1.1.2: OpenPGP_0xD4945FFDD7FE7E37_and_old_rev.asc --]
[-- Type: application/pgp-keys, Size: 122125 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-10-15 16:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-12 14:05 [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba
2020-10-12 14:05 ` [gentoo-dev] [PATCH 1/3] lua-utils.eclass: Add lua_get_include_dir() Marek Szuba
2020-10-12 14:05 ` [gentoo-dev] [PATCH 2/3] lua-utils.eclass: Add lua_get_shared_lib() Marek Szuba
2020-10-12 14:05 ` [gentoo-dev] [PATCH 3/3] lua-utils.eclass: Add lua_get_static_lib() Marek Szuba
2020-10-12 15:39   ` David Seifert
2020-10-12 15:57     ` Marek Szuba
2020-10-12 16:09       ` David Seifert
2020-10-15 16:28 ` [gentoo-dev] [PATCH 0/3] lua-utils.eclass: expose header and library locations Marek Szuba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox