LUA.ECLASS

Section: eclass-manpages (5)
Updated: Mar 2024
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.

Note that since this eclass always inherits lua-utils as well, in ebuilds using the former there is no need to explicitly inherit the latter in order to use helper functions such as lua_get_CFLAGS.

SUPPORTED EAPIS

7 8

TRANSITIVELY PROVIDED ECLASSES

lua-utils

EXAMPLE

EAPI=8

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

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.

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-3 lua5-4 )

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='luajit' 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
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-3? ( dev-lang/lua:5.3 )
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-3 )
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-3(-)?

AUTHORS

Marek Szuba <marecki@gentoo.org>
Based on python-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
TRANSITIVELY PROVIDED ECLASSES
EXAMPLE
FUNCTIONS
ECLASS VARIABLES
AUTHORS
MAINTAINERS
REPORTING BUGS
FILES
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 03:27:01 GMT, March 28, 2024