Split the logic prepending PATH from pkg_setup() into a dedicated llvm_prepend_path() function.
Signed-off-by: Michał Górny <
mgorny@gentoo.org>
---
eclass/llvm-utils.eclass | 36 ++++++++++++++++++++++++++++++++++++
eclass/llvm.eclass | 25 +------------------------
eclass/tests/llvm-utils.sh | 24 ++++++++++++++++++++++++
3 files changed, 61 insertions(+), 24 deletions(-)
diff --git a/eclass/llvm-utils.eclass b/eclass/llvm-utils.eclass
index 43988f6f88c7..f308667e3dc2 100644
--- a/eclass/llvm-utils.eclass
+++ b/eclass/llvm-utils.eclass
@@ -112,4 +112,40 @@ llvm_fix_tool_path() {
${shopt_save}
}
+# @FUNCTION: llvm_prepend_path
+# @USAGE: <slot>
+# @DESCRIPTION:
+# Prepend the path to the specified LLVM slot to PATH variable,
+# and reexport it.
+llvm_prepend_path() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <slot>"
+ local slot=${1}
+
+ local llvm_path=${ESYSROOT}/usr/lib/llvm/${slot}/bin
+ local IFS=:
+ local split_path=( ${PATH} )
+ local new_path=()
+ local x added=
+
+ # prepend new path in front of the first LLVM version found
+ for x in "${split_pat