commit: a6623741bbd2f45976d9445d3c28acf26113f8e5
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 4 13:44:03 2014 +0000
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
CommitDate: Sun May 24 16:32:40 2015 +0000
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=a6623741
multibuild.eclass: supporting introspecting all layers of nested multibuild
Transform MULTIBUILD_VARIANT, MULTIBUILD_ID and BUILD_DIR into arrays
preserving values for each nested multibuild layer. For example, if you
do something like:
MULTIBUILD_VARIANTS=( a b c )
multibuild_foreach_variant multilib_foreach_abi python_foreach_impl ..
then the function called last would have:
MULTIBUILD_VARIANT=( python2.7 abi_x86_64.amd64 a )
MULTIBUILD_ID=( a-abi_x86_64.amd64-python2.7 a-abi_x86_64.amd64 a )
and BUILD_DIR alike it. Which means that using ${MULTIBUILD_VARIANT[2]}
you can get your initial 'a' without having to copy intermediate values.
Of course, if you want to nest multibuild you still need to ensure to
set proper MULTIBUILD_VARIANTS in the scope of multibuild_foreach*
invocation.
And before you start to worry, this is fully backwards-compatible.
In bash, ${MULTIBUILD_VARIANT} is equivalent to ${MULTIBUILD_VARIANT[0]}
in context of an array, and since index 0 stores deepmost value ---
nothing changes :).
Fixes: https://bugs.gentoo.org/show_bug.cgi?id=483758
eclass/multibuild.eclass | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass
index d9a86e9..a236894 100644
--- a/eclass/multibuild.eclass
+++ b/eclass/multibuild.eclass
@@ -46,6 +46,10 @@ if [[ ! ${_MULTIBUILD} ]]; then
# @DESCRIPTION:
# The current variant which the function was executed for.
#
+# If nested multibuilds are used, this value can be an array. In that
+# case, the first element will name the deepest multibuild, and the next
+# elements will go outwards.
+#
# Example value:
# @CODE
# python2_6
@@ -59,6 +63,10 @@ if [[ ! ${_MULTIBUILD} ]]; then
#
# It can be used to create variant-unique directories and files.
#
+# If nested multibuilds are used, this value can be an array. In that
+# case, the first element will name the deepest multibuild, and the next
+# elements will go outwards.
+#
# Example value:
# @CODE
# amd64-double
@@ -73,6 +81,10 @@ if [[ ! ${_MULTIBUILD} ]]; then
# to variant-specific build directories based on the initial value
# of BUILD_DIR.
#
+# If nested multibuilds are used, this value can be an array. In that
+# case, the first element will name the deepest multibuild, and the next
+# elements will go outwards.
+#
# Example value:
# @CODE
# ${WORKDIR}/foo-1.3-python2_6
@@ -108,9 +120,9 @@ multibuild_foreach_variant() {
debug-print "${FUNCNAME}: initial build_dir = ${bdir}"
for v in "${MULTIBUILD_VARIANTS[@]}"; do
- local MULTIBUILD_VARIANT=${v}
- local MULTIBUILD_ID=${prev_id}${v}
- local BUILD_DIR=${bdir%%/}-${v}
+ local MULTIBUILD_VARIANT=( "${v}" "${MULTIBUILD_VARIANT[@]}" )
+ local MULTIBUILD_ID=( "${prev_id}${v}" "${MULTIBUILD_ID[@]}" )
+ local BUILD_DIR=( "${bdir%%/}-${v}" "${BUILD_DIR[@]}" )
_multibuild_run() {
# find the first non-private command