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 3C831158094 for ; Wed, 29 Jun 2022 11:52:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D8C07E0A5B; Wed, 29 Jun 2022 11:52:51 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 BF42CE0A5B for ; Wed, 29 Jun 2022 11:52:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 9973B340FFF for ; Wed, 29 Jun 2022 11:52:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0420D514 for ; Wed, 29 Jun 2022 11:52:49 +0000 (UTC) From: "Anna Vyalkova" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anna Vyalkova" Message-ID: <1656503546.d34b616bfc616418be86dab44d53f9397665a7bc.cybertailor@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/nim-utils.eclass X-VCS-Directories: eclass/ X-VCS-Committer: cybertailor X-VCS-Committer-Name: Anna Vyalkova X-VCS-Revision: d34b616bfc616418be86dab44d53f9397665a7bc X-VCS-Branch: dev Date: Wed, 29 Jun 2022 11:52:49 +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: f8accd74-3df7-4f74-be96-8ed055dc7a29 X-Archives-Hash: 164fa6d7465da1b7334f7735576055d1 commit: d34b616bfc616418be86dab44d53f9397665a7bc Author: Anna (cybertailor) Vyalkova sysrq in> AuthorDate: Wed Jun 29 07:13:20 2022 +0000 Commit: Anna Vyalkova sysrq in> CommitDate: Wed Jun 29 11:52:26 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=d34b616b eclass/nim-utils.eclass: new eclass Signed-off-by: Anna (cybertailor) Vyalkova sysrq.in> eclass/nim-utils.eclass | 115 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/eclass/nim-utils.eclass b/eclass/nim-utils.eclass new file mode 100644 index 000000000..12b077452 --- /dev/null +++ b/eclass/nim-utils.eclass @@ -0,0 +1,115 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: nim-utils.eclass +# @MAINTAINER: +# Anna Vyalkova +# @AUTHOR: +# Anna Vyalkova +# @SUPPORTED_EAPIS: 8 +# @BLURB: utility functions for Nim packages +# @DESCRIPTION: +# A utility eclass providing functions to call and configure Nim. +# +# This eclass does not set any metadata variables nor export any phase +# functions. It can be inherited safely. + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI} unsupported." +esac + +if [[ ! ${_NIM_UTILS_ECLASS} ]]; then + +# @ECLASS_VARIABLE: NIMFLAGS +# @USER_VARIABLE +# @DEFAULT_UNSET +# @DESCRIPTION: +# Flags for the Nim compiler. + +# @ECLASS_VARIABLE: TESTAMENT_DISABLE_MEGATEST +# @USER_VARIABLE +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set, pass '--megatest:off' to testament. + +# @VARIABLE: ETESTAMENT_DESELECT +# @DEFAULT_UNSET +# @DESCRIPTION: +# Specifies an array of test files to be deselected via testament's --skipFrom +# parameter, when calling etestament. + +inherit multiprocessing toolchain-funcs xdg-utils + +# @FUNCTION: enim +# @USAGE: [...] +# @DESCRIPTION: +# Call nim, passing the supplied arguments. +# This function dies if nim fails. It also supports being called via 'nonfatal'. +# If you need to call nim directly in your ebuilds, this is the way it should +# be done. +enim() { + debug-print-function ${FUNCNAME} "${@}" + + set -- nim "${@}" + echo "$@" >&2 + "$@" || die -n "${*} failed" +} + +# @FUNCTION: etestament +# @USAGE: [...] +# @DESCRIPTION: +# Call testament, passing the supplied arguments. +# This function dies if testament fails. +etestament() { + debug-print-function ${FUNCNAME} "${@}" + + local -a testament_args=() + [[ ${TESTAMENT_DISABLE_MEGATEST} ]] && \ + testament_args+=( --megatest:off ) + + [[ "${NOCOLOR}" == true || "${NOCOLOR}" == yes ]] && \ + testament_args+=( --colors:off ) + + if [[ ${ETESTAMENT_DESELECT} ]]; then + local skipfile="${T}"/testament.skipfile + for t in "${ETESTAMENT_DESELECT[@]}"; do + echo "${t}" >> "${skipfile}" + done + testament_args+=( --skipFrom:"${skipfile}" ) + fi + + set -- testament "${testament_args[@]}" "${@}" + echo "$@" >&2 + "$@" || die -n "${*} failed" +} + +# @FUNCTION: nim_gen_config +# @USAGE: +# @DESCRIPTION: +# Generate the ${WORKDIR}/nim.cfg to respect user's toolchain and preferences. +nim_gen_config() { + debug-print-function ${FUNCNAME} "${@}" + + xdg_environment_reset + + cat > "${WORKDIR}/nim.cfg" <<- EOF || die "Failed to create Nim config" + cc:"gcc" + gcc.exe:"$(tc-getCC)" + gcc.linkerexe:"$(tc-getCC)" + gcc.cpp.exe:"$(tc-getCXX)" + gcc.cpp.linkerexe:"$(tc-getCXX)" + gcc.options.always:"${CFLAGS} ${CPPFLAGS}" + gcc.options.linker:"${LDFLAGS}" + gcc.cpp.options.always:"${CFLAGS} ${CPPFLAGS}" + gcc.cpp.options.linker:"${LDFLAGS}" + + $([[ "${NOCOLOR}" == true || "${NOCOLOR}" == yes ]] && echo '--colors:"off"') + -d:"release" + --parallelBuild:"$(makeopts_jobs)" + $(printf "%s\n" ${NIMFLAGS}) + EOF +} + +_NIM_UTILS_ECLASS=1 +fi