From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CE66215802C for ; Tue, 17 Dec 2024 00:18:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AD254E080E; Tue, 17 Dec 2024 00:18:48 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 39A3CE07A9 for ; Tue, 17 Dec 2024 00:18:47 +0000 (UTC) From: kangie@gentoo.org To: gentoo-dev@lists.gentoo.org Cc: Matt Jolly Subject: [gentoo-dev] [PATCH] rust.eclass: be verbose when checking if a Rust is suitable Date: Tue, 17 Dec 2024 10:17:44 +1000 Message-ID: <20241217001743.1635123-2-kangie@gentoo.org> X-Mailer: git-send-email 2.47.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 7820559a-962b-40f3-9133-4d8e4534262d X-Archives-Hash: 90c9ead572e3c6c924df4490e17661f6 From: Matt Jolly 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 --- 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