summaryrefslogtreecommitdiff
path: root/eclass/llvm.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-05-30 11:44:06 +0100
committerV3n3RiX <venerix@redcorelinux.org>2020-05-30 11:44:06 +0100
commitf516638b7fe9592837389826a6152a7e1b251c54 (patch)
tree8bfecb640b7b6403d7a3d662d923eed630033da7 /eclass/llvm.eclass
parent1a61119f9f7b057830e2ce0563f913ec86f282ad (diff)
gentoo resync : 30.05.2020
Diffstat (limited to 'eclass/llvm.eclass')
-rw-r--r--eclass/llvm.eclass39
1 files changed, 26 insertions, 13 deletions
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass
index a2da231b035a..61b34d4985eb 100644
--- a/eclass/llvm.eclass
+++ b/eclass/llvm.eclass
@@ -71,6 +71,10 @@ EXPORT_FUNCTIONS pkg_setup
if [[ ! ${_LLVM_ECLASS} ]]; then
+# make sure that the versions installing straight into /usr/bin
+# are uninstalled
+DEPEND="!!sys-devel/llvm:0"
+
# @ECLASS-VARIABLE: LLVM_MAX_SLOT
# @DEFAULT_UNSET
# @DESCRIPTION:
@@ -173,13 +177,6 @@ get_llvm_prefix() {
die "${FUNCNAME}: invalid max_slot=${max_slot}"
fi
- # fallback to :0
- # assume it's always <= 4 (the lower max_slot allowed)
- if has_version ${hv_switch} "sys-devel/llvm:0"; then
- echo "${prefix}/usr"
- return
- fi
-
die "No LLVM slot${1:+ <= ${1}} found installed!"
}
@@ -201,13 +198,29 @@ llvm_pkg_setup() {
debug-print-function ${FUNCNAME} "${@}"
if [[ ${MERGE_TYPE} != binary ]]; then
- local llvm_prefix=$(get_llvm_prefix "${LLVM_MAX_SLOT}")
+ local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin
+ local IFS=:
+ local split_path=( ${PATH} )
+ local new_path=()
+ local x added=
+
+ # prepend new path before first LLVM version found
+ for x in "${split_path[@]}"; do
+ if [[ ${x} == */usr/lib/llvm/*/bin ]]; then
+ if [[ ${x} != ${llvm_path} ]]; then
+ new_path+=( "${llvm_path}" )
+ elif [[ ${added} && ${x} == ${llvm_path} ]]; then
+ # deduplicate
+ continue
+ fi
+ added=1
+ fi
+ new_path+=( "${x}" )
+ done
+ # ...or to the end of PATH
+ [[ ${added} ]] || new_path+=( "${llvm_path}" )
- # do not prepend /usr/bin, it's not necessary and breaks other
- # prepends, https://bugs.gentoo.org/622866
- if [[ ${llvm_prefix} != ${EPREFIX}/usr ]]; then
- export PATH=${llvm_prefix}/bin:${PATH}
- fi
+ export PATH=${new_path[*]}
fi
}