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 715A8158021 for ; Tue, 8 Nov 2022 17:55:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0F49BE09E6; Tue, 8 Nov 2022 17:55:41 +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 EC3DEE09E6 for ; Tue, 8 Nov 2022 17:55:40 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A6CB933BEC7 for ; Tue, 8 Nov 2022 17:55:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1354870D for ; Tue, 8 Nov 2022 17:55:38 +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: <1667927491.af71c1f7c459d3372295b424457f759838cb3e7f.cybertailor@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/shards.eclass X-VCS-Directories: eclass/ X-VCS-Committer: cybertailor X-VCS-Committer-Name: Anna Vyalkova X-VCS-Revision: af71c1f7c459d3372295b424457f759838cb3e7f X-VCS-Branch: dev Date: Tue, 8 Nov 2022 17:55:38 +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: 7116e6a3-e7d6-4081-a7d1-bda11cf60655 X-Archives-Hash: d8fc4bec02025982ee06e4d3b102cb4b commit: af71c1f7c459d3372295b424457f759838cb3e7f Author: Anna (cybertailor) Vyalkova sysrq in> AuthorDate: Tue Nov 8 16:14:52 2022 +0000 Commit: Anna Vyalkova sysrq in> CommitDate: Tue Nov 8 17:11:31 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=af71c1f7 shards.eclass: new eclass Signed-off-by: Anna (cybertailor) Vyalkova sysrq.in> eclass/shards.eclass | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/eclass/shards.eclass b/eclass/shards.eclass new file mode 100644 index 000000000..548c86bce --- /dev/null +++ b/eclass/shards.eclass @@ -0,0 +1,126 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: shards.eclass +# @MAINTAINER: +# Anna +# @AUTHOR: +# Anna +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: crystal-utils +# @BLURB: eclass to build Crystal packages using Shards +# @DESCRIPTION: +# This eclass contains the default phase function for packages which use Crystal +# Shards as a build system. +# +# If the package has no shard.yml(5) file, use crystal-utils.eclass(5) instead. + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI} unsupported." +esac + +if [[ ! ${_SHARDS_ECLASS} ]]; then +_SHARDS_ECLASS=1 + +inherit crystal-utils multiprocessing toolchain-funcs + +BDEPEND=" + ${CRYSTAL_DEPS} + dev-util/gshards +" +IUSE="debug doc" + +# Crystal packages do not use CFLAGS +QA_FLAGS_IGNORED='.*' + +# @FUNCTION: shards_get_libdir +# @RETURN: the library path for Crystal packages +shards_get_libdir() { + echo "${BROOT}"/usr/lib/shards +} + +# @FUNCTION: shards_get_pkgname +# @RETURN: the package name as specified in shard.yml +shards_get_pkgname() { + debug-print-function ${FUNCNAME} "${@}" + + gshards-get-pkgname || die "Parsing package name failed" +} + +# @FUNCTION: shards_src_configure +# @DESCRIPTION: +# Function for configuring Crystal to match user settings. +shards_src_configure() { + debug-print-function ${FUNCNAME} "${@}" + + crystal_configure + einfo "CRYSTAL_OPTS='${CRYSTAL_OPTS}'" + + export CRYSTAL_PATH="$(shards_get_libdir):$(crystal env CRYSTAL_PATH || die "'crystal env' failed")" + einfo "CRYSTAL_PATH='${CRYSTAL_PATH}'" + + tc-export CC +} + +# @FUNCTION: shards_src_compile +# @USAGE: [...] +# @DESCRIPTION: +# General function for building packages using Shards. +shards_src_compile() { + debug-print-function ${FUNCNAME} "${@}" + + local build_args=( + --threads=$(makeopts_jobs) + --verbose + "${@}" + ) + + if gshards-has-targets; then + eshards build "${build_args[@]}" + fi + + if use doc; then + ecrystal docs + HTML_DOCS=( docs/. ) + fi + + return 0 +} + +# @FUNCTION: shards_src_test +# @USAGE: [...] +# @DESCRIPTION: +# Function for testing the package. +shards_src_test() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ -d "spec" ]]; then + ecrystal spec "${@}" || die "Tests failed" + fi + + return 0 +} + +# @FUNCTION: shards_src_install +# @DESCRIPTION: +# Function for installing the package. +shards_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + if [[ -d "bin" ]]; then + dobin bin/* + fi + + if [[ -d "src" ]]; then + insinto "$(shards_get_libdir)/$(shards_get_pkgname)" + doins -r src + doins shard.yml + fi + + einstalldocs +} + +fi + +EXPORT_FUNCTIONS src_configure src_compile src_test src_install