From: Alfred Persson Forsberg <cat@catcream.org>
To: gentoo-dev@lists.gentoo.org
Cc: sam@gentoo.org, llvm@gentoo.org, toolchain@gentoo.org,
cross@gentoo.org, Alfred Persson Forsberg <cat@catcream.org>
Subject: [gentoo-dev] [PATCH 1/4] cross.eclass: new eclass
Date: Fri, 11 Aug 2023 05:48:20 +0200 [thread overview]
Message-ID: <20230811034823.34301-3-cat@catcream.org> (raw)
In-Reply-To: <20230811034823.34301-1-cat@catcream.org>
Signed-off-by: Alfred Persson Forsberg <cat@catcream.org>
---
eclass/cross.eclass | 83 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
create mode 100644 eclass/cross.eclass
diff --git a/eclass/cross.eclass b/eclass/cross.eclass
new file mode 100644
index 000000000000..a7a75aac8e43
--- /dev/null
+++ b/eclass/cross.eclass
@@ -0,0 +1,83 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: cross.eclass
+# @MAINTAINER:
+# cat@catcream.org
+# @AUTHOR:
+# Alfred Persson Forsberg <cat@catcream.org> (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 ${_CROSS_ECLASS} ]]; then
+_CROSS_ECLASS=1
+
+# @ECLASS_VARIABLE: _CROSS_CATEGORY_PREFIX
+# @INTERNAL
+_CROSS_CATEGORY_PREFIX=""
+
+# @ECLASS_VARIABLE: _IS_CROSSPKG_LLVM
+# @INTERNAL
+_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
+_IS_CROSSPKG_GCC=0
+if [[ ${CATEGORY} == cross-* ]] ; then
+ _IS_CROSSPKG_GCC=1
+ _CROSS_CATEGORY_PREFIX="cross-"
+fi
+
+# @ECLASS_VARIABLE: _IS_CROSSPKG
+# @INTERNAL
+[[ ${_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_GCC} == 1 ]] && export CTARGET=${CATEGORY#cross-}
+ [[ ${_IS_CROSSPKG_LLVM} == 1 ]] && export CTARGET=${CATEGORY#cross_llvm-}
+fi
+
+# @FUNCTION: is_crosscompile
+# @RETURN:
+# Shell true if we're targeting an architecture other than host
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+
+# @FUNCTION: is_crosspkg
+# @RETURN:
+# Shell true if package belongs to any crossdev category
+is_crosspkg() {
+ [[ ${_IS_CROSSPKG} == 1 ]]
+}
+
+# @FUNCTION: is_crosspkg_gcc
+# @RETURN:
+# Shell true if package belongs to GCC (standard) crossdev category
+is_crosspkg_gcc() {
+ [[ ${_IS_CROSSPKG_GCC} == 1 ]]
+}
+
+# @FUNCTION: is_crosspkg_llvm
+# @RETURN:
+# Shell true if package belongs to LLVM crossdev category.
+is_crosspkg_llvm() {
+ [[ ${_IS_CROSSPKG_LLVM} == 1 ]]
+}
+
+fi
--
2.41.0
next prev parent reply other threads:[~2023-08-11 3:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 3:48 [gentoo-dev] [PATCH 3/4] kernel-2.eclass: Use cross.eclass for figuring out CTARGET Alfred Persson Forsberg
2023-08-11 3:48 ` [gentoo-dev] [PATCH 0/4] Introducing cross.eclass for Crossdev ebuilds Alfred Persson Forsberg
2023-08-11 3:48 ` Alfred Persson Forsberg [this message]
2023-08-11 3:48 ` [gentoo-dev] [PATCH 2/4] sys-libs/musl: Support LLVM/Clang crossdev Alfred Persson Forsberg
2023-08-11 3:48 ` [gentoo-dev] [PATCH 3/4] kernel-2.eclass: Use cross.eclass for figuring out CTARGET Alfred Persson Forsberg
2023-08-11 3:48 ` [gentoo-dev] [PATCH 4/4] sys-libs/compiler-rt: Support LLVM/Clang crossdev Alfred Persson Forsberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230811034823.34301-3-cat@catcream.org \
--to=cat@catcream.org \
--cc=cross@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=llvm@gentoo.org \
--cc=sam@gentoo.org \
--cc=toolchain@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox