summaryrefslogtreecommitdiff
path: root/eclass/llvm.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2019-06-02 21:45:28 +0100
committerV3n3RiX <venerix@redcorelinux.org>2019-06-02 21:45:28 +0100
commit2018227e9344edb9da15fc6a4a8298086cc2aa77 (patch)
treec18e1c09e605e94e2a1e93345ad25746cc9e14b9 /eclass/llvm.eclass
parent6f8038813c460b4f0572d5ef595cdfa94af3a94d (diff)
gentoo resync : 02.06.2019
Diffstat (limited to 'eclass/llvm.eclass')
-rw-r--r--eclass/llvm.eclass69
1 files changed, 55 insertions, 14 deletions
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass
index ca10e742f1b1..d61effb5e9c6 100644
--- a/eclass/llvm.eclass
+++ b/eclass/llvm.eclass
@@ -6,7 +6,7 @@
# Michał Górny <mgorny@gentoo.org>
# @AUTHOR:
# Michał Górny <mgorny@gentoo.org>
-# @SUPPORTED_EAPIS: 6
+# @SUPPORTED_EAPIS: 6 7
# @BLURB: Utility functions to build against slotted LLVM
# @DESCRIPTION:
# The llvm.eclass provides utility functions that can be used to build
@@ -17,20 +17,21 @@
# a proper dependency string yourself to guarantee that appropriate
# version of LLVM is installed.
#
-# Example use for a package supporting LLVM 3.8 to 5:
+# Example use for a package supporting LLVM 5 to 7:
# @CODE
# inherit cmake-utils llvm
#
# RDEPEND="
-# <sys-devel/llvm-6_rc:=
+# <sys-devel/llvm-8:=
# || (
+# sys-devel/llvm:7
+# sys-devel/llvm:6
# sys-devel/llvm:5
-# sys-devel/llvm:4
-# >=sys-devel/llvm-3.8:0
# )
# "
+# DEPEND=${RDEPEND}
#
-# LLVM_MAX_SLOT=5
+# LLVM_MAX_SLOT=7
#
# # only if you need to define one explicitly
# pkg_setup() {
@@ -46,11 +47,12 @@
# # note: do not use := on both clang and llvm, it can match different
# # slots then. clang pulls llvm in, so we can skip the latter.
# RDEPEND="
-# >=sys-devel/clang-4:=[llvm_targets_AMDGPU(+)]
+# >=sys-devel/clang-6:=[llvm_targets_AMDGPU(+)]
# "
+# DEPEND=${RDEPEND}
#
# llvm_check_deps() {
-# has_version "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]"
+# has_version -d "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]"
# }
# @CODE
@@ -58,7 +60,7 @@ case "${EAPI:-0}" in
0|1|2|3|4|5)
die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
;;
- 6)
+ 6|7)
;;
*)
die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
@@ -82,11 +84,19 @@ if [[ ! ${_LLVM_ECLASS} ]]; then
declare -g -r _LLVM_KNOWN_SLOTS=( 9 8 7 6 5 4 )
# @FUNCTION: get_llvm_prefix
-# @USAGE: [<max_slot>]
+# @USAGE: [-b|-d] [<max_slot>]
# @DESCRIPTION:
# Find the newest LLVM install that is acceptable for the package,
# and print an absolute path to it.
#
+# If -b is specified, the checks are performed relative to BROOT,
+# and BROOT-path is returned. This is appropriate when your package
+# calls llvm-config executable. -b is supported since EAPI 7.
+#
+# If -d is specified, the checks are performed relative to ESYSROOT,
+# and ESYSROOT-path is returned. This is appropriate when your package
+# uses CMake find_package(LLVM). -d is the default.
+#
# If <max_slot> is specified, then only LLVM versions that are not newer
# than <max_slot> will be considered. Otherwise, all LLVM versions would
# be considered acceptable. The function does not support specifying
@@ -103,6 +113,37 @@ declare -g -r _LLVM_KNOWN_SLOTS=( 9 8 7 6 5 4 )
get_llvm_prefix() {
debug-print-function ${FUNCNAME} "${@}"
+ local hv_switch=-d
+ while [[ ${1} == -* ]]; do
+ case ${1} in
+ -b|-d) hv_switch=${1};;
+ *) break;;
+ esac
+ shift
+ done
+
+ local prefix=
+ if [[ ${EAPI} != 6 ]]; then
+ case ${hv_switch} in
+ -b)
+ prefix=${BROOT}
+ ;;
+ -d)
+ prefix=${ESYSROOT}
+ ;;
+ esac
+ else
+ case ${hv_switch} in
+ -b)
+ die "${FUNCNAME} -b is not supported in EAPI ${EAPI}"
+ ;;
+ -d)
+ prefix=${EPREFIX}
+ hv_switch=
+ ;;
+ esac
+ fi
+
local max_slot=${1}
local slot
for slot in "${_LLVM_KNOWN_SLOTS[@]}"; do
@@ -120,10 +161,10 @@ get_llvm_prefix() {
llvm_check_deps || continue
else
# check if LLVM package is installed
- has_version "sys-devel/llvm:${slot}" || continue
+ has_version ${hv_switch} "sys-devel/llvm:${slot}" || continue
fi
- echo "${EPREFIX}/usr/lib/llvm/${slot}"
+ echo "${prefix}/usr/lib/llvm/${slot}"
return
done
@@ -134,8 +175,8 @@ get_llvm_prefix() {
# fallback to :0
# assume it's always <= 4 (the lower max_slot allowed)
- if has_version "sys-devel/llvm:0"; then
- echo "${EPREFIX}/usr"
+ if has_version ${hv_switch} "sys-devel/llvm:0"; then
+ echo "${prefix}/usr"
return
fi