* [gentoo-dev] [PATCH] rust.eclass: be verbose when checking if a Rust is suitable
@ 2024-12-17 0:17 kangie
2024-12-22 0:45 ` Sam James
0 siblings, 1 reply; 2+ messages in thread
From: kangie @ 2024-12-17 0:17 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Jolly
From: Matt Jolly <kangie@gentoo.org>
This commit addresses some feedback that the Rust eclass should 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@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"
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-dev] [PATCH] rust.eclass: be verbose when checking if a Rust is suitable
2024-12-17 0:17 [gentoo-dev] [PATCH] rust.eclass: be verbose when checking if a Rust is suitable kangie
@ 2024-12-22 0:45 ` Sam James
0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2024-12-22 0:45 UTC (permalink / raw
To: kangie; +Cc: gentoo-dev
kangie@gentoo.org writes:
> From: Matt Jolly <kangie@gentoo.org>
>
> This commit addresses some feedback that the Rust eclass should 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.
LGTM, thanks for doing this.
>
> Signed-off-by: Matt Jolly <kangie@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"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-22 0:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 0:17 [gentoo-dev] [PATCH] rust.eclass: be verbose when checking if a Rust is suitable kangie
2024-12-22 0:45 ` Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox