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 3350415800A for ; Tue, 22 Aug 2023 18:04:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6AA922BC01D; Tue, 22 Aug 2023 18:04:10 +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 4ACF22BC01D for ; Tue, 22 Aug 2023 18:04:10 +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 443703412A1 for ; Tue, 22 Aug 2023 18:04:09 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A1B271045 for ; Tue, 22 Aug 2023 18:04:07 +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: <1692727416.00ee14eab35e0dad294da8efe1c9f6606c3e4794.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/crossdev.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 00ee14eab35e0dad294da8efe1c9f6606c3e4794 X-VCS-Branch: master Date: Tue, 22 Aug 2023 18:04:07 +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: dd6ceac8-1014-4bff-94b1-51a8788cc71d X-Archives-Hash: 27e33851ca3cdec4054586e94255db2d commit: 00ee14eab35e0dad294da8efe1c9f6606c3e4794 Author: Alfred Persson Forsberg catcream org> AuthorDate: Tue Aug 1 22:14:15 2023 +0000 Commit: Sam James gentoo org> CommitDate: Tue Aug 22 18:03:36 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=00ee14ea crossdev.eclass: new eclass This eclass includes convenience wrappers for use in ebuilds used by the Crossdev tool. Mostly to avoid duplicating code for checking category and setting CTARGET in ebuilds. Signed-off-by: Alfred Persson Forsberg catcream.org> Signed-off-by: Sam James gentoo.org> eclass/crossdev.eclass | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/eclass/crossdev.eclass b/eclass/crossdev.eclass new file mode 100644 index 000000000000..d6c99e4f32b7 --- /dev/null +++ b/eclass/crossdev.eclass @@ -0,0 +1,77 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: crossdev.eclass +# @MAINTAINER: +# cat@catcream.org +# @AUTHOR: +# Alfred Persson Forsberg (21 Jul 2023) +# @SUPPORTED_EAPIS: 7 8 +# @BLURB: Convenience wrappers for packages used by the Crossdev tool. + +inherit toolchain-funcs + +case ${EAPI} in + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ -z ${_CROSSDEV_ECLASS} ]]; then +_CROSSDEV_ECLASS=1 + +# @ECLASS_VARIABLE: _CROSS_CATEGORY_PREFIX +# @INTERNAL +# @DESCRIPTION: +# This variable specifies the category prefix for a Crossdev +# package. For GCC Crossdev it is "cross-", and for LLVM it is +# "cross_llvm-" +_CROSS_CATEGORY_PREFIX="" + +# @ECLASS_VARIABLE: _IS_CROSSPKG_LLVM +# @INTERNAL +# @DESCRIPTION: +# Is true if the package is in a LLVM Crossdev category, otherwise false +_IS_CROSSPKG_LLVM=0 +if [[ ${CATEGORY} == cross_llvm-* ]] ; then + _IS_CROSSPKG_LLVM=1 + _CROSS_CATEGORY_PREFIX="cross_llvm-" +fi + +# @ECLASS_VARIABLE: _IS_CROSSPKG_GCC +# @INTERNAL +# @DESCRIPTION: +# Is true if the package is in a GCC Crossdev category, otherwise false +_IS_CROSSPKG_GCC=0 +if [[ ${CATEGORY} == cross-* ]] ; then + _IS_CROSSPKG_GCC=1 + _CROSS_CATEGORY_PREFIX="cross-" +fi + +# @ECLASS_VARIABLE: _IS_CROSSPKG +# @INTERNAL +# @DESCRIPTION: +# Is true if the package is in a any Crossdev category, otherwise false +[[ ${_IS_CROSSPKG_LLVM} == 1 || ${_IS_CROSSPKG_GCC} == 1 ]] && _IS_CROSSPKG=1 + +# Default CBUILD and CTARGET to CHOST if unset. +export CBUILD=${CBUILD:-${CHOST}} +export CTARGET=${CTARGET:-${CHOST}} + +if [[ ${CTARGET} == ${CHOST} ]] ; then + # cross-aarch64-gentoo-linux-musl -> aarch64-gentoo-linux-musl + [[ ${_IS_CROSSPKG} == 1 ]] && export CTARGET=${CATEGORY#${_CROSS_CATEGORY_PREFIX}} +fi + +# @FUNCTION: target_is_not_host +# @RETURN: Shell true if we're targeting an triple other than host +target_is_not_host() { + [[ ${CHOST} != ${CTARGET} ]] +} + +# @FUNCTION: is_crosspkg +# @RETURN: Shell true if package belongs to any crossdev category +is_crosspkg() { + [[ ${_IS_CROSSPKG} == 1 ]] +} + +fi