1 |
Set LLVM_SLOT in pkg_setup() to the selected LLVM slot, for inspection |
2 |
from the package. For example, it can be used to easily compare |
3 |
the version number. |
4 |
|
5 |
Split get_llvm_slot() out of get_llvm_prefix() to factor out the common |
6 |
code. |
7 |
|
8 |
Signed-off-by: Michał Górny <mgorny@g.o> |
9 |
--- |
10 |
eclass/llvm.eclass | 53 ++++++++++++++++++++++++++++++---------------- |
11 |
1 file changed, 35 insertions(+), 18 deletions(-) |
12 |
|
13 |
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass |
14 |
index 16596ec2ea66..92c05c308f91 100644 |
15 |
--- a/eclass/llvm.eclass |
16 |
+++ b/eclass/llvm.eclass |
17 |
@@ -87,11 +87,10 @@ DEPEND="!!sys-devel/llvm:0" |
18 |
# Correct values of LLVM slots, newest first. |
19 |
declare -g -r _LLVM_KNOWN_SLOTS=( {16..8} ) |
20 |
|
21 |
-# @FUNCTION: get_llvm_prefix |
22 |
+# @FUNCTION: get_llvm_slot |
23 |
# @USAGE: [-b|-d] [<max_slot>] |
24 |
-# @DESCRIPTION: |
25 |
# Find the newest LLVM install that is acceptable for the package, |
26 |
-# and print an absolute path to it. |
27 |
+# and print its major version number (i.e. slot). |
28 |
# |
29 |
# If -b is specified, the checks are performed relative to BROOT, |
30 |
# and BROOT-path is returned. This is appropriate when your package |
31 |
@@ -114,7 +113,7 @@ declare -g -r _LLVM_KNOWN_SLOTS=( {16..8} ) |
32 |
# is acceptable, false otherwise. If llvm_check_deps() is not defined, |
33 |
# the function defaults to checking whether sys-devel/llvm:${LLVM_SLOT} |
34 |
# is installed. |
35 |
-get_llvm_prefix() { |
36 |
+get_llvm_slot() { |
37 |
debug-print-function ${FUNCNAME} "${@}" |
38 |
|
39 |
local hv_switch=-d |
40 |
@@ -126,23 +125,12 @@ get_llvm_prefix() { |
41 |
shift |
42 |
done |
43 |
|
44 |
- local prefix= |
45 |
- if [[ ${EAPI} != 6 ]]; then |
46 |
- case ${hv_switch} in |
47 |
- -b) |
48 |
- prefix=${BROOT} |
49 |
- ;; |
50 |
- -d) |
51 |
- prefix=${ESYSROOT} |
52 |
- ;; |
53 |
- esac |
54 |
- else |
55 |
+ if [[ ${EAPI} == 6 ]]; then |
56 |
case ${hv_switch} in |
57 |
-b) |
58 |
die "${FUNCNAME} -b is not supported in EAPI ${EAPI}" |
59 |
;; |
60 |
-d) |
61 |
- prefix=${EPREFIX} |
62 |
hv_switch= |
63 |
;; |
64 |
esac |
65 |
@@ -168,7 +156,7 @@ get_llvm_prefix() { |
66 |
has_version ${hv_switch} "sys-devel/llvm:${slot}" || continue |
67 |
fi |
68 |
|
69 |
- echo "${prefix}/usr/lib/llvm/${slot}" |
70 |
+ echo "${slot}" |
71 |
return |
72 |
done |
73 |
|
74 |
@@ -180,6 +168,31 @@ get_llvm_prefix() { |
75 |
die "No LLVM slot${1:+ <= ${1}} satisfying the package's dependencies found installed!" |
76 |
} |
77 |
|
78 |
+# @FUNCTION: get_llvm_prefix |
79 |
+# @USAGE: [-b|-d] [<max_slot>] |
80 |
+# @DESCRIPTION: |
81 |
+# Find the newest LLVM install that is acceptable for the package, |
82 |
+# and print an absolute path to it. |
83 |
+# |
84 |
+# The options and behavior is the same as for get_llvm_slot. |
85 |
+get_llvm_prefix() { |
86 |
+ debug-print-function ${FUNCNAME} "${@}" |
87 |
+ |
88 |
+ local prefix=${EPREFIX} |
89 |
+ if [[ ${EAPI} != 6 ]]; then |
90 |
+ case ${1} in |
91 |
+ -b) |
92 |
+ prefix=${BROOT} |
93 |
+ ;; |
94 |
+ *) |
95 |
+ prefix=${ESYSROOT} |
96 |
+ ;; |
97 |
+ esac |
98 |
+ fi |
99 |
+ |
100 |
+ echo "${prefix}/usr/lib/llvm/$(get_llvm_slot "${@}")" |
101 |
+} |
102 |
+ |
103 |
# @FUNCTION: llvm_fix_clang_version |
104 |
# @USAGE: <variable-name>... |
105 |
# @DESCRIPTION: |
106 |
@@ -256,12 +269,16 @@ llvm_pkg_setup() { |
107 |
debug-print-function ${FUNCNAME} "${@}" |
108 |
|
109 |
if [[ ${MERGE_TYPE} != binary ]]; then |
110 |
+ LLVM_SLOT=$(get_llvm_slot "${LLVM_MAX_SLOT}") |
111 |
+ |
112 |
llvm_fix_clang_version CC CPP CXX |
113 |
# keep in sync with profiles/features/llvm/make.defaults! |
114 |
llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB |
115 |
llvm_fix_tool_path READELF STRINGS STRIP |
116 |
|
117 |
- local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin |
118 |
+ local prefix=${EPREFIX} |
119 |
+ [[ ${EAPI} != 6 ]] && prefix=${ESYSROOT} |
120 |
+ local llvm_path=${prefix}/usr/lib/llvm/${LLVM_SLOT}/bin |
121 |
local IFS=: |
122 |
local split_path=( ${PATH} ) |
123 |
local new_path=() |
124 |
-- |
125 |
2.38.1 |