aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'eclass/multibuild.eclass')
-rw-r--r--eclass/multibuild.eclass30
1 files changed, 14 insertions, 16 deletions
diff --git a/eclass/multibuild.eclass b/eclass/multibuild.eclass
index 382d51d..249814a 100644
--- a/eclass/multibuild.eclass
+++ b/eclass/multibuild.eclass
@@ -194,32 +194,30 @@ multibuild_for_best_variant() {
|| die "MULTIBUILD_VARIANTS need to be set"
# bash-4.1 can't handle negative subscripts
- local MULTIBUILD_VARIANTS=(
- "${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}"
- )
+ local MULTIBUILD_VARIANTS=("$(multibuild_get_best_variant)")
multibuild_foreach_variant "${@}"
}
-# @FUNCTION: multibuild_is_best_variant
+# @FUNCTION: multibuild_get_best_variant
# @DESCRIPTION:
-# Sometimes, while iterating through multibuild variants, we might
-# want to conditionalize some code on whether or not the current
-# variant is the "best" variant, without explicitly needing to
-# invoke multibuild_for_best_variant.
+# Sometimes, we want to know what the best variant is according to
+# multibuild (answer: it's always the last one on the list).
#
-# Returns zero if and only if the current variant is the same as
-# would be activated by multibuild_for_best_variant.
-multibuild_is_best_variant() {
+# This performs some sanity checking and returns it on the standard
+# output -- otherwise, folks would have to know the ordering
+# implementation detail or use multibuild_for_best_variant which is
+# a rather wasteful, and even potentially incorrect way to get the
+# information.
+#
+# This may only be used if ${MULTIBUILD_VARIANTS} has been set.
+# otherwise we die(), lest someone miss an error in a subshell.
+multibuild_get_best_variant() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
[[ ${MULTIBUILD_VARIANTS} ]] \
|| die "MULTIBUILD_VARIANTS must be set"
- [[ ${MULTIBUILD_VARIANT} ]] \
- || die "MULTIBUILD_VARIANT must be set"
-
- local best_variant="${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}"
- [[ ${MULTIBUILD_VARIANT} == ${best_variant} ]]
+ echo "${MULTIBUILD_VARIANTS[$(( ${#MULTIBUILD_VARIANTS[@]} - 1 ))]}"
}
# @FUNCTION: multibuild_copy_sources