Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 12 Aug 2017 21:21:39
Message-Id: 1502572889.672d7885d6de8969dbc8df5b168a253afa68cbea.mgorny@gentoo
1 commit: 672d7885d6de8969dbc8df5b168a253afa68cbea
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 30 21:09:33 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Aug 12 21:21:29 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=672d7885
7
8 llvm.eclass: Support checking LLVM deps via llvm_check_deps()
9
10 Introduce the support for llvm_check_deps() function to override
11 the default LLVM slot acceptance test (checking whether sys-devel/llvm
12 is installed). This can be used to match more complex dependency
13 specifications, e.g. to find a LLVM slot that has a matching clang
14 version, or to request USE dependencies on LLVM or clang.
15
16 eclass/llvm.eclass | 60 ++++++++++++++++++++++++++++++++++++++++--------------
17 1 file changed, 45 insertions(+), 15 deletions(-)
18
19 diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass
20 index 4df3825e6e3..fc09a7d9598 100644
21 --- a/eclass/llvm.eclass
22 +++ b/eclass/llvm.eclass
23 @@ -37,6 +37,21 @@
24 # do-something-else
25 # }
26 # @CODE
27 +#
28 +# Example for a package needing LLVM+clang w/ a specific target:
29 +# @CODE
30 +# inherit cmake-utils llvm
31 +#
32 +# # note: do not use := on both clang and llvm, it can match different
33 +# # slots then. clang pulls llvm in, so we can skip the latter.
34 +# RDEPEND="
35 +# >=sys-devel/clang-4:=[llvm_targets_AMDGPU(+)]
36 +# "
37 +#
38 +# llvm_check_deps() {
39 +# has_version "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]"
40 +# }
41 +# @CODE
42
43 case "${EAPI:-0}" in
44 0|1|2|3|4|5)
45 @@ -68,14 +83,22 @@ declare -g -r _LLVM_KNOWN_SLOTS=( 6 5 4 )
46 # @FUNCTION: get_llvm_prefix
47 # @USAGE: [<max_slot>]
48 # @DESCRIPTION:
49 -# Prints the absolute path to an LLVM install prefix corresponding to
50 -# the newest installed version of LLVM that is not newer than
51 -# <max_slot>. If no <max_slot> is specified, there is no upper limit.
52 +# Find the newest LLVM install that is acceptable for the package,
53 +# and print an absolute path to it.
54 +#
55 +# If <max_slot> is specified, then only LLVM versions that are not newer
56 +# than <max_slot> will be considered. Otherwise, all LLVM versions would
57 +# be considered acceptable. The function does not support specifying
58 +# minimal supported version -- the developer must ensure that a version
59 +# new enough is installed via providing appropriate dependencies.
60 #
61 -# Note that the function does not support lower-bound version, so you
62 -# need to provide correct dependencies to ensure that a new enough
63 -# version will be always installed. Otherwise, the function could return
64 -# a version lower than required.
65 +# If llvm_check_deps() function is defined within the ebuild, it will
66 +# be called to verify whether a particular slot is accepable. Within
67 +# the function scope, LLVM_SLOT will be defined to the SLOT value
68 +# (0, 4, 5...). The function should return a true status if the slot
69 +# is acceptable, false otherwise. If llvm_check_deps() is not defined,
70 +# the function defaults to checking whether sys-devel/llvm:${LLVM_SLOT}
71 +# is installed.
72 get_llvm_prefix() {
73 debug-print-function ${FUNCNAME} "${@}"
74
75 @@ -91,11 +114,16 @@ get_llvm_prefix() {
76 fi
77 fi
78
79 - # check if LLVM package is installed
80 - if has_version "sys-devel/llvm:${slot}"; then
81 - echo "${EPREFIX}/usr/lib/llvm/${slot}"
82 - return
83 + if declare -f llvm_check_deps >/dev/null; then
84 + local LLVM_SLOT=${slot}
85 + llvm_check_deps || continue
86 + else
87 + # check if LLVM package is installed
88 + has_version "sys-devel/llvm:${slot}" || continue
89 fi
90 +
91 + echo "${EPREFIX}/usr/lib/llvm/${slot}"
92 + return
93 done
94
95 # max_slot should have been unset in the iteration
96 @@ -115,10 +143,12 @@ get_llvm_prefix() {
97
98 # @FUNCTION: llvm_pkg_setup
99 # @DESCRIPTION:
100 -# Prepend the executable directory corresponding to the newest
101 -# installed LLVM version that is not newer than ${LLVM_MAX_SLOT}
102 -# to PATH. If LLVM_MAX_SLOT is unset or empty, the newest installed
103 -# slot will be used.
104 +# Prepend the appropriate executable directory for the newest
105 +# acceptable LLVM slot to the PATH. For path determination logic,
106 +# please see the get_llvm_prefix documentation.
107 +#
108 +# The highest acceptable LLVM slot can be set in LLVM_MAX_SLOT variable.
109 +# If it is unset or empty, any slot is acceptable.
110 #
111 # The PATH manipulation is only done for source builds. The function
112 # is a no-op when installing a binary package.