LUA.ECLASS

Section: eclass-manpages (5)
Updated: Sep 2020
Index Return to Main Contents

NAME

lua.eclass - A common eclass for Lua packages

DESCRIPTION

A common eclass providing helper functions to build and install packages supporting being installed for multiple Lua implementations.

This eclass sets correct IUSE. Modification of REQUIRED_USE has to be done by the author of the ebuild (but LUA_REQUIRED_USE is provided for convenience, see below). The eclass exports LUA_DEPS and LUA_USEDEP so you can create correct dependencies for your package easily. It also provides methods to easily run a command for each enabled Lua implementation and duplicate the sources for them.

Please note that for the time being this eclass does NOT support luajit.

SUPPORTED EAPIS

7

EXAMPLE

EAPI=7

LUA_COMPAT=( lua5-{1..3} )

inherit lua

[...]

REQUIRED_USE="${LUA_REQUIRED_USE}"
DEPEND="${LUA_DEPS}"
RDEPEND="${DEPEND}
dev-lua/foo[${LUA_USEDEP}]"
BDEPEND="virtual/pkgconfig"

lua_src_install() {
emake LUA_VERSION="$(lua_get_version)" install
}

src_install() {
lua_foreach_impl lua_src_install
}

FUNCTIONS

lua_copy_sources
Create a single copy of the package sources for each enabled Lua implementation.

The sources are always copied from initial BUILD_DIR (or S if unset) to implementation-specific build directory matching BUILD_DIR used by lua_foreach_abi().

lua_foreach_impl <command> [<args>...]
Run the given command for each of the enabled Lua implementations. If additional parameters are passed, they will be passed through to the command.

The function will return 0 status if all invocations succeed. Otherwise, the return code from first failing invocation will be returned.

For each command being run, ELUA, LUA and BUILD_DIR are set locally, and the former two are exported to the command environment.

lua_get_CFLAGS [<impl>]
Obtain and print the compiler flags for building against Lua, for the given 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_cmod_dir [<impl>]
Obtain and print the name of the directory into which compiled Lua modules are installed, for the given 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_LIBS [<impl>]
Obtain and print the compiler flags for linking against Lua, for the given 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_lmod_dir [<impl>]
Obtain and print the name of the directory into which native-Lua modules are installed, for the given 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_version [<impl>]
Obtain and print the full version number 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.

ECLASS VARIABLES

LUA_COMPAT (REQUIRED) (SET BEFORE INHERIT)
This variable contains a list of Lua implementations the package supports. It must be set before the `inherit' call. It has to be an array.

Example:

LUA_COMPAT=( lua5-1 lua5-2 lua5-3 )

Please note that you can also use bash brace expansion if you like:

LUA_COMPAT=( lua5-{1..3} )
LUA_COMPAT_OVERRIDE (USER VARIABLE)
This variable can be used when working with ebuilds to override the in-ebuild LUA_COMPAT. It is a string listing all the implementations which package will be built for. It need be specified in the calling environment, and not in ebuilds.

It should be noted that in order to preserve metadata immutability, LUA_COMPAT_OVERRIDE does not affect IUSE nor dependencies. The state of LUA_TARGETS is ignored, and all the implementations in LUA_COMPAT_OVERRIDE are built. Dependencies need to be satisfied manually.

Example:

LUA_COMPAT_OVERRIDE='lua5-2' emerge -1v dev-lua/foo
LUA_REQ_USE (SET BEFORE INHERIT)
The list of USE flags required to be enabled on the chosen Lua implementations, formed as a USE-dependency string. It should be valid for all implementations in LUA_COMPAT, so it may be necessary to use USE defaults. This must be set before calling `inherit'.

Example:

LUA_REQ_USE="deprecated"

It will cause the Lua dependencies to look like:

lua_targets_luaX-Y? ( dev-lang/lua:X.Y[deprecated] )
BUILD_DIR (GENERATED BY ECLASS)
The current build directory. In global scope, it is supposed to contain an initial build directory; if unset, it defaults to ${S}.

In functions run by lua_foreach_impl(), the BUILD_DIR is locally set to an implementation-specific build directory. That path is created through appending a hyphen and the implementation name to the final component of the initial BUILD_DIR.

Example value:

${WORKDIR}/foo-1.3-lua5-1
ELUA
The executable name of the current Lua interpreter. This variable is set automatically in functions called by lua_foreach_impl().

Example value:

lua5.1
LUA
The absolute path to the current Lua interpreter. This variable is set automatically in functions called by lua_foreach_impl().

Example value:

/usr/bin/lua5.1
LUA_DEPS (GENERATED BY ECLASS)
This is an eclass-generated Lua dependency string for all implementations listed in LUA_COMPAT.

Example use:

RDEPEND="${LUA_DEPS}
  dev-foo/mydep"
DEPEND="${RDEPEND}"

Example value:

lua_targets_lua5-1? ( dev-lang/lua:5.1 )
lua_targets_lua5-2? ( dev-lang/lua:5.2 )
LUA_REQUIRED_USE (GENERATED BY ECLASS)
This is an eclass-generated required-use expression which ensures at least one Lua implementation has been enabled.

This expression should be utilized in an ebuild by including it in REQUIRED_USE, optionally behind a use flag.

Example use:

REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )"

Example value:

|| ( lua_targets_lua5-1 lua_targets_lua5-2 )
LUA_USEDEP (GENERATED BY ECLASS)
This is an eclass-generated USE-dependency string which can be used to depend on another Lua package being built for the same Lua implementations.

Example use:

RDEPEND="dev-lua/foo[${LUA_USEDEP}]"

Example value:

lua_targets_lua5-1(-)?,lua_targets_lua5-2(-)?

AUTHORS

Marek Szuba <marecki@gentoo.org>
Based on python{,-utils}-r1.eclass by Michał Górny <mgorny@gentoo.org> et al.

MAINTAINERS

William Hubbs <williamh@gentoo.org>
Marek Szuba <marecki@gentoo.org>

REPORTING BUGS

Please report bugs via https://bugs.gentoo.org/

FILES

lua.eclass

SEE ALSO

ebuild(5)
https://gitweb.gentoo.org/repo/gentoo.git/log/eclass/lua.eclass


Index

NAME
DESCRIPTION
SUPPORTED EAPIS
EXAMPLE
FUNCTIONS
ECLASS VARIABLES
AUTHORS
MAINTAINERS
REPORTING BUGS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 00:27:01 GMT, November 01, 2020