From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 21A161584AD for ; Sat, 19 Apr 2025 01:31:59 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (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) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 1009E343087 for ; Sat, 19 Apr 2025 01:31:59 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 390901104C3; Sat, 19 Apr 2025 01:31:11 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 bobolink.gentoo.org (Postfix) with ESMTPS id 2E4D51104C3 for ; Sat, 19 Apr 2025 01:31:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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 smtp.gentoo.org (Postfix) with ESMTPS id D9ABC343023 for ; Sat, 19 Apr 2025 01:31:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0C5FF19F6 for ; Sat, 19 Apr 2025 01:31:09 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1745026231.e7aa0ac74a17f3b404103a42cfd24525c1e9cc2f.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/cargo.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: e7aa0ac74a17f3b404103a42cfd24525c1e9cc2f X-VCS-Branch: master Date: Sat, 19 Apr 2025 01:31:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d00c1f40-be6a-4d3f-85aa-598e0b21bd82 X-Archives-Hash: 4f0c2a3f10dc0fc74f228db52ea33460 commit: e7aa0ac74a17f3b404103a42cfd24525c1e9cc2f Author: Christopher Fore posteo net> AuthorDate: Sun Apr 13 00:53:49 2025 +0000 Commit: Sam James gentoo org> CommitDate: Sat Apr 19 01:30:31 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e7aa0ac7 cargo.eclass: Pull check for rust_pkg_setup into its own function This reduces repetitiveness and allows for easier maintainability in the future. Bug: https://bugs.gentoo.org/953515 Bug: https://bugs.gentoo.org/953532 Signed-off-by: Christopher Fore posteo.net> Signed-off-by: Sam James gentoo.org> eclass/cargo.eclass | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index d93ae1723470..ad15da2b51a9 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -245,6 +245,16 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @DESCRIPTION: # List of URIs to put in SRC_URI created from CRATES variable. +# @FUNCTION: _cargo_check_initialized +# @INTERNAL +# @DESCRIPTION: +# Checks if rust_pkg_setup has been run. +_cargo_check_initialized() { + if [[ -z "${CARGO}" ]]; then + die "CARGO is not set; was rust_pkg_setup run?" + fi +} + # @FUNCTION: _cargo_set_crate_uris # @USAGE: # @DESCRIPTION: @@ -468,9 +478,7 @@ cargo_target_dir() { cargo_update_crates () { debug-print-function ${FUNCNAME} "$@" - if [[ -z ${CARGO} ]]; then - die "CARGO is not set; was rust_pkg_setup run?" - fi + _cargo_check_initialized local path=${1:-"${S}/Cargo.toml"} if [[ $# -gt 1 ]]; then @@ -778,9 +786,7 @@ cargo_env() { cargo_src_compile() { debug-print-function ${FUNCNAME} "$@" - if [[ -z "${CARGO}" ]]; then - die "CARGO is not set; was rust_pkg_setup run?" - fi + _cargo_check_initialized set -- "${CARGO}" build $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}" @@ -796,9 +802,7 @@ cargo_src_compile() { cargo_src_install() { debug-print-function ${FUNCNAME} "$@" - if [[ -z "${CARGO}" ]]; then - die "CARGO is not set; was rust_pkg_setup run?" - fi + _cargo_check_initialized set -- "${CARGO}" install $(has --path ${@} || echo --path ./) \ --root "${ED}/usr" \ @@ -818,9 +822,7 @@ cargo_src_install() { cargo_src_test() { debug-print-function ${FUNCNAME} "$@" - if [[ -z "${CARGO}" ]]; then - die "CARGO is not set; was rust_pkg_setup run?" - fi + _cargo_check_initialized set -- "${CARGO}" test $(usex debug "" --release) ${ECARGO_ARGS[@]} "$@" einfo "${@}"