Gentoo Archives: gentoo-commits

From: Marek Szuba <marecki@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Mon, 05 Oct 2020 12:14:56
Message-Id: 1601900015.c7f4f296d7e3c67413a82b3fc3eb29dd6cea79bf.marecki@gentoo
1 commit: c7f4f296d7e3c67413a82b3fc3eb29dd6cea79bf
2 Author: Marek Szuba <marecki <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 28 16:33:23 2020 +0000
4 Commit: Marek Szuba <marecki <AT> gentoo <DOT> org>
5 CommitDate: Mon Oct 5 12:13:35 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c7f4f296
7
8 lua.eclass: split some stuff out as lua-utils.eclass
9
10 These are the things that will be used by both lua and lua-single.
11
12 Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
13
14 eclass/{lua.eclass => lua-utils.eclass} | 589 +++++++-------------------------
15 eclass/lua.eclass | 345 +------------------
16 2 files changed, 132 insertions(+), 802 deletions(-)
17
18 diff --git a/eclass/lua.eclass b/eclass/lua-utils.eclass
19 similarity index 51%
20 copy from eclass/lua.eclass
21 copy to eclass/lua-utils.eclass
22 index 7dccba6980a..490d19a0019 100644
23 --- a/eclass/lua.eclass
24 +++ b/eclass/lua-utils.eclass
25 @@ -1,52 +1,23 @@
26 # Copyright 1999-2020 Gentoo Authors
27 # Distributed under the terms of the GNU General Public License v2
28
29 -# @ECLASS: lua.eclass
30 +# @ECLASS: lua-utils.eclass
31 # @MAINTAINER:
32 # William Hubbs <williamh@g.o>
33 # Marek Szuba <marecki@g.o>
34 # @AUTHOR:
35 # Marek Szuba <marecki@g.o>
36 -# Based on python{,-utils}-r1.eclass by Michał Górny <mgorny@g.o> et al.
37 +# Based on python-utils-r1.eclass by Michał Górny <mgorny@g.o> et al.
38 # @SUPPORTED_EAPIS: 7
39 -# @BLURB: A common eclass for Lua packages
40 +# @BLURB: Utility functions for packages with Lua parts
41 # @DESCRIPTION:
42 -# A common eclass providing helper functions to build and install
43 -# packages supporting being installed for multiple Lua implementations.
44 -#
45 -# This eclass sets correct IUSE. Modification of REQUIRED_USE has to
46 -# be done by the author of the ebuild (but LUA_REQUIRED_USE is
47 -# provided for convenience, see below). The eclass exports LUA_DEPS
48 -# and LUA_USEDEP so you can create correct dependencies for your
49 -# package easily. It also provides methods to easily run a command for
50 -# each enabled Lua implementation and duplicate the sources for them.
51 +# A utility eclass providing functions to query Lua implementations,
52 +# install Lua modules and scripts.
53 #
54 # Please note that for the time being this eclass does NOT support luajit.
55 #
56 -# @EXAMPLE:
57 -# @CODE
58 -# EAPI=7
59 -#
60 -# LUA_COMPAT=( lua5-{1..3} )
61 -#
62 -# inherit lua
63 -#
64 -# [...]
65 -#
66 -# REQUIRED_USE="${LUA_REQUIRED_USE}"
67 -# DEPEND="${LUA_DEPS}"
68 -# RDEPEND="${DEPEND}
69 -# dev-lua/foo[${LUA_USEDEP}]"
70 -# BDEPEND="virtual/pkgconfig"
71 -#
72 -# lua_src_install() {
73 -# emake LUA_VERSION="$(lua_get_version)" install
74 -# }
75 -#
76 -# src_install() {
77 -# lua_foreach_impl lua_src_install
78 -# }
79 -# @CODE
80 +# This eclass neither sets any metadata variables nor exports any phase
81 +# functions. It can be inherited safely.
82
83 case ${EAPI:-0} in
84 0|1|2|3|4|5|6)
85 @@ -59,86 +30,137 @@ case ${EAPI:-0} in
86 ;;
87 esac
88
89 -if [[ ! ${_LUA_R0} ]]; then
90 +if [[ ! ${_LUA_UTILS_R0} ]]; then
91
92 -inherit multibuild toolchain-funcs
93 +inherit toolchain-funcs
94
95 -fi
96 -
97 -# @ECLASS-VARIABLE: LUA_COMPAT
98 -# @REQUIRED
99 -# @PRE_INHERIT
100 +# @ECLASS-VARIABLE: _LUA_ALL_IMPLS
101 +# @INTERNAL
102 # @DESCRIPTION:
103 -# This variable contains a list of Lua implementations the package
104 -# supports. It must be set before the `inherit' call. It has to be
105 -# an array.
106 -#
107 -# Example:
108 -# @CODE
109 -# LUA_COMPAT=( lua5-1 lua5-2 lua5-3 )
110 -# @CODE
111 -#
112 -# Please note that you can also use bash brace expansion if you like:
113 -# @CODE
114 -# LUA_COMPAT=( lua5-{1..3} )
115 -# @CODE
116 +# All supported Lua implementations, most preferred last
117 +_LUA_ALL_IMPLS=(
118 + lua5-1
119 + lua5-2
120 + lua5-3
121 + lua5-4
122 +)
123 +readonly _LUA_ALL_IMPLS
124
125 -# @ECLASS-VARIABLE: LUA_COMPAT_OVERRIDE
126 -# @USER_VARIABLE
127 -# @DEFAULT_UNSET
128 +# @FUNCTION: _lua_set_impls
129 +# @INTERNAL
130 # @DESCRIPTION:
131 -# This variable can be used when working with ebuilds to override
132 -# the in-ebuild LUA_COMPAT. It is a string listing all
133 -# the implementations which package will be built for. It need be
134 -# specified in the calling environment, and not in ebuilds.
135 +# Check LUA_COMPAT for well-formedness and validity, then set
136 +# two global variables:
137 #
138 -# It should be noted that in order to preserve metadata immutability,
139 -# LUA_COMPAT_OVERRIDE does not affect IUSE nor dependencies.
140 -# The state of LUA_TARGETS is ignored, and all the implementations
141 -# in LUA_COMPAT_OVERRIDE are built. Dependencies need to be satisfied
142 -# manually.
143 +# - _LUA_SUPPORTED_IMPLS containing valid implementations supported
144 +# by the ebuild (LUA_COMPAT minus dead implementations),
145 #
146 -# Example:
147 -# @CODE
148 -# LUA_COMPAT_OVERRIDE='lua5-2' emerge -1v dev-lua/foo
149 -# @CODE
150 -
151 -# @ECLASS-VARIABLE: LUA_REQ_USE
152 -# @DEFAULT_UNSET
153 -# @PRE_INHERIT
154 -# @DESCRIPTION:
155 -# The list of USE flags required to be enabled on the chosen Lua
156 -# implementations, formed as a USE-dependency string. It should be valid
157 -# for all implementations in LUA_COMPAT, so it may be necessary to
158 -# use USE defaults.
159 -# This must be set before calling `inherit'.
160 +# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that
161 +# are not supported by the ebuild.
162 #
163 -# Example:
164 -# @CODE
165 -# LUA_REQ_USE="deprecated"
166 -# @CODE
167 +# Implementations in both variables are ordered using the pre-defined
168 +# eclass implementation ordering.
169 #
170 -# It will cause the Lua dependencies to look like:
171 -# @CODE
172 -# lua_targets_luaX-Y? ( dev-lang/lua:X.Y[deprecated] )
173 -# @CODE
174 +# This function must only be called once.
175 +_lua_set_impls() {
176 + local i
177
178 -# @ECLASS-VARIABLE: BUILD_DIR
179 -# @OUTPUT_VARIABLE
180 -# @DEFAULT_UNSET
181 + if ! declare -p LUA_COMPAT &>/dev/null; then
182 + die 'LUA_COMPAT not declared.'
183 + fi
184 + if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then
185 + die 'LUA_COMPAT must be an array.'
186 + fi
187 +
188 + local supp=() unsupp=()
189 +
190 + for i in "${_LUA_ALL_IMPLS[@]}"; do
191 + if has "${i}" "${LUA_COMPAT[@]}"; then
192 + supp+=( "${i}" )
193 + else
194 + unsupp+=( "${i}" )
195 + fi
196 + done
197 +
198 + if [[ ! ${supp[@]} ]]; then
199 + die "No supported implementation in LUA_COMPAT."
200 + fi
201 +
202 + if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then
203 + # set once already, verify integrity
204 + if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
205 + eerror "Supported impls (LUA_COMPAT) changed between inherits!"
206 + eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}"
207 + eerror "Now : ${supp[*]}"
208 + die "_LUA_SUPPORTED_IMPLS integrity check failed"
209 + fi
210 + if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
211 + eerror "Unsupported impls changed between inherits!"
212 + eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}"
213 + eerror "Now : ${unsupp[*]}"
214 + die "_LUA_UNSUPPORTED_IMPLS integrity check failed"
215 + fi
216 + else
217 + _LUA_SUPPORTED_IMPLS=( "${supp[@]}" )
218 + _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
219 + readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS
220 + fi
221 +}
222 +
223 +# @FUNCTION: _lua_wrapper_setup
224 +# @USAGE: [<path> [<impl>]]
225 +# @INTERNAL
226 # @DESCRIPTION:
227 -# The current build directory. In global scope, it is supposed to
228 -# contain an initial build directory; if unset, it defaults to ${S}.
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 -# In functions run by lua_foreach_impl(), the BUILD_DIR is locally
234 -# set to an implementation-specific build directory. That path is
235 -# created through appending a hyphen and the implementation name
236 -# to the final component of the initial BUILD_DIR.
237 +# The wrappers will be created for implementation named by <impl>,
238 +# or for one named by ${ELUA} if no <impl> passed.
239 #
240 -# Example value:
241 -# @CODE
242 -# ${WORKDIR}/foo-1.3-lua5-1
243 -# @CODE
244 +# If the named directory contains a lua symlink already, it will
245 +# be assumed to contain proper wrappers already and only environment
246 +# setup will be done. If wrapper update is requested, the directory
247 +# shall be removed first.
248 +_lua_wrapper_setup() {
249 + debug-print-function ${FUNCNAME} "${@}"
250 +
251 + local workdir=${1:-${T}/${ELUA}}
252 + local impl=${2:-${ELUA}}
253 +
254 + [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified."
255 + [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified."
256 +
257 + if [[ ! -x ${workdir}/bin/lua ]]; then
258 + mkdir -p "${workdir}"/{bin,pkgconfig} || die
259 +
260 + # Clean up, in case we were supposed to do a cheap update
261 + rm -f "${workdir}"/bin/lua{,c} || die
262 + rm -f "${workdir}"/pkgconfig/lua.pc || die
263 +
264 + local ELUA LUA
265 + _lua_export "${impl}" ELUA LUA
266 +
267 + # Lua interpreter and compiler
268 + ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die
269 + ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
270 +
271 + # pkg-config
272 + ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \
273 + "${workdir}"/pkgconfig/lua.pc || die
274 + fi
275 +
276 + # Now, set the environment.
277 + # But note that ${workdir} may be shared with something else,
278 + # and thus already on top of PATH.
279 + if [[ ${PATH##:*} != ${workdir}/bin ]]; then
280 + PATH=${workdir}/bin${PATH:+:${PATH}}
281 + fi
282 + if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
283 + PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
284 + fi
285 + export PATH PKG_CONFIG_PATH
286 +}
287
288 # @ECLASS-VARIABLE: ELUA
289 # @DEFAULT_UNSET
290 @@ -162,63 +184,6 @@ fi
291 # /usr/bin/lua5.1
292 # @CODE
293
294 -# @ECLASS-VARIABLE: LUA_DEPS
295 -# @OUTPUT_VARIABLE
296 -# @DESCRIPTION:
297 -# This is an eclass-generated Lua dependency string for all
298 -# implementations listed in LUA_COMPAT.
299 -#
300 -# Example use:
301 -# @CODE
302 -# RDEPEND="${LUA_DEPS}
303 -# dev-foo/mydep"
304 -# DEPEND="${RDEPEND}"
305 -# @CODE
306 -#
307 -# Example value:
308 -# @CODE
309 -# lua_targets_lua5-1? ( dev-lang/lua:5.1 )
310 -# lua_targets_lua5-2? ( dev-lang/lua:5.2 )
311 -# @CODE
312 -
313 -# @ECLASS-VARIABLE: LUA_REQUIRED_USE
314 -# @OUTPUT_VARIABLE
315 -# @DESCRIPTION:
316 -# This is an eclass-generated required-use expression which ensures at
317 -# least one Lua implementation has been enabled.
318 -#
319 -# This expression should be utilized in an ebuild by including it in
320 -# REQUIRED_USE, optionally behind a use flag.
321 -#
322 -# Example use:
323 -# @CODE
324 -# REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )"
325 -# @CODE
326 -#
327 -# Example value:
328 -# @CODE
329 -# || ( lua_targets_lua5-1 lua_targets_lua5-2 )
330 -# @CODE
331 -
332 -# @ECLASS-VARIABLE: LUA_USEDEP
333 -# @OUTPUT_VARIABLE
334 -# @DESCRIPTION:
335 -# This is an eclass-generated USE-dependency string which can be used to
336 -# depend on another Lua package being built for the same Lua
337 -# implementations.
338 -#
339 -# Example use:
340 -# @CODE
341 -# RDEPEND="dev-lua/foo[${LUA_USEDEP}]"
342 -# @CODE
343 -#
344 -# Example value:
345 -# @CODE
346 -# lua_targets_lua5-1(-)?,lua_targets_lua5-2(-)?
347 -# @CODE
348 -
349 -if [[ ! ${_LUA_R0} ]]; then
350 -
351 # @FUNCTION: _lua_export
352 # @USAGE: [<impl>] <variables>...
353 # @INTERNAL
354 @@ -325,176 +290,6 @@ _lua_export() {
355 done
356 }
357
358 -# @FUNCTION: _lua_validate_useflags
359 -# @INTERNAL
360 -# @DESCRIPTION:
361 -# Enforce the proper setting of LUA_TARGETS, if LUA_COMPAT_OVERRIDE
362 -# is not in effect. If it is, just warn that the flags will be ignored.
363 -_lua_validate_useflags() {
364 - debug-print-function ${FUNCNAME} "${@}"
365 -
366 - if [[ ${LUA_COMPAT_OVERRIDE} ]]; then
367 - if [[ ! ${_LUA_COMPAT_OVERRIDE_WARNED} ]]; then
368 - ewarn "WARNING: LUA_COMPAT_OVERRIDE in effect. The following Lua"
369 - ewarn "implementations will be enabled:"
370 - ewarn
371 - ewarn " ${LUA_COMPAT_OVERRIDE}"
372 - ewarn
373 - ewarn "Dependencies won't be satisfied, and LUA_TARGETS will be ignored."
374 - _LUA_COMPAT_OVERRIDE_WARNED=1
375 - fi
376 - # we do not use flags with LCO
377 - return
378 - fi
379 -
380 - local i
381 -
382 - for i in "${_LUA_SUPPORTED_IMPLS[@]}"; do
383 - use "lua_targets_${i}" && return 0
384 - done
385 -
386 - eerror "No Lua implementation selected for the build. Please add one"
387 - eerror "of the following values to your LUA_TARGETS"
388 - eerror "(in make.conf or package.use):"
389 - eerror
390 - eerror "${LUA_COMPAT[@]}"
391 - echo
392 - die "No supported Lua implementation in LUA_TARGETS."
393 -}
394 -
395 -# @FUNCTION: _lua_obtain_impls
396 -# @INTERNAL
397 -# @DESCRIPTION:
398 -# Set up the enabled implementation list.
399 -_lua_obtain_impls() {
400 - _lua_validate_useflags
401 -
402 - if [[ ${LUA_COMPAT_OVERRIDE} ]]; then
403 - MULTIBUILD_VARIANTS=( ${LUA_COMPAT_OVERRIDE} )
404 - return
405 - fi
406 -
407 - MULTIBUILD_VARIANTS=()
408 -
409 - local impl
410 - for impl in "${_LUA_SUPPORTED_IMPLS[@]}"; do
411 - has "${impl}" "${LUA_COMPAT[@]}" && \
412 - use "lua_targets_${impl}" && MULTIBUILD_VARIANTS+=( "${impl}" )
413 - done
414 -}
415 -
416 -
417 -# @FUNCTION: _lua_multibuild_wrapper
418 -# @USAGE: <command> [<args>...]
419 -# @INTERNAL
420 -# @DESCRIPTION:
421 -# Initialize the environment for the Lua implementation selected
422 -# for multibuild.
423 -_lua_multibuild_wrapper() {
424 - debug-print-function ${FUNCNAME} "${@}"
425 -
426 - local -x ELUA LUA
427 - _lua_export "${MULTIBUILD_VARIANT}" ELUA LUA
428 - local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
429 - _lua_wrapper_setup
430 -
431 - "${@}"
432 -}
433 -
434 -# @FUNCTION: _lua_wrapper_setup
435 -# @USAGE: [<path> [<impl>]]
436 -# @INTERNAL
437 -# @DESCRIPTION:
438 -# Create proper Lua executables and pkg-config wrappers
439 -# (if available) in the directory named by <path>. Set up PATH
440 -# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${ELUA}.
441 -#
442 -# The wrappers will be created for implementation named by <impl>,
443 -# or for one named by ${ELUA} if no <impl> passed.
444 -#
445 -# If the named directory contains a lua symlink already, it will
446 -# be assumed to contain proper wrappers already and only environment
447 -# setup will be done. If wrapper update is requested, the directory
448 -# shall be removed first.
449 -_lua_wrapper_setup() {
450 - debug-print-function ${FUNCNAME} "${@}"
451 -
452 - local workdir=${1:-${T}/${ELUA}}
453 - local impl=${2:-${ELUA}}
454 -
455 - [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified."
456 - [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified."
457 -
458 - if [[ ! -x ${workdir}/bin/lua ]]; then
459 - mkdir -p "${workdir}"/{bin,pkgconfig} || die
460 -
461 - # Clean up, in case we were supposed to do a cheap update
462 - rm -f "${workdir}"/bin/lua{,c} || die
463 - rm -f "${workdir}"/pkgconfig/lua.pc || die
464 -
465 - local ELUA LUA
466 - _lua_export "${impl}" ELUA LUA
467 -
468 - # Lua interpreter and compiler
469 - ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die
470 - ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
471 -
472 - # pkg-config
473 - ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \
474 - "${workdir}"/pkgconfig/lua.pc || die
475 - fi
476 -
477 - # Now, set the environment.
478 - # But note that ${workdir} may be shared with something else,
479 - # and thus already on top of PATH.
480 - if [[ ${PATH##:*} != ${workdir}/bin ]]; then
481 - PATH=${workdir}/bin${PATH:+:${PATH}}
482 - fi
483 - if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
484 - PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
485 - fi
486 - export PATH PKG_CONFIG_PATH
487 -}
488 -
489 -# @FUNCTION: lua_copy_sources
490 -# @DESCRIPTION:
491 -# Create a single copy of the package sources for each enabled Lua
492 -# implementation.
493 -#
494 -# The sources are always copied from initial BUILD_DIR (or S if unset)
495 -# to implementation-specific build directory matching BUILD_DIR used by
496 -# lua_foreach_abi().
497 -lua_copy_sources() {
498 - debug-print-function ${FUNCNAME} "${@}"
499 -
500 - local MULTIBUILD_VARIANTS
501 - _lua_obtain_impls
502 -
503 - multibuild_copy_sources
504 -}
505 -
506 -# @FUNCTION: lua_foreach_impl
507 -# @USAGE: <command> [<args>...]
508 -# @DESCRIPTION:
509 -# Run the given command for each of the enabled Lua implementations.
510 -# If additional parameters are passed, they will be passed through
511 -# to the command.
512 -#
513 -# The function will return 0 status if all invocations succeed.
514 -# Otherwise, the return code from first failing invocation will
515 -# be returned.
516 -#
517 -# For each command being run, ELUA, LUA and BUILD_DIR are set
518 -# locally, and the former two are exported to the command environment.
519 -lua_foreach_impl() {
520 - debug-print-function ${FUNCNAME} "${@}"
521 -
522 - local MULTIBUILD_VARIANTS
523 - _lua_obtain_impls
524 -
525 - multibuild_foreach_variant _lua_multibuild_wrapper "${@}"
526 -}
527 -
528 # @FUNCTION: lua_get_CFLAGS
529 # @USAGE: [<impl>]
530 # @DESCRIPTION:
531 @@ -574,137 +369,5 @@ lua_get_version() {
532 echo "${LUA_VERSION}"
533 }
534
535 -_LUA_R0=1
536 +_LUA_UTILS_R0=1
537 fi
538 -
539 -# @ECLASS-VARIABLE: _LUA_ALL_IMPLS
540 -# @INTERNAL
541 -# @DESCRIPTION:
542 -# All supported Lua implementations, most preferred last
543 -_LUA_ALL_IMPLS=(
544 - lua5-1
545 - lua5-2
546 - lua5-3
547 - lua5-4
548 -)
549 -readonly _LUA_ALL_IMPLS
550 -
551 -# @FUNCTION: _lua_set_impls
552 -# @INTERNAL
553 -# @DESCRIPTION:
554 -# Check LUA_COMPAT for well-formedness and validity, then set
555 -# two global variables:
556 -#
557 -# - _LUA_SUPPORTED_IMPLS containing valid implementations supported
558 -# by the ebuild (LUA_COMPAT minus dead implementations),
559 -#
560 -# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that
561 -# are not supported by the ebuild.
562 -#
563 -# Implementations in both variables are ordered using the pre-defined
564 -# eclass implementation ordering.
565 -#
566 -# This function must only be called once.
567 -_lua_set_impls() {
568 - local i
569 -
570 - if ! declare -p LUA_COMPAT &>/dev/null; then
571 - die 'LUA_COMPAT not declared.'
572 - fi
573 - if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then
574 - die 'LUA_COMPAT must be an array.'
575 - fi
576 -
577 - local supp=() unsupp=()
578 -
579 - for i in "${_LUA_ALL_IMPLS[@]}"; do
580 - if has "${i}" "${LUA_COMPAT[@]}"; then
581 - supp+=( "${i}" )
582 - else
583 - unsupp+=( "${i}" )
584 - fi
585 - done
586 -
587 - if [[ ! ${supp[@]} ]]; then
588 - die "No supported implementation in LUA_COMPAT."
589 - fi
590 -
591 - if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then
592 - # set once already, verify integrity
593 - if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
594 - eerror "Supported impls (LUA_COMPAT) changed between inherits!"
595 - eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}"
596 - eerror "Now : ${supp[*]}"
597 - die "_LUA_SUPPORTED_IMPLS integrity check failed"
598 - fi
599 - if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
600 - eerror "Unsupported impls changed between inherits!"
601 - eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}"
602 - eerror "Now : ${unsupp[*]}"
603 - die "_LUA_UNSUPPORTED_IMPLS integrity check failed"
604 - fi
605 - else
606 - _LUA_SUPPORTED_IMPLS=( "${supp[@]}" )
607 - _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
608 - readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS
609 - fi
610 -}
611 -
612 -# @FUNCTION: _lua_set_globals
613 -# @INTERNAL
614 -# @DESCRIPTION:
615 -# Sets all the global output variables provided by this eclass.
616 -# This function must be called once, in global scope.
617 -_lua_set_globals() {
618 - local deps i LUA_PKG_DEP
619 -
620 - _lua_set_impls
621 -
622 - for i in "${_LUA_SUPPORTED_IMPLS[@]}"; do
623 - _lua_export "${i}" LUA_PKG_DEP
624 - deps+="lua_targets_${i}? ( ${LUA_PKG_DEP} ) "
625 - done
626 -
627 - local flags=( "${_LUA_SUPPORTED_IMPLS[@]/#/lua_targets_}" )
628 - local optflags=${flags[@]/%/(-)?}
629 -
630 - local requse="|| ( ${flags[*]} )"
631 - local usedep=${optflags// /,}
632 -
633 - if [[ ${LUA_DEPS+1} ]]; then
634 - # IUSE is magical, so we can't really check it
635 - # (but we verify LUA_COMPAT already)
636 -
637 - if [[ ${LUA_DEPS} != "${deps}" ]]; then
638 - eerror "LUA_DEPS have changed between inherits (LUA_REQ_USE?)!"
639 - eerror "Before: ${LUA_DEPS}"
640 - eerror "Now : ${deps}"
641 - die "LUA_DEPS integrity check failed"
642 - fi
643 -
644 - # these two are formality -- they depend on LUA_COMPAT only
645 - if [[ ${LUA_REQUIRED_USE} != ${requse} ]]; then
646 - eerror "LUA_REQUIRED_USE have changed between inherits!"
647 - eerror "Before: ${LUA_REQUIRED_USE}"
648 - eerror "Now : ${requse}"
649 - die "LUA_REQUIRED_USE integrity check failed"
650 - fi
651 -
652 - if [[ ${LUA_USEDEP} != "${usedep}" ]]; then
653 - eerror "LUA_USEDEP have changed between inherits!"
654 - eerror "Before: ${LUA_USEDEP}"
655 - eerror "Now : ${usedep}"
656 - die "LUA_USEDEP integrity check failed"
657 - fi
658 - else
659 - IUSE=${flags[*]}
660 -
661 - LUA_DEPS=${deps}
662 - LUA_REQUIRED_USE=${requse}
663 - LUA_USEDEP=${usedep}
664 - readonly LUA_DEPS LUA_REQUIRED_USE
665 - fi
666 -}
667 -
668 -_lua_set_globals
669 -unset -f _lua_set_globals _lua_set_impls
670
671 diff --git a/eclass/lua.eclass b/eclass/lua.eclass
672 index 7dccba6980a..f4594872e58 100644
673 --- a/eclass/lua.eclass
674 +++ b/eclass/lua.eclass
675 @@ -7,7 +7,7 @@
676 # Marek Szuba <marecki@g.o>
677 # @AUTHOR:
678 # Marek Szuba <marecki@g.o>
679 -# Based on python{,-utils}-r1.eclass by Michał Górny <mgorny@g.o> et al.
680 +# Based on python-r1.eclass by Michał Górny <mgorny@g.o> et al.
681 # @SUPPORTED_EAPIS: 7
682 # @BLURB: A common eclass for Lua packages
683 # @DESCRIPTION:
684 @@ -21,7 +21,9 @@
685 # package easily. It also provides methods to easily run a command for
686 # each enabled Lua implementation and duplicate the sources for them.
687 #
688 -# Please note that for the time being this eclass does NOT support luajit.
689 +# Note that since this eclass always inherits lua-utils as well, in ebuilds
690 +# using the former there is no need to explicitly inherit the latter in order
691 +# to use helper functions such as lua_get_CFLAGS.
692 #
693 # @EXAMPLE:
694 # @CODE
695 @@ -61,7 +63,7 @@ esac
696
697 if [[ ! ${_LUA_R0} ]]; then
698
699 -inherit multibuild toolchain-funcs
700 +inherit multibuild lua-utils
701
702 fi
703
704 @@ -140,28 +142,6 @@ fi
705 # ${WORKDIR}/foo-1.3-lua5-1
706 # @CODE
707
708 -# @ECLASS-VARIABLE: ELUA
709 -# @DEFAULT_UNSET
710 -# @DESCRIPTION:
711 -# The executable name of the current Lua interpreter. This variable is set
712 -# automatically in functions called by lua_foreach_impl().
713 -#
714 -# Example value:
715 -# @CODE
716 -# lua5.1
717 -# @CODE
718 -
719 -# @ECLASS-VARIABLE: LUA
720 -# @DEFAULT_UNSET
721 -# @DESCRIPTION:
722 -# The absolute path to the current Lua interpreter. This variable is set
723 -# automatically in functions called by lua_foreach_impl().
724 -#
725 -# Example value:
726 -# @CODE
727 -# /usr/bin/lua5.1
728 -# @CODE
729 -
730 # @ECLASS-VARIABLE: LUA_DEPS
731 # @OUTPUT_VARIABLE
732 # @DESCRIPTION:
733 @@ -219,112 +199,6 @@ fi
734
735 if [[ ! ${_LUA_R0} ]]; then
736
737 -# @FUNCTION: _lua_export
738 -# @USAGE: [<impl>] <variables>...
739 -# @INTERNAL
740 -# @DESCRIPTION:
741 -# Set and export the Lua implementation-relevant variables passed
742 -# as parameters.
743 -#
744 -# The optional first parameter may specify the requested Lua
745 -# implementation (either as LUA_TARGETS value, e.g. lua5-2,
746 -# or an ELUA one, e.g. lua5.2). If no implementation passed,
747 -# the current one will be obtained from ${ELUA}.
748 -_lua_export() {
749 - debug-print-function ${FUNCNAME} "${@}"
750 -
751 - local impl var
752 -
753 - case "${1}" in
754 - lua*)
755 - impl=${1/-/.}
756 - shift
757 - ;;
758 - *)
759 - impl=${ELUA}
760 - if [[ -z ${impl} ]]; then
761 - die "_lua_export called without a Lua implementation and ELUA is unset"
762 - fi
763 - ;;
764 - esac
765 - debug-print "${FUNCNAME}: implementation: ${impl}"
766 -
767 - for var; do
768 - case "${var}" in
769 - ELUA)
770 - export ELUA=${impl}
771 - debug-print "${FUNCNAME}: ELUA = ${ELUA}"
772 - ;;
773 - LUA)
774 - export LUA="${EPREFIX}"/usr/bin/${impl}
775 - debug-print "${FUNCNAME}: LUA = ${LUA}"
776 - ;;
777 - LUA_CFLAGS)
778 - local val
779 -
780 - val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die
781 -
782 - export LUA_CFLAGS=${val}
783 - debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}"
784 - ;;
785 - LUA_CMOD_DIR)
786 - local val
787 -
788 - val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die
789 -
790 - export LUA_CMOD_DIR=${val}
791 - debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}"
792 - ;;
793 - LUA_LIBS)
794 - local val
795 -
796 - val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die
797 -
798 - export LUA_LIBS=${val}
799 - debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}"
800 - ;;
801 - LUA_LMOD_DIR)
802 - local val
803 -
804 - val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die
805 -
806 - export LUA_LMOD_DIR=${val}
807 - debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}"
808 - ;;
809 - LUA_PKG_DEP)
810 - local d
811 - case ${impl} in
812 - lua*)
813 - LUA_PKG_DEP="dev-lang/lua:${impl#lua}"
814 - ;;
815 - *)
816 - die "Invalid implementation: ${impl}"
817 - ;;
818 - esac
819 -
820 - # use-dep
821 - if [[ ${LUA_REQ_USE} ]]; then
822 - LUA_PKG_DEP+=[${LUA_REQ_USE}]
823 - fi
824 -
825 - export LUA_PKG_DEP
826 - debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}"
827 - ;;
828 - LUA_VERSION)
829 - local val
830 -
831 - val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die
832 -
833 - export LUA_VERSION=${val}
834 - debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}"
835 - ;;
836 - *)
837 - die "_lua_export: unknown variable ${var}"
838 - ;;
839 - esac
840 - done
841 -}
842 -
843 # @FUNCTION: _lua_validate_useflags
844 # @INTERNAL
845 # @DESCRIPTION:
846 @@ -401,61 +275,6 @@ _lua_multibuild_wrapper() {
847 "${@}"
848 }
849
850 -# @FUNCTION: _lua_wrapper_setup
851 -# @USAGE: [<path> [<impl>]]
852 -# @INTERNAL
853 -# @DESCRIPTION:
854 -# Create proper Lua executables and pkg-config wrappers
855 -# (if available) in the directory named by <path>. Set up PATH
856 -# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${ELUA}.
857 -#
858 -# The wrappers will be created for implementation named by <impl>,
859 -# or for one named by ${ELUA} if no <impl> passed.
860 -#
861 -# If the named directory contains a lua symlink already, it will
862 -# be assumed to contain proper wrappers already and only environment
863 -# setup will be done. If wrapper update is requested, the directory
864 -# shall be removed first.
865 -_lua_wrapper_setup() {
866 - debug-print-function ${FUNCNAME} "${@}"
867 -
868 - local workdir=${1:-${T}/${ELUA}}
869 - local impl=${2:-${ELUA}}
870 -
871 - [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified."
872 - [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified."
873 -
874 - if [[ ! -x ${workdir}/bin/lua ]]; then
875 - mkdir -p "${workdir}"/{bin,pkgconfig} || die
876 -
877 - # Clean up, in case we were supposed to do a cheap update
878 - rm -f "${workdir}"/bin/lua{,c} || die
879 - rm -f "${workdir}"/pkgconfig/lua.pc || die
880 -
881 - local ELUA LUA
882 - _lua_export "${impl}" ELUA LUA
883 -
884 - # Lua interpreter and compiler
885 - ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die
886 - ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die
887 -
888 - # pkg-config
889 - ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \
890 - "${workdir}"/pkgconfig/lua.pc || die
891 - fi
892 -
893 - # Now, set the environment.
894 - # But note that ${workdir} may be shared with something else,
895 - # and thus already on top of PATH.
896 - if [[ ${PATH##:*} != ${workdir}/bin ]]; then
897 - PATH=${workdir}/bin${PATH:+:${PATH}}
898 - fi
899 - if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then
900 - PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
901 - fi
902 - export PATH PKG_CONFIG_PATH
903 -}
904 -
905 # @FUNCTION: lua_copy_sources
906 # @DESCRIPTION:
907 # Create a single copy of the package sources for each enabled Lua
908 @@ -495,161 +314,9 @@ lua_foreach_impl() {
909 multibuild_foreach_variant _lua_multibuild_wrapper "${@}"
910 }
911
912 -# @FUNCTION: lua_get_CFLAGS
913 -# @USAGE: [<impl>]
914 -# @DESCRIPTION:
915 -# Obtain and print the compiler flags for building against Lua,
916 -# for the given implementation. If no implementation is provided,
917 -# ${ELUA} will be used.
918 -#
919 -# Please note that this function requires Lua and pkg-config installed,
920 -# and therefore proper build-time dependencies need be added to the ebuild.
921 -lua_get_CFLAGS() {
922 - debug-print-function ${FUNCNAME} "${@}"
923 -
924 - _lua_export "${@}" LUA_CFLAGS
925 - echo "${LUA_CFLAGS}"
926 -}
927 -
928 -# @FUNCTION: lua_get_cmod_dir
929 -# @USAGE: [<impl>]
930 -# @DESCRIPTION:
931 -# Obtain and print the name of the directory into which compiled Lua
932 -# modules are installed, for the given implementation. If no implementation
933 -# is provided, ${ELUA} will be used.
934 -#
935 -# Please note that this function requires Lua and pkg-config installed,
936 -# and therefore proper build-time dependencies need be added to the ebuild.
937 -lua_get_cmod_dir() {
938 - debug-print-function ${FUNCNAME} "${@}"
939 -
940 - _lua_export "${@}" LUA_CMOD_DIR
941 - echo "${LUA_CMOD_DIR}"
942 -}
943 -
944 -# @FUNCTION: lua_get_LIBS
945 -# @USAGE: [<impl>]
946 -# @DESCRIPTION:
947 -# Obtain and print the compiler flags for linking against Lua,
948 -# for the given implementation. If no implementation is provided,
949 -# ${ELUA} will be used.
950 -#
951 -# Please note that this function requires Lua and pkg-config installed,
952 -# and therefore proper build-time dependencies need be added to the ebuild.
953 -lua_get_LIBS() {
954 - debug-print-function ${FUNCNAME} "${@}"
955 -
956 - _lua_export "${@}" LUA_LIBS
957 - echo "${LUA_LIBS}"
958 -}
959 -
960 -# @FUNCTION: lua_get_lmod_dir
961 -# @USAGE: [<impl>]
962 -# @DESCRIPTION:
963 -# Obtain and print the name of the directory into which native-Lua
964 -# modules are installed, for the given implementation. If no implementation
965 -# is provided, ${ELUA} will be used.
966 -#
967 -# Please note that this function requires Lua and pkg-config installed,
968 -# and therefore proper build-time dependencies need be added to the ebuild.
969 -lua_get_lmod_dir() {
970 - debug-print-function ${FUNCNAME} "${@}"
971 -
972 - _lua_export "${@}" LUA_LMOD_DIR
973 - echo "${LUA_LMOD_DIR}"
974 -}
975 -
976 -# @FUNCTION: lua_get_version
977 -# @USAGE: [<impl>]
978 -# @DESCRIPTION:
979 -# Obtain and print the full version number of the given Lua implementation.
980 -# If no implementation is provided, ${ELUA} will be used.
981 -#
982 -# Please note that this function requires Lua and pkg-config installed,
983 -# and therefore proper build-time dependencies need be added to the ebuild.
984 -lua_get_version() {
985 - debug-print-function ${FUNCNAME} "${@}"
986 -
987 - _lua_export "${@}" LUA_VERSION
988 - echo "${LUA_VERSION}"
989 -}
990 -
991 _LUA_R0=1
992 fi
993
994 -# @ECLASS-VARIABLE: _LUA_ALL_IMPLS
995 -# @INTERNAL
996 -# @DESCRIPTION:
997 -# All supported Lua implementations, most preferred last
998 -_LUA_ALL_IMPLS=(
999 - lua5-1
1000 - lua5-2
1001 - lua5-3
1002 - lua5-4
1003 -)
1004 -readonly _LUA_ALL_IMPLS
1005 -
1006 -# @FUNCTION: _lua_set_impls
1007 -# @INTERNAL
1008 -# @DESCRIPTION:
1009 -# Check LUA_COMPAT for well-formedness and validity, then set
1010 -# two global variables:
1011 -#
1012 -# - _LUA_SUPPORTED_IMPLS containing valid implementations supported
1013 -# by the ebuild (LUA_COMPAT minus dead implementations),
1014 -#
1015 -# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that
1016 -# are not supported by the ebuild.
1017 -#
1018 -# Implementations in both variables are ordered using the pre-defined
1019 -# eclass implementation ordering.
1020 -#
1021 -# This function must only be called once.
1022 -_lua_set_impls() {
1023 - local i
1024 -
1025 - if ! declare -p LUA_COMPAT &>/dev/null; then
1026 - die 'LUA_COMPAT not declared.'
1027 - fi
1028 - if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then
1029 - die 'LUA_COMPAT must be an array.'
1030 - fi
1031 -
1032 - local supp=() unsupp=()
1033 -
1034 - for i in "${_LUA_ALL_IMPLS[@]}"; do
1035 - if has "${i}" "${LUA_COMPAT[@]}"; then
1036 - supp+=( "${i}" )
1037 - else
1038 - unsupp+=( "${i}" )
1039 - fi
1040 - done
1041 -
1042 - if [[ ! ${supp[@]} ]]; then
1043 - die "No supported implementation in LUA_COMPAT."
1044 - fi
1045 -
1046 - if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then
1047 - # set once already, verify integrity
1048 - if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then
1049 - eerror "Supported impls (LUA_COMPAT) changed between inherits!"
1050 - eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}"
1051 - eerror "Now : ${supp[*]}"
1052 - die "_LUA_SUPPORTED_IMPLS integrity check failed"
1053 - fi
1054 - if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then
1055 - eerror "Unsupported impls changed between inherits!"
1056 - eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}"
1057 - eerror "Now : ${unsupp[*]}"
1058 - die "_LUA_UNSUPPORTED_IMPLS integrity check failed"
1059 - fi
1060 - else
1061 - _LUA_SUPPORTED_IMPLS=( "${supp[@]}" )
1062 - _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" )
1063 - readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS
1064 - fi
1065 -}
1066 -
1067 # @FUNCTION: _lua_set_globals
1068 # @INTERNAL
1069 # @DESCRIPTION:
1070 @@ -707,4 +374,4 @@ _lua_set_globals() {
1071 }
1072
1073 _lua_set_globals
1074 -unset -f _lua_set_globals _lua_set_impls
1075 +unset -f _lua_set_globals