This only has one function for now, but I intend to add a general purpose sysroot wrapper script for use with Meson, Perl, and more. It just needs longer in the oven.
Signed-off-by: James Le Cuirot <ch...@gentoo.org> --- eclass/sysroot.eclass | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 eclass/sysroot.eclass diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass new file mode 100644 index 000000000000..73722154564a --- /dev/null +++ b/eclass/sysroot.eclass @@ -0,0 +1,34 @@ +# Copyright 2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: sysroot.eclass +# @MAINTAINER: +# cr...@gentoo.org +# @AUTHOR: +# James Le Cuirot <ch...@gentoo.org> +# @SUPPORTED_EAPIS: 8 +# @BLURB: Common functions for using a different sysroot (e.g. cross-compiling) + +case ${EAPI} in + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +# @FUNCTION: qemu_arch +# @DESCRIPTION: +# Return the QEMU architecture name for the current CHOST. This name is used in +# qemu-user binary filenames, e.g. qemu-ppc64le. +qemu_arch() { + case "${CHOST}" in + armeb*) echo armeb ;; + arm*) echo arm ;; + hppa*) echo hppa ;; + i?86*) echo i386 ;; + mips64el*) [[ ${ABI} == n32 ]] && echo mipsn32el || echo mips64el ;; + mips64*) [[ ${ABI} == n32 ]] && echo mipsn32 || echo mips64 ;; + powerpc64le*) echo ppc64le ;; + powerpc64*) echo ppc64 ;; + powerpc*) echo ppc ;; + *) echo "${CHOST%%-*}" ;; + esac +} -- 2.49.0