1 |
These are the things that will be used by both lua and lua-single. |
2 |
|
3 |
Signed-off-by: Marek Szuba <marecki@g.o> |
4 |
--- |
5 |
eclass/lua-utils.eclass | 373 ++++++++++++++++++++++++++++++++++++++++ |
6 |
eclass/lua.eclass | 345 +------------------------------------ |
7 |
2 files changed, 379 insertions(+), 339 deletions(-) |
8 |
create mode 100644 eclass/lua-utils.eclass |
9 |
|
10 |
diff --git a/eclass/lua-utils.eclass b/eclass/lua-utils.eclass |
11 |
new file mode 100644 |
12 |
index 00000000000..490d19a0019 |
13 |
--- /dev/null |
14 |
+++ b/eclass/lua-utils.eclass |
15 |
@@ -0,0 +1,373 @@ |
16 |
+# Copyright 1999-2020 Gentoo Authors |
17 |
+# Distributed under the terms of the GNU General Public License v2 |
18 |
+ |
19 |
+# @ECLASS: lua-utils.eclass |
20 |
+# @MAINTAINER: |
21 |
+# William Hubbs <williamh@g.o> |
22 |
+# Marek Szuba <marecki@g.o> |
23 |
+# @AUTHOR: |
24 |
+# Marek Szuba <marecki@g.o> |
25 |
+# Based on python-utils-r1.eclass by Michał Górny <mgorny@g.o> et al. |
26 |
+# @SUPPORTED_EAPIS: 7 |
27 |
+# @BLURB: Utility functions for packages with Lua parts |
28 |
+# @DESCRIPTION: |
29 |
+# A utility eclass providing functions to query Lua implementations, |
30 |
+# install Lua modules and scripts. |
31 |
+# |
32 |
+# Please note that for the time being this eclass does NOT support luajit. |
33 |
+# |
34 |
+# This eclass neither sets any metadata variables nor exports any phase |
35 |
+# functions. It can be inherited safely. |
36 |
+ |
37 |
+case ${EAPI:-0} in |
38 |
+ 0|1|2|3|4|5|6) |
39 |
+ die "Unsupported EAPI=${EAPI} (too old) for ${ECLASS}" |
40 |
+ ;; |
41 |
+ 7) |
42 |
+ ;; |
43 |
+ *) |
44 |
+ die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" |
45 |
+ ;; |
46 |
+esac |
47 |
+ |
48 |
+if [[ ! ${_LUA_UTILS_R0} ]]; then |
49 |
+ |
50 |
+inherit toolchain-funcs |
51 |
+ |
52 |
+# @ECLASS-VARIABLE: _LUA_ALL_IMPLS |
53 |
+# @INTERNAL |
54 |
+# @DESCRIPTION: |
55 |
+# All supported Lua implementations, most preferred last |
56 |
+_LUA_ALL_IMPLS=( |
57 |
+ lua5-1 |
58 |
+ lua5-2 |
59 |
+ lua5-3 |
60 |
+ lua5-4 |
61 |
+) |
62 |
+readonly _LUA_ALL_IMPLS |
63 |
+ |
64 |
+# @FUNCTION: _lua_set_impls |
65 |
+# @INTERNAL |
66 |
+# @DESCRIPTION: |
67 |
+# Check LUA_COMPAT for well-formedness and validity, then set |
68 |
+# two global variables: |
69 |
+# |
70 |
+# - _LUA_SUPPORTED_IMPLS containing valid implementations supported |
71 |
+# by the ebuild (LUA_COMPAT minus dead implementations), |
72 |
+# |
73 |
+# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that |
74 |
+# are not supported by the ebuild. |
75 |
+# |
76 |
+# Implementations in both variables are ordered using the pre-defined |
77 |
+# eclass implementation ordering. |
78 |
+# |
79 |
+# This function must only be called once. |
80 |
+_lua_set_impls() { |
81 |
+ local i |
82 |
+ |
83 |
+ if ! declare -p LUA_COMPAT &>/dev/null; then |
84 |
+ die 'LUA_COMPAT not declared.' |
85 |
+ fi |
86 |
+ if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then |
87 |
+ die 'LUA_COMPAT must be an array.' |
88 |
+ fi |
89 |
+ |
90 |
+ local supp=() unsupp=() |
91 |
+ |
92 |
+ for i in "${_LUA_ALL_IMPLS[@]}"; do |
93 |
+ if has "${i}" "${LUA_COMPAT[@]}"; then |
94 |
+ supp+=( "${i}" ) |
95 |
+ else |
96 |
+ unsupp+=( "${i}" ) |
97 |
+ fi |
98 |
+ done |
99 |
+ |
100 |
+ if [[ ! ${supp[@]} ]]; then |
101 |
+ die "No supported implementation in LUA_COMPAT." |
102 |
+ fi |
103 |
+ |
104 |
+ if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then |
105 |
+ # set once already, verify integrity |
106 |
+ if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then |
107 |
+ eerror "Supported impls (LUA_COMPAT) changed between inherits!" |
108 |
+ eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}" |
109 |
+ eerror "Now : ${supp[*]}" |
110 |
+ die "_LUA_SUPPORTED_IMPLS integrity check failed" |
111 |
+ fi |
112 |
+ if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then |
113 |
+ eerror "Unsupported impls changed between inherits!" |
114 |
+ eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}" |
115 |
+ eerror "Now : ${unsupp[*]}" |
116 |
+ die "_LUA_UNSUPPORTED_IMPLS integrity check failed" |
117 |
+ fi |
118 |
+ else |
119 |
+ _LUA_SUPPORTED_IMPLS=( "${supp[@]}" ) |
120 |
+ _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" ) |
121 |
+ readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS |
122 |
+ fi |
123 |
+} |
124 |
+ |
125 |
+# @FUNCTION: _lua_wrapper_setup |
126 |
+# @USAGE: [<path> [<impl>]] |
127 |
+# @INTERNAL |
128 |
+# @DESCRIPTION: |
129 |
+# Create proper Lua executables and pkg-config wrappers |
130 |
+# (if available) in the directory named by <path>. Set up PATH |
131 |
+# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${ELUA}. |
132 |
+# |
133 |
+# The wrappers will be created for implementation named by <impl>, |
134 |
+# or for one named by ${ELUA} if no <impl> passed. |
135 |
+# |
136 |
+# If the named directory contains a lua symlink already, it will |
137 |
+# be assumed to contain proper wrappers already and only environment |
138 |
+# setup will be done. If wrapper update is requested, the directory |
139 |
+# shall be removed first. |
140 |
+_lua_wrapper_setup() { |
141 |
+ debug-print-function ${FUNCNAME} "${@}" |
142 |
+ |
143 |
+ local workdir=${1:-${T}/${ELUA}} |
144 |
+ local impl=${2:-${ELUA}} |
145 |
+ |
146 |
+ [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified." |
147 |
+ [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified." |
148 |
+ |
149 |
+ if [[ ! -x ${workdir}/bin/lua ]]; then |
150 |
+ mkdir -p "${workdir}"/{bin,pkgconfig} || die |
151 |
+ |
152 |
+ # Clean up, in case we were supposed to do a cheap update |
153 |
+ rm -f "${workdir}"/bin/lua{,c} || die |
154 |
+ rm -f "${workdir}"/pkgconfig/lua.pc || die |
155 |
+ |
156 |
+ local ELUA LUA |
157 |
+ _lua_export "${impl}" ELUA LUA |
158 |
+ |
159 |
+ # Lua interpreter and compiler |
160 |
+ ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die |
161 |
+ ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die |
162 |
+ |
163 |
+ # pkg-config |
164 |
+ ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ |
165 |
+ "${workdir}"/pkgconfig/lua.pc || die |
166 |
+ fi |
167 |
+ |
168 |
+ # Now, set the environment. |
169 |
+ # But note that ${workdir} may be shared with something else, |
170 |
+ # and thus already on top of PATH. |
171 |
+ if [[ ${PATH##:*} != ${workdir}/bin ]]; then |
172 |
+ PATH=${workdir}/bin${PATH:+:${PATH}} |
173 |
+ fi |
174 |
+ if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then |
175 |
+ PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} |
176 |
+ fi |
177 |
+ export PATH PKG_CONFIG_PATH |
178 |
+} |
179 |
+ |
180 |
+# @ECLASS-VARIABLE: ELUA |
181 |
+# @DEFAULT_UNSET |
182 |
+# @DESCRIPTION: |
183 |
+# The executable name of the current Lua interpreter. This variable is set |
184 |
+# automatically in functions called by lua_foreach_impl(). |
185 |
+# |
186 |
+# Example value: |
187 |
+# @CODE |
188 |
+# lua5.1 |
189 |
+# @CODE |
190 |
+ |
191 |
+# @ECLASS-VARIABLE: LUA |
192 |
+# @DEFAULT_UNSET |
193 |
+# @DESCRIPTION: |
194 |
+# The absolute path to the current Lua interpreter. This variable is set |
195 |
+# automatically in functions called by lua_foreach_impl(). |
196 |
+# |
197 |
+# Example value: |
198 |
+# @CODE |
199 |
+# /usr/bin/lua5.1 |
200 |
+# @CODE |
201 |
+ |
202 |
+# @FUNCTION: _lua_export |
203 |
+# @USAGE: [<impl>] <variables>... |
204 |
+# @INTERNAL |
205 |
+# @DESCRIPTION: |
206 |
+# Set and export the Lua implementation-relevant variables passed |
207 |
+# as parameters. |
208 |
+# |
209 |
+# The optional first parameter may specify the requested Lua |
210 |
+# implementation (either as LUA_TARGETS value, e.g. lua5-2, |
211 |
+# or an ELUA one, e.g. lua5.2). If no implementation passed, |
212 |
+# the current one will be obtained from ${ELUA}. |
213 |
+_lua_export() { |
214 |
+ debug-print-function ${FUNCNAME} "${@}" |
215 |
+ |
216 |
+ local impl var |
217 |
+ |
218 |
+ case "${1}" in |
219 |
+ lua*) |
220 |
+ impl=${1/-/.} |
221 |
+ shift |
222 |
+ ;; |
223 |
+ *) |
224 |
+ impl=${ELUA} |
225 |
+ if [[ -z ${impl} ]]; then |
226 |
+ die "_lua_export called without a Lua implementation and ELUA is unset" |
227 |
+ fi |
228 |
+ ;; |
229 |
+ esac |
230 |
+ debug-print "${FUNCNAME}: implementation: ${impl}" |
231 |
+ |
232 |
+ for var; do |
233 |
+ case "${var}" in |
234 |
+ ELUA) |
235 |
+ export ELUA=${impl} |
236 |
+ debug-print "${FUNCNAME}: ELUA = ${ELUA}" |
237 |
+ ;; |
238 |
+ LUA) |
239 |
+ export LUA="${EPREFIX}"/usr/bin/${impl} |
240 |
+ debug-print "${FUNCNAME}: LUA = ${LUA}" |
241 |
+ ;; |
242 |
+ LUA_CFLAGS) |
243 |
+ local val |
244 |
+ |
245 |
+ val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die |
246 |
+ |
247 |
+ export LUA_CFLAGS=${val} |
248 |
+ debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}" |
249 |
+ ;; |
250 |
+ LUA_CMOD_DIR) |
251 |
+ local val |
252 |
+ |
253 |
+ val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die |
254 |
+ |
255 |
+ export LUA_CMOD_DIR=${val} |
256 |
+ debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}" |
257 |
+ ;; |
258 |
+ LUA_LIBS) |
259 |
+ local val |
260 |
+ |
261 |
+ val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die |
262 |
+ |
263 |
+ export LUA_LIBS=${val} |
264 |
+ debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}" |
265 |
+ ;; |
266 |
+ LUA_LMOD_DIR) |
267 |
+ local val |
268 |
+ |
269 |
+ val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die |
270 |
+ |
271 |
+ export LUA_LMOD_DIR=${val} |
272 |
+ debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}" |
273 |
+ ;; |
274 |
+ LUA_PKG_DEP) |
275 |
+ local d |
276 |
+ case ${impl} in |
277 |
+ lua*) |
278 |
+ LUA_PKG_DEP="dev-lang/lua:${impl#lua}" |
279 |
+ ;; |
280 |
+ *) |
281 |
+ die "Invalid implementation: ${impl}" |
282 |
+ ;; |
283 |
+ esac |
284 |
+ |
285 |
+ # use-dep |
286 |
+ if [[ ${LUA_REQ_USE} ]]; then |
287 |
+ LUA_PKG_DEP+=[${LUA_REQ_USE}] |
288 |
+ fi |
289 |
+ |
290 |
+ export LUA_PKG_DEP |
291 |
+ debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}" |
292 |
+ ;; |
293 |
+ LUA_VERSION) |
294 |
+ local val |
295 |
+ |
296 |
+ val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die |
297 |
+ |
298 |
+ export LUA_VERSION=${val} |
299 |
+ debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}" |
300 |
+ ;; |
301 |
+ *) |
302 |
+ die "_lua_export: unknown variable ${var}" |
303 |
+ ;; |
304 |
+ esac |
305 |
+ done |
306 |
+} |
307 |
+ |
308 |
+# @FUNCTION: lua_get_CFLAGS |
309 |
+# @USAGE: [<impl>] |
310 |
+# @DESCRIPTION: |
311 |
+# Obtain and print the compiler flags for building against Lua, |
312 |
+# for the given implementation. If no implementation is provided, |
313 |
+# ${ELUA} will be used. |
314 |
+# |
315 |
+# Please note that this function requires Lua and pkg-config installed, |
316 |
+# and therefore proper build-time dependencies need be added to the ebuild. |
317 |
+lua_get_CFLAGS() { |
318 |
+ debug-print-function ${FUNCNAME} "${@}" |
319 |
+ |
320 |
+ _lua_export "${@}" LUA_CFLAGS |
321 |
+ echo "${LUA_CFLAGS}" |
322 |
+} |
323 |
+ |
324 |
+# @FUNCTION: lua_get_cmod_dir |
325 |
+# @USAGE: [<impl>] |
326 |
+# @DESCRIPTION: |
327 |
+# Obtain and print the name of the directory into which compiled Lua |
328 |
+# modules are installed, for the given implementation. If no implementation |
329 |
+# is provided, ${ELUA} will be used. |
330 |
+# |
331 |
+# Please note that this function requires Lua and pkg-config installed, |
332 |
+# and therefore proper build-time dependencies need be added to the ebuild. |
333 |
+lua_get_cmod_dir() { |
334 |
+ debug-print-function ${FUNCNAME} "${@}" |
335 |
+ |
336 |
+ _lua_export "${@}" LUA_CMOD_DIR |
337 |
+ echo "${LUA_CMOD_DIR}" |
338 |
+} |
339 |
+ |
340 |
+# @FUNCTION: lua_get_LIBS |
341 |
+# @USAGE: [<impl>] |
342 |
+# @DESCRIPTION: |
343 |
+# Obtain and print the compiler flags for linking against Lua, |
344 |
+# for the given implementation. If no implementation is provided, |
345 |
+# ${ELUA} will be used. |
346 |
+# |
347 |
+# Please note that this function requires Lua and pkg-config installed, |
348 |
+# and therefore proper build-time dependencies need be added to the ebuild. |
349 |
+lua_get_LIBS() { |
350 |
+ debug-print-function ${FUNCNAME} "${@}" |
351 |
+ |
352 |
+ _lua_export "${@}" LUA_LIBS |
353 |
+ echo "${LUA_LIBS}" |
354 |
+} |
355 |
+ |
356 |
+# @FUNCTION: lua_get_lmod_dir |
357 |
+# @USAGE: [<impl>] |
358 |
+# @DESCRIPTION: |
359 |
+# Obtain and print the name of the directory into which native-Lua |
360 |
+# modules are installed, for the given implementation. If no implementation |
361 |
+# is provided, ${ELUA} will be used. |
362 |
+# |
363 |
+# Please note that this function requires Lua and pkg-config installed, |
364 |
+# and therefore proper build-time dependencies need be added to the ebuild. |
365 |
+lua_get_lmod_dir() { |
366 |
+ debug-print-function ${FUNCNAME} "${@}" |
367 |
+ |
368 |
+ _lua_export "${@}" LUA_LMOD_DIR |
369 |
+ echo "${LUA_LMOD_DIR}" |
370 |
+} |
371 |
+ |
372 |
+# @FUNCTION: lua_get_version |
373 |
+# @USAGE: [<impl>] |
374 |
+# @DESCRIPTION: |
375 |
+# Obtain and print the full version number of the given Lua implementation. |
376 |
+# If no implementation is provided, ${ELUA} will be used. |
377 |
+# |
378 |
+# Please note that this function requires Lua and pkg-config installed, |
379 |
+# and therefore proper build-time dependencies need be added to the ebuild. |
380 |
+lua_get_version() { |
381 |
+ debug-print-function ${FUNCNAME} "${@}" |
382 |
+ |
383 |
+ _lua_export "${@}" LUA_VERSION |
384 |
+ echo "${LUA_VERSION}" |
385 |
+} |
386 |
+ |
387 |
+_LUA_UTILS_R0=1 |
388 |
+fi |
389 |
diff --git a/eclass/lua.eclass b/eclass/lua.eclass |
390 |
index 7dccba6980a..f4594872e58 100644 |
391 |
--- a/eclass/lua.eclass |
392 |
+++ b/eclass/lua.eclass |
393 |
@@ -7,7 +7,7 @@ |
394 |
# Marek Szuba <marecki@g.o> |
395 |
# @AUTHOR: |
396 |
# Marek Szuba <marecki@g.o> |
397 |
-# Based on python{,-utils}-r1.eclass by Michał Górny <mgorny@g.o> et al. |
398 |
+# Based on python-r1.eclass by Michał Górny <mgorny@g.o> et al. |
399 |
# @SUPPORTED_EAPIS: 7 |
400 |
# @BLURB: A common eclass for Lua packages |
401 |
# @DESCRIPTION: |
402 |
@@ -21,7 +21,9 @@ |
403 |
# package easily. It also provides methods to easily run a command for |
404 |
# each enabled Lua implementation and duplicate the sources for them. |
405 |
# |
406 |
-# Please note that for the time being this eclass does NOT support luajit. |
407 |
+# Note that since this eclass always inherits lua-utils as well, in ebuilds |
408 |
+# using the former there is no need to explicitly inherit the latter in order |
409 |
+# to use helper functions such as lua_get_CFLAGS. |
410 |
# |
411 |
# @EXAMPLE: |
412 |
# @CODE |
413 |
@@ -61,7 +63,7 @@ esac |
414 |
|
415 |
if [[ ! ${_LUA_R0} ]]; then |
416 |
|
417 |
-inherit multibuild toolchain-funcs |
418 |
+inherit multibuild lua-utils |
419 |
|
420 |
fi |
421 |
|
422 |
@@ -140,28 +142,6 @@ fi |
423 |
# ${WORKDIR}/foo-1.3-lua5-1 |
424 |
# @CODE |
425 |
|
426 |
-# @ECLASS-VARIABLE: ELUA |
427 |
-# @DEFAULT_UNSET |
428 |
-# @DESCRIPTION: |
429 |
-# The executable name of the current Lua interpreter. This variable is set |
430 |
-# automatically in functions called by lua_foreach_impl(). |
431 |
-# |
432 |
-# Example value: |
433 |
-# @CODE |
434 |
-# lua5.1 |
435 |
-# @CODE |
436 |
- |
437 |
-# @ECLASS-VARIABLE: LUA |
438 |
-# @DEFAULT_UNSET |
439 |
-# @DESCRIPTION: |
440 |
-# The absolute path to the current Lua interpreter. This variable is set |
441 |
-# automatically in functions called by lua_foreach_impl(). |
442 |
-# |
443 |
-# Example value: |
444 |
-# @CODE |
445 |
-# /usr/bin/lua5.1 |
446 |
-# @CODE |
447 |
- |
448 |
# @ECLASS-VARIABLE: LUA_DEPS |
449 |
# @OUTPUT_VARIABLE |
450 |
# @DESCRIPTION: |
451 |
@@ -219,112 +199,6 @@ fi |
452 |
|
453 |
if [[ ! ${_LUA_R0} ]]; then |
454 |
|
455 |
-# @FUNCTION: _lua_export |
456 |
-# @USAGE: [<impl>] <variables>... |
457 |
-# @INTERNAL |
458 |
-# @DESCRIPTION: |
459 |
-# Set and export the Lua implementation-relevant variables passed |
460 |
-# as parameters. |
461 |
-# |
462 |
-# The optional first parameter may specify the requested Lua |
463 |
-# implementation (either as LUA_TARGETS value, e.g. lua5-2, |
464 |
-# or an ELUA one, e.g. lua5.2). If no implementation passed, |
465 |
-# the current one will be obtained from ${ELUA}. |
466 |
-_lua_export() { |
467 |
- debug-print-function ${FUNCNAME} "${@}" |
468 |
- |
469 |
- local impl var |
470 |
- |
471 |
- case "${1}" in |
472 |
- lua*) |
473 |
- impl=${1/-/.} |
474 |
- shift |
475 |
- ;; |
476 |
- *) |
477 |
- impl=${ELUA} |
478 |
- if [[ -z ${impl} ]]; then |
479 |
- die "_lua_export called without a Lua implementation and ELUA is unset" |
480 |
- fi |
481 |
- ;; |
482 |
- esac |
483 |
- debug-print "${FUNCNAME}: implementation: ${impl}" |
484 |
- |
485 |
- for var; do |
486 |
- case "${var}" in |
487 |
- ELUA) |
488 |
- export ELUA=${impl} |
489 |
- debug-print "${FUNCNAME}: ELUA = ${ELUA}" |
490 |
- ;; |
491 |
- LUA) |
492 |
- export LUA="${EPREFIX}"/usr/bin/${impl} |
493 |
- debug-print "${FUNCNAME}: LUA = ${LUA}" |
494 |
- ;; |
495 |
- LUA_CFLAGS) |
496 |
- local val |
497 |
- |
498 |
- val=$($(tc-getPKG_CONFIG) --cflags ${impl}) || die |
499 |
- |
500 |
- export LUA_CFLAGS=${val} |
501 |
- debug-print "${FUNCNAME}: LUA_CFLAGS = ${LUA_CFLAGS}" |
502 |
- ;; |
503 |
- LUA_CMOD_DIR) |
504 |
- local val |
505 |
- |
506 |
- val=$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD ${impl}) || die |
507 |
- |
508 |
- export LUA_CMOD_DIR=${val} |
509 |
- debug-print "${FUNCNAME}: LUA_CMOD_DIR = ${LUA_CMOD_DIR}" |
510 |
- ;; |
511 |
- LUA_LIBS) |
512 |
- local val |
513 |
- |
514 |
- val=$($(tc-getPKG_CONFIG) --libs ${impl}) || die |
515 |
- |
516 |
- export LUA_LIBS=${val} |
517 |
- debug-print "${FUNCNAME}: LUA_LIBS = ${LUA_LIBS}" |
518 |
- ;; |
519 |
- LUA_LMOD_DIR) |
520 |
- local val |
521 |
- |
522 |
- val=$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD ${impl}) || die |
523 |
- |
524 |
- export LUA_LMOD_DIR=${val} |
525 |
- debug-print "${FUNCNAME}: LUA_LMOD_DIR = ${LUA_LMOD_DIR}" |
526 |
- ;; |
527 |
- LUA_PKG_DEP) |
528 |
- local d |
529 |
- case ${impl} in |
530 |
- lua*) |
531 |
- LUA_PKG_DEP="dev-lang/lua:${impl#lua}" |
532 |
- ;; |
533 |
- *) |
534 |
- die "Invalid implementation: ${impl}" |
535 |
- ;; |
536 |
- esac |
537 |
- |
538 |
- # use-dep |
539 |
- if [[ ${LUA_REQ_USE} ]]; then |
540 |
- LUA_PKG_DEP+=[${LUA_REQ_USE}] |
541 |
- fi |
542 |
- |
543 |
- export LUA_PKG_DEP |
544 |
- debug-print "${FUNCNAME}: LUA_PKG_DEP = ${LUA_PKG_DEP}" |
545 |
- ;; |
546 |
- LUA_VERSION) |
547 |
- local val |
548 |
- |
549 |
- val=$($(tc-getPKG_CONFIG) --modversion ${impl}) || die |
550 |
- |
551 |
- export LUA_VERSION=${val} |
552 |
- debug-print "${FUNCNAME}: LUA_VERSION = ${LUA_VERSION}" |
553 |
- ;; |
554 |
- *) |
555 |
- die "_lua_export: unknown variable ${var}" |
556 |
- ;; |
557 |
- esac |
558 |
- done |
559 |
-} |
560 |
- |
561 |
# @FUNCTION: _lua_validate_useflags |
562 |
# @INTERNAL |
563 |
# @DESCRIPTION: |
564 |
@@ -401,61 +275,6 @@ _lua_multibuild_wrapper() { |
565 |
"${@}" |
566 |
} |
567 |
|
568 |
-# @FUNCTION: _lua_wrapper_setup |
569 |
-# @USAGE: [<path> [<impl>]] |
570 |
-# @INTERNAL |
571 |
-# @DESCRIPTION: |
572 |
-# Create proper Lua executables and pkg-config wrappers |
573 |
-# (if available) in the directory named by <path>. Set up PATH |
574 |
-# and PKG_CONFIG_PATH appropriately. <path> defaults to ${T}/${ELUA}. |
575 |
-# |
576 |
-# The wrappers will be created for implementation named by <impl>, |
577 |
-# or for one named by ${ELUA} if no <impl> passed. |
578 |
-# |
579 |
-# If the named directory contains a lua symlink already, it will |
580 |
-# be assumed to contain proper wrappers already and only environment |
581 |
-# setup will be done. If wrapper update is requested, the directory |
582 |
-# shall be removed first. |
583 |
-_lua_wrapper_setup() { |
584 |
- debug-print-function ${FUNCNAME} "${@}" |
585 |
- |
586 |
- local workdir=${1:-${T}/${ELUA}} |
587 |
- local impl=${2:-${ELUA}} |
588 |
- |
589 |
- [[ ${workdir} ]] || die "${FUNCNAME}: no workdir specified." |
590 |
- [[ ${impl} ]] || die "${FUNCNAME}: no impl nor ELUA specified." |
591 |
- |
592 |
- if [[ ! -x ${workdir}/bin/lua ]]; then |
593 |
- mkdir -p "${workdir}"/{bin,pkgconfig} || die |
594 |
- |
595 |
- # Clean up, in case we were supposed to do a cheap update |
596 |
- rm -f "${workdir}"/bin/lua{,c} || die |
597 |
- rm -f "${workdir}"/pkgconfig/lua.pc || die |
598 |
- |
599 |
- local ELUA LUA |
600 |
- _lua_export "${impl}" ELUA LUA |
601 |
- |
602 |
- # Lua interpreter and compiler |
603 |
- ln -s "${EPREFIX}"/usr/bin/${ELUA} "${workdir}"/bin/lua || die |
604 |
- ln -s "${EPREFIX}"/usr/bin/${ELUA/a/ac} "${workdir}"/bin/luac || die |
605 |
- |
606 |
- # pkg-config |
607 |
- ln -s "${EPREFIX}"/usr/$(get_libdir)/pkgconfig/${ELUA}.pc \ |
608 |
- "${workdir}"/pkgconfig/lua.pc || die |
609 |
- fi |
610 |
- |
611 |
- # Now, set the environment. |
612 |
- # But note that ${workdir} may be shared with something else, |
613 |
- # and thus already on top of PATH. |
614 |
- if [[ ${PATH##:*} != ${workdir}/bin ]]; then |
615 |
- PATH=${workdir}/bin${PATH:+:${PATH}} |
616 |
- fi |
617 |
- if [[ ${PKG_CONFIG_PATH##:*} != ${workdir}/pkgconfig ]]; then |
618 |
- PKG_CONFIG_PATH=${workdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} |
619 |
- fi |
620 |
- export PATH PKG_CONFIG_PATH |
621 |
-} |
622 |
- |
623 |
# @FUNCTION: lua_copy_sources |
624 |
# @DESCRIPTION: |
625 |
# Create a single copy of the package sources for each enabled Lua |
626 |
@@ -495,161 +314,9 @@ lua_foreach_impl() { |
627 |
multibuild_foreach_variant _lua_multibuild_wrapper "${@}" |
628 |
} |
629 |
|
630 |
-# @FUNCTION: lua_get_CFLAGS |
631 |
-# @USAGE: [<impl>] |
632 |
-# @DESCRIPTION: |
633 |
-# Obtain and print the compiler flags for building against Lua, |
634 |
-# for the given implementation. If no implementation is provided, |
635 |
-# ${ELUA} will be used. |
636 |
-# |
637 |
-# Please note that this function requires Lua and pkg-config installed, |
638 |
-# and therefore proper build-time dependencies need be added to the ebuild. |
639 |
-lua_get_CFLAGS() { |
640 |
- debug-print-function ${FUNCNAME} "${@}" |
641 |
- |
642 |
- _lua_export "${@}" LUA_CFLAGS |
643 |
- echo "${LUA_CFLAGS}" |
644 |
-} |
645 |
- |
646 |
-# @FUNCTION: lua_get_cmod_dir |
647 |
-# @USAGE: [<impl>] |
648 |
-# @DESCRIPTION: |
649 |
-# Obtain and print the name of the directory into which compiled Lua |
650 |
-# modules are installed, for the given implementation. If no implementation |
651 |
-# is provided, ${ELUA} will be used. |
652 |
-# |
653 |
-# Please note that this function requires Lua and pkg-config installed, |
654 |
-# and therefore proper build-time dependencies need be added to the ebuild. |
655 |
-lua_get_cmod_dir() { |
656 |
- debug-print-function ${FUNCNAME} "${@}" |
657 |
- |
658 |
- _lua_export "${@}" LUA_CMOD_DIR |
659 |
- echo "${LUA_CMOD_DIR}" |
660 |
-} |
661 |
- |
662 |
-# @FUNCTION: lua_get_LIBS |
663 |
-# @USAGE: [<impl>] |
664 |
-# @DESCRIPTION: |
665 |
-# Obtain and print the compiler flags for linking against Lua, |
666 |
-# for the given implementation. If no implementation is provided, |
667 |
-# ${ELUA} will be used. |
668 |
-# |
669 |
-# Please note that this function requires Lua and pkg-config installed, |
670 |
-# and therefore proper build-time dependencies need be added to the ebuild. |
671 |
-lua_get_LIBS() { |
672 |
- debug-print-function ${FUNCNAME} "${@}" |
673 |
- |
674 |
- _lua_export "${@}" LUA_LIBS |
675 |
- echo "${LUA_LIBS}" |
676 |
-} |
677 |
- |
678 |
-# @FUNCTION: lua_get_lmod_dir |
679 |
-# @USAGE: [<impl>] |
680 |
-# @DESCRIPTION: |
681 |
-# Obtain and print the name of the directory into which native-Lua |
682 |
-# modules are installed, for the given implementation. If no implementation |
683 |
-# is provided, ${ELUA} will be used. |
684 |
-# |
685 |
-# Please note that this function requires Lua and pkg-config installed, |
686 |
-# and therefore proper build-time dependencies need be added to the ebuild. |
687 |
-lua_get_lmod_dir() { |
688 |
- debug-print-function ${FUNCNAME} "${@}" |
689 |
- |
690 |
- _lua_export "${@}" LUA_LMOD_DIR |
691 |
- echo "${LUA_LMOD_DIR}" |
692 |
-} |
693 |
- |
694 |
-# @FUNCTION: lua_get_version |
695 |
-# @USAGE: [<impl>] |
696 |
-# @DESCRIPTION: |
697 |
-# Obtain and print the full version number of the given Lua implementation. |
698 |
-# If no implementation is provided, ${ELUA} will be used. |
699 |
-# |
700 |
-# Please note that this function requires Lua and pkg-config installed, |
701 |
-# and therefore proper build-time dependencies need be added to the ebuild. |
702 |
-lua_get_version() { |
703 |
- debug-print-function ${FUNCNAME} "${@}" |
704 |
- |
705 |
- _lua_export "${@}" LUA_VERSION |
706 |
- echo "${LUA_VERSION}" |
707 |
-} |
708 |
- |
709 |
_LUA_R0=1 |
710 |
fi |
711 |
|
712 |
-# @ECLASS-VARIABLE: _LUA_ALL_IMPLS |
713 |
-# @INTERNAL |
714 |
-# @DESCRIPTION: |
715 |
-# All supported Lua implementations, most preferred last |
716 |
-_LUA_ALL_IMPLS=( |
717 |
- lua5-1 |
718 |
- lua5-2 |
719 |
- lua5-3 |
720 |
- lua5-4 |
721 |
-) |
722 |
-readonly _LUA_ALL_IMPLS |
723 |
- |
724 |
-# @FUNCTION: _lua_set_impls |
725 |
-# @INTERNAL |
726 |
-# @DESCRIPTION: |
727 |
-# Check LUA_COMPAT for well-formedness and validity, then set |
728 |
-# two global variables: |
729 |
-# |
730 |
-# - _LUA_SUPPORTED_IMPLS containing valid implementations supported |
731 |
-# by the ebuild (LUA_COMPAT minus dead implementations), |
732 |
-# |
733 |
-# - and _LUA_UNSUPPORTED_IMPLS containing valid implementations that |
734 |
-# are not supported by the ebuild. |
735 |
-# |
736 |
-# Implementations in both variables are ordered using the pre-defined |
737 |
-# eclass implementation ordering. |
738 |
-# |
739 |
-# This function must only be called once. |
740 |
-_lua_set_impls() { |
741 |
- local i |
742 |
- |
743 |
- if ! declare -p LUA_COMPAT &>/dev/null; then |
744 |
- die 'LUA_COMPAT not declared.' |
745 |
- fi |
746 |
- if [[ $(declare -p LUA_COMPAT) != "declare -a"* ]]; then |
747 |
- die 'LUA_COMPAT must be an array.' |
748 |
- fi |
749 |
- |
750 |
- local supp=() unsupp=() |
751 |
- |
752 |
- for i in "${_LUA_ALL_IMPLS[@]}"; do |
753 |
- if has "${i}" "${LUA_COMPAT[@]}"; then |
754 |
- supp+=( "${i}" ) |
755 |
- else |
756 |
- unsupp+=( "${i}" ) |
757 |
- fi |
758 |
- done |
759 |
- |
760 |
- if [[ ! ${supp[@]} ]]; then |
761 |
- die "No supported implementation in LUA_COMPAT." |
762 |
- fi |
763 |
- |
764 |
- if [[ ${_LUA_SUPPORTED_IMPLS[@]} ]]; then |
765 |
- # set once already, verify integrity |
766 |
- if [[ ${_LUA_SUPPORTED_IMPLS[@]} != ${supp[@]} ]]; then |
767 |
- eerror "Supported impls (LUA_COMPAT) changed between inherits!" |
768 |
- eerror "Before: ${_LUA_SUPPORTED_IMPLS[*]}" |
769 |
- eerror "Now : ${supp[*]}" |
770 |
- die "_LUA_SUPPORTED_IMPLS integrity check failed" |
771 |
- fi |
772 |
- if [[ ${_LUA_UNSUPPORTED_IMPLS[@]} != ${unsupp[@]} ]]; then |
773 |
- eerror "Unsupported impls changed between inherits!" |
774 |
- eerror "Before: ${_LUA_UNSUPPORTED_IMPLS[*]}" |
775 |
- eerror "Now : ${unsupp[*]}" |
776 |
- die "_LUA_UNSUPPORTED_IMPLS integrity check failed" |
777 |
- fi |
778 |
- else |
779 |
- _LUA_SUPPORTED_IMPLS=( "${supp[@]}" ) |
780 |
- _LUA_UNSUPPORTED_IMPLS=( "${unsupp[@]}" ) |
781 |
- readonly _LUA_SUPPORTED_IMPLS _LUA_UNSUPPORTED_IMPLS |
782 |
- fi |
783 |
-} |
784 |
- |
785 |
# @FUNCTION: _lua_set_globals |
786 |
# @INTERNAL |
787 |
# @DESCRIPTION: |
788 |
@@ -707,4 +374,4 @@ _lua_set_globals() { |
789 |
} |
790 |
|
791 |
_lua_set_globals |
792 |
-unset -f _lua_set_globals _lua_set_impls |
793 |
+unset -f _lua_set_globals |
794 |
-- |
795 |
2.26.2 |