Gentoo Archives: gentoo-dev

From: Conrad Kostecki <conikost@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH v2] eclass/lua-utils.eclass: Add support for test-runners
Date: Fri, 08 Jan 2021 00:10:16
Message-Id: 20210108000952.1043-1-conikost@gentoo.org
1 During migration of dev-lua/* ebuilds to slotted lua, I noticed, that
2 many ebuilds use 'dev-lua/busted' for running tests. This change adds
3 support for running a test-runner, at first only 'busted' for now.
4 Also a non-color and plaintext output will be used for the test-runner 'busted'.
5
6 This is basically a copy of the test-runner section, written by mgorny,
7 which already exists in 'distutils-r1', but modified and adapted to lua.
8
9 In order to use this feature, you can define 'lua_enable_tests busted'
10 to setup everything needed for tests and run them. By default,
11 'dev-lua/busted' assumes, that tests are in the 'spec' folder.
12
13 If this is not the case, you can add a second argument to specify a
14 different folder. For example, if the folder is called 'foo', you can
15 just run 'lua_enable_tests busted foo'.
16
17 More test-runners can be added in future, if needed.
18
19 PATCH v2 has two changes:
20 - removed EAPI condition, as lua-utils is EAPI=7 only.
21 - make test_directoy as a local variable and use eval in src_test to
22 read it.
23
24 Signed-off-by: Conrad Kostecki <conikost@g.o>
25 ---
26 eclass/lua-utils.eclass | 69 ++++++
27 lua-utils.eclass | 532 ++++++++++++++++++++++++++++++++++++++++
28 2 files changed, 601 insertions(+)
29 create mode 100644 lua-utils.eclass
30
31 diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass
32 index 100be14cb08..2200aa50391 100644
33 --- a/eclass/lua-utils.eclass
34 +++ b/eclass/lua-utils.eclass
35 @@ -344,6 +344,75 @@ _lua_export() {
36 done
37 }
38
39 +# @FUNCTION: lua_enable_tests
40 +# @USAGE: <test-runner> <test-directory>
41 +# @DESCRIPTION:
42 +# Set up IUSE, RESTRICT, BDEPEND and src_test() for running tests
43 +# with the specified test runner. Also copies the current value
44 +# of RDEPEND to test?-BDEPEND. The test-runner argument must be one of:
45 +#
46 +# - busted: dev-lua/busted
47 +#
48 +# Additionally, a second argument can be passed after <test-runner>,
49 +# so <test-runner> will use that directory to search for tests.
50 +# If not passed, a default directory of <test-runner> will be used.
51 +#
52 +# - busted: spec
53 +#
54 +# This function is meant as a helper for common use cases, and it only
55 +# takes care of basic setup. You still need to list additional test
56 +# dependencies manually. If you have uncommon use case, you should
57 +# not use it and instead enable tests manually.
58 +#
59 +# This function must be called in global scope, after RDEPEND has been
60 +# declared. Take care not to overwrite the variables set by it.
61 +lua_enable_tests() {
62 + debug-print-function ${FUNCNAME} "${@}"
63 +
64 + [[ ${#} -ge 1 ]] || die "${FUNCNAME} takes at least one argument: test-runner (test-directory)"
65 + local test_pkg
66 + case ${1} in
67 + busted)
68 + test_directory="${2:-spec}"
69 + test_pkg="dev-lua/busted"
70 + if [[ ! ${_LUA_SINGLE_R0} ]]; then
71 + lua_src_test() {
72 + busted --lua="${ELUA}" --output="plainTerminal" "${test_directory}" || die "Tests fail with ${ELUA}"
73 + }
74 + src_test() {
75 + lua_foreach_impl lua_src_test
76 + }
77 + else
78 + src_test() {
79 + busted --lua="${ELUA}" --output="plainTerminal" "${test_directory}" || die "Tests fail with ${ELUA}"
80 + }
81 + fi
82 + ;;
83 + *)
84 + die "${FUNCNAME}: unsupported argument: ${1}"
85 + esac
86 +
87 + local test_deps=${RDEPEND}
88 + if [[ -n ${test_pkg} ]]; then
89 + if [[ ! ${_LUA_SINGLE_R0} ]]; then
90 + test_deps+=" ${test_pkg}[${LUA_USEDEP}]"
91 + else
92 + test_deps+=" $(lua_gen_cond_dep "
93 + ${test_pkg}[\${LUA_USEDEP}]
94 + ")"
95 + fi
96 + fi
97 + if [[ -n ${test_deps} ]]; then
98 + IUSE+=" test"
99 + RESTRICT+=" !test? ( test )"
100 + BDEPEND+=" test? ( ${test_deps} )"
101 + fi
102 +
103 + # we need to ensure successful return in case we're called last,
104 + # otherwise Portage may wrongly assume sourcing failed
105 + return 0
106 +}
107 +
108 # @FUNCTION: lua_get_CFLAGS
109 # @USAGE: [<impl>]
110 # @DESCRIPTION:
111 diff --git a/lua-utils.eclass b/lua-utils.eclass
112 new file mode 100644
113 index 00000000000..0589318ef51
114 --- /dev/null
115 +++ b/lua-utils.eclass
116 @@ -0,0 +1,532 @@
117 +# Copyright 1999-2020 Gentoo Authors
118 +# Distributed under the terms of the GNU General Public License v2
119 +
120 +# @ECLASS: lua-utils.eclass
121 +# @MAINTAINER:
122 +# William Hubbs <williamh@g.o>
123 +# Marek Szuba <marecki@g.o>
124 +# @AUTHOR:
125 +# Marek Szuba <marecki@g.o>
126 +# Based on python-utils-r1.eclass by Michał Górny <mgorny@g.o> et al.
127 +# @SUPPORTED_EAPIS: 7
128 +# @BLURB: Utility functions for packages with Lua parts
129 +# @DESCRIPTION:
130 +# A utility eclass providing functions to query Lua implementations,
131 +# install Lua modules and scripts.
132 +#
133 +# This eclass neither sets any metadata variables nor exports any phase
134 +# functions. It can be inherited safely.
135 +
136 +case ${EAPI:-0} in
137 + 0|1|2|3|4|5|6)
138 + die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}"
139 + ;;
140 + 7)
141 + ;;
142 + *)
143 + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
144 + ;;
145 +esac
146 +
147 +if [[ ! ${_LUA_UTILS_R0} ]]; then
148 +
149 +inherit toolchain-funcs
150 +
151 +# @ECLASS-VARIABLE: _LUA_ALL_IMPLS
152 +# @INTERNAL
153 +# @DESCRIPTION:
154 +# All supported Lua implementations, most preferred last
155 +_LUA_ALL_IMPLS=(
156 + luajit
157 + lua5-1
158 + lua5-2
159 + lua5-3
160 + lua5-4
161 +)
162 +readonly _LUA_ALL_IMPLS
163 +
164 +# @FUNCTION: _lua_set_impls
165 +# @INTERNAL
166 +# @DESCRIPTION:
167 +# Check LUA_COMPAT for well-formedness and validity, then set
168 +# two global variables:
169 +#
170 +# - _LUA_SUPPORTED_IMPLS containing valid implementations supported
171 +# by the ebuild (LUA_COMPAT minus dead implementations),
172 +#
173 +# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that
174 +# are not supported by the ebuild.
175 +#
176 +# Implementations in both variables are ordered using the pre-defined
177 +# eclass implementation ordering.
178 +#
179 +# This function must only be called once.
180 +_lua_set_impls() {
181 + local i
182 +
183 + if ! declare -p LUA_COMPAT &>/dev/null; then
184 + die 'LUA_COMPAT not declared.'
185 + fi
186 + if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then
187 + die 'LUA_COMPAT must be an array.'
188 + fi
189 +
190 + local supp=() unsupp=()
191 +
192 + for i in "${_LUA_ALL_IMPLS[@]}"; do
193 + if has "${i}" "${LUA_COMPAT[@]}"; then
194 + supp+=( "${i}" )
195 + else
196 + unsupp+=( "${i}" )
197 + fi
198 + done
199 +
200 + if [[ ! ${supp[@]} ]]; then
201 + die "No supported implementation in LUA_COMPAT."
202 + fi
203 +
204 + if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then
205 + # set once already, verify integrity
206 + if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
207 + eerror "Supported impls (LUA_COMPAT) changed between inherits!"
208 + eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}"
209 + eerror "Now : ${supp[*]}"
210 + die "_LUA_SUPPORTED_IMPLS integrity check failed"
211 + fi
212 + if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
213 + eerror "Unsupported impls changed between inherits!"
214 + eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}"
215 + eerror "Now : ${unsupp[*]}"
216 + die "_LUA_UNSUPPORTED_IMPLS integrity check failed"
217 + fi
218 + else
219 + _LUA_SUPPORTED_IMPLS=( "${supp[@]}" )
220 + _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
221 + readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS
222 + fi
223 +}
224 +
225 +# @FUNCTION: _lua_wrapper_setup
226 +# @USAGE: [<path> [<impl>]]
227 +# @INTERNAL
228 +# @DESCRIPTION:
229 +# Create proper Lua executables and pkg-config wrappers
230 +# (if available) in the directory named by <path>. Set up PATH
231 +# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${ELUA}.
232 +#
233 +# The wrappers will be created for implementation named by <impl>,
234 +# or for one named by ${ELUA} if no <impl> passed.
235 +#
236 +# If the named directory contains a lua symlink already, it will
237 +# be assumed to contain proper wrappers already and only environment
238 +# setup will be done. If wrapper update is requested, the directory
239 +# shall be removed first.
240 +_lua_wrapper_setup() {
241 + debug-print-function ${FUNCNAME} "${@}"
242 +
243 + local workdir=${1:-${T}/${ELUA}}
244 + local impl=${2:-${ELUA}}
245 +
246 + [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified."
247 + [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified."
248 +
249 + if [[ ! -x ${workdir}/bin/lua ]]; then
250 + mkdir -p "${workdir}"/{bin,pkgconfig} || die
251 +
252 + # Clean up, in case we were supposed to do a cheap update
253 + rm -f "${workdir}"/bin/lua{,c} || die
254 + rm -f "${workdir}"/pkgconfig/lua.pc || die
255 +
256 + local ELUA LUA
257 + _lua_export "${impl}" ELUA LUA
258 +
259 + # Lua interpreter
260 + ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die
261 +
262 + # Lua compiler, or a stub for it in case of luajit
263 + if [[ ${ELUA} == luajit ]]; then
264 + # Just in case
265 + ln -s "${EPREFIX}"/bin/true "${workdir}"/bin/luac || die
266 + else
267 + ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
268 + fi
269 +
270 + # pkg-config
271 + ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \
272 + "${workdir}"/pkgconfig/lua.pc || die
273 + fi
274 +
275 + # Now, set the environment.
276 + # But note that ${workdir} may be shared with something else,
277 + # and thus already on top of PATH.
278 + if [[ ${PATH##:*} != ${workdir}/bin ]]; then
279 + PATH=${workdir}/bin${PATH:+:${PATH}}
280 + fi
281 + if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
282 + PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
283 + fi
284 + export PATH PKG_CONFIG_PATH
285 +}
286 +
287 +# @ECLASS-VARIABLE: ELUA
288 +# @DEFAULT_UNSET
289 +# @DESCRIPTION:
290 +# The executable name of the current Lua interpreter. This variable is set
291 +# automatically in functions called by lua_foreach_impl().
292 +#
293 +# Example value:
294 +# @CODE
295 +# lua5.1
296 +# @CODE
297 +
298 +# @ECLASS-VARIABLE: LUA
299 +# @DEFAULT_UNSET
300 +# @DESCRIPTION:
301 +# The absolute path to the current Lua interpreter. This variable is set
302 +# automatically in functions called by lua_foreach_impl().
303 +#
304 +# Example value:
305 +# @CODE
306 +# /usr/bin/lua5.1
307 +# @CODE
308 +
309 +# @FUNCTION: _lua_get_library_file
310 +# @USAGE: <impl>
311 +# @INTERNAL
312 +# @DESCRIPTION:
313 +# Get the core part (i.e. without the extension) of the library name,
314 +# with path, of the given Lua implementation.
315 +# Used internally by _lua_export().
316 +_lua_get_library_file() {
317 + local impl="${1}"
318 + local libdir libname
319 +
320 + case ${impl} in
321 + luajit)
322 + libname=lib$($(tc-getPKG_CONFIG) --variable libname ${impl}) || die
323 + ;;
324 + lua*)
325 + libname=lib${impl}
326 + ;;
327 + *)
328 + die "Invalid implementation: ${impl}"
329 + ;;
330 + esac
331 + libdir=$($(tc-getPKG_CONFIG) --variable libdir ${impl}) || die
332 +
333 + debug-print "${FUNCNAME}: libdir = ${libdir}, libname = ${libname}"
334 + echo "${libdir}/${libname}"
335 +}
336 +
337 +# @FUNCTION: _lua_export
338 +# @USAGE: [<impl>] <variables>...
339 +# @INTERNAL
340 +# @DESCRIPTION:
341 +# Set and export the Lua implementation-relevant variables passed
342 +# as parameters.
343 +#
344 +# The optional first parameter may specify the requested Lua
345 +# implementation (either as LUA_TARGETS value, e.g. lua5-2,
346 +# or an ELUA one, e.g. lua5.2). If no implementation passed,
347 +# the current one will be obtained from ${ELUA}.
348 +_lua_export() {
349 + debug-print-function ${FUNCNAME} "${@}"
350 +
351 + local impl var
352 +
353 + case "${1}" in
354 + luajit)
355 + impl=${1}
356 + shift
357 + ;;
358 + lua*)
359 + impl=${1/-/.}
360 + shift
361 + ;;
362 + *)
363 + impl=${ELUA}
364 + if [[ -z ${impl} ]]; then
365 + die "_lua_export called without a Lua implementation and ELUA is unset"
366 + fi
367 + ;;
368 + esac
369 + debug-print "${FUNCNAME}: implementation: ${impl}"
370 +
371 + for var; do
372 + case "${var}" in
373 + ELUA)
374 + export ELUA=${impl}
375 + debug-print "${FUNCNAME}: ELUA = ${ELUA}"
376 + ;;
377 + LUA)
378 + export LUA="${EPREFIX}"/usr/bin/${impl}
379 + debug-print "${FUNCNAME}: LUA = ${LUA}"
380 + ;;
381 + LUA_CFLAGS)
382 + local val
383 +
384 + val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die
385 +
386 + export LUA_CFLAGS=${val}
387 + debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}"
388 + ;;
389 + LUA_CMOD_DIR)
390 + local val
391 +
392 + val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die
393 +
394 + export LUA_CMOD_DIR=${val}
395 + debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}"
396 + ;;
397 + LUA_INCLUDE_DIR)
398 + local val
399 +
400 + val=$($(tc-getPKG_CONFIG) --variable includedir ${impl}) || die
401 +
402 + export LUA_INCLUDE_DIR=${val}
403 + debug-print "${FUNCNAME}: LUA_INCLUDE_DIR = ${LUA_INCLUDE_DIR}"
404 + ;;
405 + LUA_LIBS)
406 + local val
407 +
408 + val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die
409 +
410 + export LUA_LIBS=${val}
411 + debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}"
412 + ;;
413 + LUA_LMOD_DIR)
414 + local val
415 +
416 + val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die
417 +
418 + export LUA_LMOD_DIR=${val}
419 + debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}"
420 + ;;
421 + LUA_PKG_DEP)
422 + local d
423 + case ${impl} in
424 + luajit)
425 + LUA_PKG_DEP="dev-lang/luajit:="
426 + ;;
427 + lua*)
428 + LUA_PKG_DEP="dev-lang/lua:${impl#lua}"
429 + ;;
430 + *)
431 + die "Invalid implementation: ${impl}"
432 + ;;
433 + esac
434 +
435 + # use-dep
436 + if [[ ${LUA_REQ_USE} ]]; then
437 + LUA_PKG_DEP+=[${LUA_REQ_USE}]
438 + fi
439 +
440 + export LUA_PKG_DEP
441 + debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}"
442 + ;;
443 + LUA_SHARED_LIB)
444 + local val=$(_lua_get_library_file ${impl})
445 + export LUA_SHARED_LIB="${val}".so
446 + debug-print "${FUNCNAME}: LUA_SHARED_LIB = ${LUA_SHARED_LIB}"
447 + ;;
448 + LUA_VERSION)
449 + local val
450 +
451 + val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die
452 +
453 + export LUA_VERSION=${val}
454 + debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}"
455 + ;;
456 + *)
457 + die "_lua_export: unknown variable ${var}"
458 + ;;
459 + esac
460 + done
461 +}
462 +
463 +# @FUNCTION: lua_enable_tests
464 +# @USAGE: <test-runner> <test-directory>
465 +# @DESCRIPTION:
466 +# Set up IUSE, RESTRICT, BDEPEND and src_test() for running tests
467 +# with the specified test runner. Also copies the current value
468 +# of RDEPEND to test?-BDEPEND. The test-runner argument must be one of:
469 +#
470 +# - busted: dev-lua/busted
471 +#
472 +# Additionally, a second argument can be passed after <test-runner>,
473 +# so <test-runner> will use that directory to search for tests.
474 +# If not passed, a default directory of <test-runner> will be used.
475 +#
476 +# - busted: spec
477 +#
478 +# This function is meant as a helper for common use cases, and it only
479 +# takes care of basic setup. You still need to list additional test
480 +# dependencies manually. If you have uncommon use case, you should
481 +# not use it and instead enable tests manually.
482 +#
483 +# This function must be called in global scope, after RDEPEND has been
484 +# declared. Take care not to overwrite the variables set by it.
485 +lua_enable_tests() {
486 + debug-print-function ${FUNCNAME} "${@}"
487 +
488 + [[ ${#} -ge 1 ]] || die "${FUNCNAME} takes at least one argument: test-runner (test-directory)"
489 + local test_directory
490 + local test_pkg
491 + case ${1} in
492 + busted)
493 + test_directory="${2:-spec}"
494 + test_pkg="dev-lua/busted"
495 + if [[ ! ${_LUA_SINGLE_R0} ]]; then
496 + eval "lua_src_test() {
497 + busted --lua=\"\${ELUA}\" --output=\"plainTerminal\" \"${test_directory}\" || die \"Tests fail with \${ELUA}\"
498 + }"
499 + src_test() {
500 + lua_foreach_impl lua_src_test
501 + }
502 + else
503 + eval "src_test() {
504 + busted --lua=\"\${ELUA}\" --output=\"plainTerminal\" \"${test_directory}\" || die \"Tests fail with \${ELUA}\"
505 + }"
506 + fi
507 + ;;
508 + *)
509 + die "${FUNCNAME}: unsupported argument: ${1}"
510 + esac
511 +
512 + local test_deps=${RDEPEND}
513 + if [[ -n ${test_pkg} ]]; then
514 + if [[ ! ${_LUA_SINGLE_R0} ]]; then
515 + test_deps+=" ${test_pkg}[${LUA_USEDEP}]"
516 + else
517 + test_deps+=" $(lua_gen_cond_dep "
518 + ${test_pkg}[\${LUA_USEDEP}]
519 + ")"
520 + fi
521 + fi
522 + if [[ -n ${test_deps} ]]; then
523 + IUSE+=" test"
524 + RESTRICT+=" !test? ( test )"
525 + BDEPEND+=" test? ( ${test_deps} )"
526 + fi
527 +
528 + # we need to ensure successful return in case we're called last,
529 + # otherwise Portage may wrongly assume sourcing failed
530 + return 0
531 +}
532 +
533 +# @FUNCTION: lua_get_CFLAGS
534 +# @USAGE: [<impl>]
535 +# @DESCRIPTION:
536 +# Obtain and print the compiler flags for building against Lua,
537 +# for the given implementation. If no implementation is provided,
538 +# ${ELUA} will be used.
539 +#
540 +# Please note that this function requires Lua and pkg-config installed,
541 +# and therefore proper build-time dependencies need be added to the ebuild.
542 +lua_get_CFLAGS() {
543 + debug-print-function ${FUNCNAME} "${@}"
544 +
545 + _lua_export "${@}" LUA_CFLAGS
546 + echo "${LUA_CFLAGS}"
547 +}
548 +
549 +# @FUNCTION: lua_get_cmod_dir
550 +# @USAGE: [<impl>]
551 +# @DESCRIPTION:
552 +# Obtain and print the name of the directory into which compiled Lua
553 +# modules are installed, for the given implementation. If no implementation
554 +# is provided, ${ELUA} will be used.
555 +#
556 +# Please note that this function requires Lua and pkg-config installed,
557 +# and therefore proper build-time dependencies need be added to the ebuild.
558 +lua_get_cmod_dir() {
559 + debug-print-function ${FUNCNAME} "${@}"
560 +
561 + _lua_export "${@}" LUA_CMOD_DIR
562 + echo "${LUA_CMOD_DIR}"
563 +}
564 +
565 +# @FUNCTION: lua_get_include_dir
566 +# @USAGE: [<impl>]
567 +# @DESCRIPTION:
568 +# Obtain and print the name of the directory containing header files
569 +# of the given Lua implementation. If no implementation is provided,
570 +# ${ELUA} will be used.
571 +#
572 +# Please note that this function requires Lua and pkg-config installed,
573 +# and therefore proper build-time dependencies need be added to the ebuild.
574 +lua_get_include_dir() {
575 + debug-print-function ${FUNCNAME} "${@}"
576 +
577 + _lua_export "${@}" LUA_INCLUDE_DIR
578 + echo "${LUA_INCLUDE_DIR}"
579 +}
580 +
581 +# @FUNCTION: lua_get_LIBS
582 +# @USAGE: [<impl>]
583 +# @DESCRIPTION:
584 +# Obtain and print the compiler flags for linking against Lua,
585 +# for the given implementation. If no implementation is provided,
586 +# ${ELUA} will be used.
587 +#
588 +# Please note that this function requires Lua and pkg-config installed,
589 +# and therefore proper build-time dependencies need be added to the ebuild.
590 +lua_get_LIBS() {
591 + debug-print-function ${FUNCNAME} "${@}"
592 +
593 + _lua_export "${@}" LUA_LIBS
594 + echo "${LUA_LIBS}"
595 +}
596 +
597 +# @FUNCTION: lua_get_lmod_dir
598 +# @USAGE: [<impl>]
599 +# @DESCRIPTION:
600 +# Obtain and print the name of the directory into which native-Lua
601 +# modules are installed, for the given implementation. If no implementation
602 +# is provided, ${ELUA} will be used.
603 +#
604 +# Please note that this function requires Lua and pkg-config installed,
605 +# and therefore proper build-time dependencies need be added to the ebuild.
606 +lua_get_lmod_dir() {
607 + debug-print-function ${FUNCNAME} "${@}"
608 +
609 + _lua_export "${@}" LUA_LMOD_DIR
610 + echo "${LUA_LMOD_DIR}"
611 +}
612 +
613 +# @FUNCTION: lua_get_shared_lib
614 +# @USAGE: [<impl>]
615 +# @DESCRIPTION:
616 +# Obtain and print the expected name, with path, of the main shared library
617 +# of the given Lua implementation. If no implementation is provided,
618 +# ${ELUA} will be used.
619 +#
620 +# Note that it is up to the ebuild maintainer to ensure Lua actually
621 +# provides a shared library.
622 +#
623 +# Please note that this function requires Lua and pkg-config installed,
624 +# and therefore proper build-time dependencies need be added to the ebuild.
625 +lua_get_shared_lib() {
626 + debug-print-function ${FUNCNAME} "${@}"
627 +
628 + _lua_export "${@}" LUA_SHARED_LIB
629 + echo "${LUA_SHARED_LIB}"
630 +}
631 +
632 +# @FUNCTION: lua_get_version
633 +# @USAGE: [<impl>]
634 +# @DESCRIPTION:
635 +# Obtain and print the full version number of the given Lua implementation.
636 +# If no implementation is provided, ${ELUA} will be used.
637 +#
638 +# Please note that this function requires Lua and pkg-config installed,
639 +# and therefore proper build-time dependencies need be added to the ebuild.
640 +lua_get_version() {
641 + debug-print-function ${FUNCNAME} "${@}"
642 +
643 + _lua_export "${@}" LUA_VERSION
644 + echo "${LUA_VERSION}"
645 +}
646 +
647 +_LUA_UTILS_R0=1
648 +fi
649 --
650 2.30.0