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 79223158094 for ; Wed, 29 Jun 2022 15:38:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 49BEEE0876; Wed, 29 Jun 2022 15:38:05 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 E6E5BE0876 for ; Wed, 29 Jun 2022 15:38:04 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 29CB8341A62 for ; Wed, 29 Jun 2022 15:38:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C58F152F for ; Wed, 29 Jun 2022 15:38:00 +0000 (UTC) From: "Florian Schmaus" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Florian Schmaus" Message-ID: <1656503552.56b12ae84dcc932450abcab8e2099582cf4e22c0.flow@gentoo> Subject: [gentoo-commits] repo/proj/guru:master commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/nimble.eclass X-VCS-Directories: eclass/ X-VCS-Committer: flow X-VCS-Committer-Name: Florian Schmaus X-VCS-Revision: 56b12ae84dcc932450abcab8e2099582cf4e22c0 X-VCS-Branch: master Date: Wed, 29 Jun 2022 15:38:00 +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: 6e38260f-b6be-49a0-9e89-11089ef25c82 X-Archives-Hash: b23107f22958203c8566232bc2154b5a commit: 56b12ae84dcc932450abcab8e2099582cf4e22c0 Author: Anna (cybertailor) Vyalkova sysrq in> AuthorDate: Wed Jun 29 08:18:03 2022 +0000 Commit: Florian Schmaus gentoo org> CommitDate: Wed Jun 29 11:52:32 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=56b12ae8 eclass/nimble.eclass: new eclass Signed-off-by: Anna (cybertailor) Vyalkova sysrq.in> eclass/nimble.eclass | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/eclass/nimble.eclass b/eclass/nimble.eclass new file mode 100644 index 000000000..177a2fbd4 --- /dev/null +++ b/eclass/nimble.eclass @@ -0,0 +1,169 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: nimble.eclass +# @MAINTAINER: +# Anna Vyalkova +# @AUTHOR: +# Anna Vyalkova +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: nim-utils +# @BLURB: eclass to build Nim packages that use nimble as a build system +# @EXAMPLE: +# Typical ebuild for a Nim application: +# +# EAPI=8 +# +# inherit nimble +# +# ... +# +# src_compile() { +# nimble_src_compile +# nimble_build scss +# } +# +# ... +# +# +# Typical ebuild for a Nim library: +# +# EAPI=8 +# +# inherit nimble +# +# ... +# SLOT=${PV} +# +# set_package_url "https://github.com/example/example" + + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI} unsupported." +esac + +if [[ ! ${_NIMBLE_ECLASS} ]]; then + +# @ECLASS_VARIABLE: BUILD_DIR +# @DEFAULT_UNSET +# @DESCRIPTION: +# Build directory, location where all generated files should be placed. +# If this isn't set, it defaults to ${WORKDIR}/${P}-build. + +inherit edo nim-utils ninja-utils + +BDEPEND="${NINJA_DEPEND} + dev-lang/nim + dev-nim/nimbus +" + +# @FUNCTION: set_package_url +# @USAGE: +# @DESCRIPTION: +# If this function is called, nimbus will generate and install a nimblemeta.json +# file. Some packages specify their dependencies using URLs and nimbus is +# unable to find them unless a metadata file exists. +set_package_url() { + debug-print-function ${FUNCNAME} "${@}" + + (( $# == 1 )) || \ + die "${FUNCNAME} takes exactly one argument" + + _PACKAGE_URL="${1}" +} + +# @FUNCTION: get_package_url +# @USAGE: +# @INTERNAL +# @RETURN: package URL +get_package_url() { + echo "${_PACKAGE_URL}" +} + +# @FUNCTION: nimble_src_configure +# @USAGE: +# @DESCRIPTION: +# Configure the package with nimbus. This will start an out-of-source build. +# Passes arguments to Nim by reading from an optionally pre-defined local +# mynimargs bash array. +# @CODE +# src_configure() { +# local mynimargs=( +# --threads:on +# ) +# nimble_src_configure +# } +# @CODE +nimble_src_configure() { + debug-print-function ${FUNCNAME} "${@}" + + [[ -n "${NINJA_DEPEND}" ]] || \ + ewarn "Unknown value '${NINJA}' for \${NINJA}" + + BUILD_DIR="${BUILD_DIR:-${WORKDIR}/${P}-build}" + + [[ -z ${mynimargs} ]] && local -a mynimargs=() + local mynimargstype=$(declare -p mynimargs 2>&-) + if [[ "${mynimargstype}" != "declare -a mynimargs="* ]]; then + die "mynimargs must be declared as array" + fi + + nim_gen_config + + local nimbusargs=( + --nimbleDir:"${EPREFIX}"/opt/nimble + --binDir:"${EPREFIX}"/usr/bin + --url:"$(get_package_url)" + "${mynimargs[@]}" + ) + + edo nimbus "${nimbusargs[@]}" "${S}" "${BUILD_DIR}" +} + +# @FUNCTION: nimble_build +# @USAGE: [ninja args...] +# @DESCRIPTION: +# Function for building the package. All arguments are passed to eninja. +nimble_build() { + debug-print-function ${FUNCNAME} "${@}" + + eninja -C "${BUILD_DIR}" "${@}" +} + +# @FUNCTION: nimble_src_compile +# @USAGE: [ninja args...] +# @DESCRIPTION: +# Build the package with Ninja. All arguments are passed to nimble_build. +nimble_src_compile() { + debug-print-function ${FUNCNAME} "${@}" + + nimble_build "${@}" +} + +# @FUNCTION: nimble_src_test +# @USAGE: [ninja args...] +# @DESCRIPTION: +# Test the package. All arguments are passed to nimble_build. +nimble_src_test() { + debug-print-function ${FUNCNAME} "${@}" + + if nonfatal nimble_build test -n &> /dev/null; then + nimble_build test "${@}" + fi +} + +# @FUNCTION: nimble_src_install +# @DESCRIPTION: +# Install the package with Ninja. All arguments are passed to nimble_build. +nimble_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + DESTDIR="${D}" nimble_build install "${@}" + einstalldocs +} + +_NIMBLE_ECLASS=1 +fi + +EXPORT_FUNCTIONS src_configure src_compile src_test src_install