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 (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 347CF15817D for ; Thu, 13 Jun 2024 15:05:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5F1F0E2AA4; Thu, 13 Jun 2024 15:05:48 +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)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F3C0DE2A9F for ; Thu, 13 Jun 2024 15:05:47 +0000 (UTC) From: James Le Cuirot To: gentoo-dev Cc: James Le Cuirot Subject: [gentoo-dev] [PATCH] cargo.eclass: Add cargo_target_dir helper function Date: Thu, 13 Jun 2024 16:03:44 +0100 Message-ID: <20240613150530.24679-1-chewi@gentoo.org> X-Mailer: git-send-email 2.45.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: cb5bd6b5-ac90-40be-bebd-55e119c23e61 X-Archives-Hash: 66a36d3d7a329bfa566217e192ec7f90 Several Cargo-based ebuilds cannot use cargo_src_install for various reasons and manually install binaries from within the target directory instead. It is common to see `target/$(usex debug debug release)`, but this lacks the target ABI when cross-compiling, so provide a helper function. There are some multilib Cargo-based ebuilds that always set the target ABI, even when not cross-compiling. It would be simpler to do this in general, so once ebuilds have been updated to use this new helper, I might change the eclass again accordingly. Signed-off-by: James Le Cuirot --- eclass/cargo.eclass | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 40d98211ce7f9..2036fb635d569 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -319,6 +319,16 @@ _cargo_gen_git_config() { fi } +# @FUNCTION: cargo_target_dir +# @DESCRIPTION: +# Return the directory within target that contains the build, e.g. +# target/aarch64-unknown-linux-gnu/release. +cargo_target_dir() { + local abi + tc-is-cross-compiler && abi=$(rust_abi) + echo "${CARGO_TARGET_DIR:-target}${abi+/}${abi}/$(usex debug debug release)" +} + # @FUNCTION: cargo_src_unpack # @DESCRIPTION: # Unpacks the package and the cargo registry. -- 2.45.1