aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory M. Tuner <gmt@be-evil.net>2013-12-29 23:14:00 -0800
committerGregory M. Tuner <gmt@be-evil.net>2013-12-29 23:14:00 -0800
commitb793b2bd9a5dc3ba3477fbfcbb00fe27fcb577f2 (patch)
tree2a01e59cc7d940f01af78f7f06b0fb75f193fa4a /eclass/multibuild.eclass
parenteclass/autotools-multilib: last-minute ehooking (diff)
downloadgmt-b793b2bd9a5dc3ba3477fbfcbb00fe27fcb577f2.tar.gz
gmt-b793b2bd9a5dc3ba3477fbfcbb00fe27fcb577f2.tar.bz2
gmt-b793b2bd9a5dc3ba3477fbfcbb00fe27fcb577f2.zip
eclass/multibuild: multibuild_is_best_variant -> multibuild_get_best_variant
It is trivial to deduce whether the current variant is the best one from an API that returns the name of the best one. However it is nontrivial to determine the name of the best variant from an API that returns whether or not the current variant is the best one. Therefore, it's better to have this API than the old one. This patch also ports multilib-build.eclass to use the new API instead of the old one. Finally, it re-implements multibuild_for_best_variant using the new API in lieu of its duplicate procedural logic, to compute precisely the same value. Signed-off-by: Gregory M. Tuner <gmt@be-evil.net>
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