llvm.eclass: Check for installed package rather than executable
authorMichał Górny <mgorny@gentoo.org>
Fri, 30 Jun 2017 15:08:50 +0000 (17:08 +0200)
committerMichał Górny <mgorny@gentoo.org>
Sat, 12 Aug 2017 21:21:28 +0000 (23:21 +0200)
Ensure that a specific LLVM slot is installed via using has_version on
"sys-devel/llvm:${SLOT}" rather than checking whether llvm-config is
installed in expected location. While it is a bit slower, this is closer
to a canonical way of testing it and will be useful when we allow
testing for more specific dependency strings. Right now, it could be
helpful if one has broken LLVM installation (i.e. stray files).

eclass/llvm.eclass

index 1128615cd35a14d2861a3ac4f36ce298a81fa6b1..4df3825e6e314a5b84cc130ce83904896d8d80d4 100644 (file)
@@ -91,9 +91,9 @@ get_llvm_prefix() {
                        fi
                fi
 
-               local p=${EPREFIX}/usr/lib/llvm/${slot}
-               if [[ -x ${p}/bin/llvm-config ]]; then
-                       echo "${p}"
+               # check if LLVM package is installed
+               if has_version "sys-devel/llvm:${slot}"; then
+                       echo "${EPREFIX}/usr/lib/llvm/${slot}"
                        return
                fi
        done
@@ -105,13 +105,12 @@ get_llvm_prefix() {
 
        # fallback to :0
        # assume it's always <= 4 (the lower max_slot allowed)
-       p=${EPREFIX}/usr
-       if [[ -x ${p}/bin/llvm-config ]]; then
-               echo "${p}"
+       if has_version "sys-devel/llvm:0"; then
+               echo "${EPREFIX}/usr"
                return
        fi
 
-       die "No LLVM slot${1:+ <= ${1}} found in PATH!"
+       die "No LLVM slot${1:+ <= ${1}} found installed!"
 }
 
 # @FUNCTION: llvm_pkg_setup