commit: d393753de4be9164251344e887e97adfcc0f0bce
Author: Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 16 23:45:07 2024 +0000
Commit: Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Sun Dec 22 03:13:08 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d393753d
rust.eclass: be verbose when checking if a Rust is suitable
This commit enables the Rust eclass to provide feedback to users
on what it's actually doing and why a particular Rust was
(or was not) deemed suitable for use.
To do this we now:
- Explicitly note if a Rust slot was skipped due to LLVM_SLOT
incompatibility
- Provide a python-utils-r1 style `Checking whether Rust SLOT is
suitable ...` for each slot
- List each package (and usedep) that we are checking for
- Provide an error message that clearly explains the requirements
if no suitable package is available.
`_get_rust_slot` has been adjusted to export RUST_SLOT and RUST_TYPE
if a suitable slot is found.
Still TODO is enhancing output for `rust_check_deps` (perhaps
ebegin/eend?), however there don't appear to be any consumers
in the wild, this can probably wait a little longer.
Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>
eclass/rust.eclass | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/eclass/rust.eclass b/eclass/rust.eclass
index eb14ca2329b5..a7199f984af8 100644
--- a/eclass/rust.eclass
+++ b/eclass/rust.eclass
@@ -286,7 +286,8 @@ unset -f _rust_set_globals
# @USAGE: [-b|-d]
# @DESCRIPTION:
# Find the newest Rust install that is acceptable for the package,
-# and print its version number (i.e. SLOT) and type (source or bin[ary]).
+# and export its version (i.e. SLOT) and type (source or bin[ary])
+# as RUST_SLOT and RUST_TYPE.
#
# If -b is specified, the checks are performed relative to BROOT,
# and BROOT-path is returned. -b is the default.
@@ -363,10 +364,13 @@ _get_rust_slot() {
# If we're in LLVM mode we can skip any slots that don't match
the selected USE
if [[ -n "${RUST_NEEDS_LLVM}" ]]; then
if [[ "${llvm_slot}" != "${llvm_r1_slot}" ]]; then
+ einfo "Skipping Rust ${slot} as it does not
match llvm_slot_${llvm_r1_slot}"
continue
fi
fi
+ einfo "Checking whether Rust ${slot} is suitable ..."
+
if declare -f rust_check_deps >/dev/null; then
local RUST_SLOT="${slot}"
local LLVM_SLOT="${_RUST_LLVM_MAP[${slot}]}"
@@ -396,11 +400,13 @@ _get_rust_slot() {
esac
local _pkg
for _pkg in "${rust_pkgs[@]}"; do
+ einfo " Checking for ${_pkg} ..."
if has_version "${hv_switch}" "${_pkg}"; then
+ export RUST_SLOT="${slot}"
if [[ "${_pkg}" ==
"dev-lang/rust:${slot}${usedep}" ]]; then
- echo "${slot} source"
+ export RUST_TYPE="source"
else
- echo "${slot} binary"
+ export RUST_TYPE="binary"
fi
return
fi
@@ -418,7 +424,12 @@ _get_rust_slot() {
die "${FUNCNAME}: invalid max_slot=${max_slot}"
fi
- die "No Rust slot${1:+ <= ${1}} satisfying the package's dependencies
found installed!"
+ local requirement_msg=""
+ [[ -n "${RUST_MAX_VER}" ]] && requirement_msg+="<= ${RUST_MAX_VER} "
+ [[ -n "${RUST_MIN_VER}" ]] && requirement_msg+=">= ${RUST_MIN_VER} "
+ [[ -n "${RUST_REQ_USE}" ]] && requirement_msg+="with
USE=${RUST_REQ_USE}"
+ requirement_msg="${requirement_msg% }"
+ die "No Rust matching requirements${requirement_msg:+
(${requirement_msg})} found installed!"
}
# @FUNCTION: get_rust_path
@@ -500,7 +511,7 @@ rust_pkg_setup() {
debug-print-function ${FUNCNAME} "$@"
if [[ ${MERGE_TYPE} != binary ]]; then
- read -r RUST_SLOT RUST_TYPE <<< $(_get_rust_slot -b)
+ _get_rust_slot -b
rust_prepend_path "${RUST_SLOT}" "${RUST_TYPE}"
local prefix=$(get_rust_path "${BROOT}" "${RUST_SLOT}"
"${RUST_TYPE}")
CARGO="${prefix}bin/cargo"