1 |
Add two switches to get_llvm_prefix(), '-b' and '-d' to enable use |
2 |
of LLVM API cross support. '-b' is intended to be used whenever prefix |
3 |
to CBUILD llvm-config is needed, and '-d' (the default) is intended |
4 |
to be used whenever prefix to CHOST bindir is needed (to find CMake |
5 |
modules). |
6 |
|
7 |
Signed-off-by: Michał Górny <mgorny@g.o> |
8 |
--- |
9 |
eclass/llvm.eclass | 51 ++++++++++++++++++++++++++++++++++++++++------ |
10 |
1 file changed, 45 insertions(+), 6 deletions(-) |
11 |
|
12 |
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass |
13 |
index e4052a6400c0..6f6e2939a17b 100644 |
14 |
--- a/eclass/llvm.eclass |
15 |
+++ b/eclass/llvm.eclass |
16 |
@@ -52,7 +52,7 @@ |
17 |
# DEPEND=${RDEPEND} |
18 |
# |
19 |
# llvm_check_deps() { |
20 |
-# has_version "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]" |
21 |
+# has_version -d "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]" |
22 |
# } |
23 |
# @CODE |
24 |
|
25 |
@@ -84,11 +84,19 @@ if [[ ! ${_LLVM_ECLASS} ]]; then |
26 |
declare -g -r _LLVM_KNOWN_SLOTS=( 9 8 7 6 5 4 ) |
27 |
|
28 |
# @FUNCTION: get_llvm_prefix |
29 |
-# @USAGE: [<max_slot>] |
30 |
+# @USAGE: [-b|-d] [<max_slot>] |
31 |
# @DESCRIPTION: |
32 |
# Find the newest LLVM install that is acceptable for the package, |
33 |
# and print an absolute path to it. |
34 |
# |
35 |
+# If -b is specified, the checks are performed relative to BROOT, |
36 |
+# and BROOT-path is returned. This is appropriate when your package |
37 |
+# calls llvm-config executable. -b is supported since EAPI 7. |
38 |
+# |
39 |
+# If -d is specified, the checks are performed relative to ESYSROOT, |
40 |
+# and ESYSROOT-path is returned. This is appropriate when your package |
41 |
+# uses CMake find_package(LLVM). -d is the default. |
42 |
+# |
43 |
# If <max_slot> is specified, then only LLVM versions that are not newer |
44 |
# than <max_slot> will be considered. Otherwise, all LLVM versions would |
45 |
# be considered acceptable. The function does not support specifying |
46 |
@@ -105,6 +113,37 @@ declare -g -r _LLVM_KNOWN_SLOTS=( 9 8 7 6 5 4 ) |
47 |
get_llvm_prefix() { |
48 |
debug-print-function ${FUNCNAME} "${@}" |
49 |
|
50 |
+ local hv_switch=-d |
51 |
+ while [[ ${1} == -* ]]; do |
52 |
+ case ${1} in |
53 |
+ -b|-d) hv_switch=${1};; |
54 |
+ *) break;; |
55 |
+ esac |
56 |
+ shift |
57 |
+ done |
58 |
+ |
59 |
+ local prefix= |
60 |
+ if [[ ${EAPI} != 6 ]]; then |
61 |
+ case ${hv_switch} in |
62 |
+ -b) |
63 |
+ prefix=${BROOT} |
64 |
+ ;; |
65 |
+ -d) |
66 |
+ prefix=${ESYSROOT} |
67 |
+ ;; |
68 |
+ esac |
69 |
+ else |
70 |
+ case ${hv_switch} in |
71 |
+ -b) |
72 |
+ die "${FUNCNAME} -b is not supported in EAPI ${EAPI}" |
73 |
+ ;; |
74 |
+ -d) |
75 |
+ prefix=${EPREFIX} |
76 |
+ hv_switch= |
77 |
+ ;; |
78 |
+ esac |
79 |
+ fi |
80 |
+ |
81 |
local max_slot=${1} |
82 |
local slot |
83 |
for slot in "${_LLVM_KNOWN_SLOTS[@]}"; do |
84 |
@@ -122,10 +161,10 @@ get_llvm_prefix() { |
85 |
llvm_check_deps || continue |
86 |
else |
87 |
# check if LLVM package is installed |
88 |
- has_version "sys-devel/llvm:${slot}" || continue |
89 |
+ has_version ${hv_switch} "sys-devel/llvm:${slot}" || continue |
90 |
fi |
91 |
|
92 |
- echo "${EPREFIX}/usr/lib/llvm/${slot}" |
93 |
+ echo "${prefix}/usr/lib/llvm/${slot}" |
94 |
return |
95 |
done |
96 |
|
97 |
@@ -136,8 +175,8 @@ get_llvm_prefix() { |
98 |
|
99 |
# fallback to :0 |
100 |
# assume it's always <= 4 (the lower max_slot allowed) |
101 |
- if has_version "sys-devel/llvm:0"; then |
102 |
- echo "${EPREFIX}/usr" |
103 |
+ if has_version ${hv_switch} "sys-devel/llvm:0"; then |
104 |
+ echo "${prefix}/usr" |
105 |
return |
106 |
fi |
107 |
|
108 |
-- |
109 |
2.21.0 |