From: "Anna (cybertailor) Vyalkova" <cyber+gentoo@sysrq.in>
To: gentoo-guru@lists.gentoo.org
Subject: [gentoo-guru] [PATCH v2 3/3] shards.eclass: new eclass
Date: Tue, 8 Nov 2022 22:14:23 +0500 [thread overview]
Message-ID: <20221108171423.20081-3-cyber+gentoo@sysrq.in> (raw)
In-Reply-To: <20221108171423.20081-1-cyber+gentoo@sysrq.in>
Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
---
Changes since v1:
- set metadata variables in global scope
eclass/shards.eclass | 126 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
create mode 100644 eclass/shards.eclass
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 <cyber+gentoo@sysrq.in>
+# @AUTHOR:
+# Anna <cyber+gentoo@sysrq.in>
+# @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: [<args>...]
+# @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: [<args>...]
+# @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
--
2.38.1
prev parent reply other threads:[~2024-11-24 22:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 16:25 [gentoo-guru] [PATCH 0/3] Eclasses for Crystal lang Anna (cybertailor) Vyalkova
2022-11-08 16:25 ` [gentoo-guru] [PATCH 1/3] crystal-utils.eclass: new eclass Anna (cybertailor) Vyalkova
2022-11-08 16:34 ` John Helmert III
2022-11-08 16:39 ` Anna
2022-11-08 16:25 ` [gentoo-guru] [PATCH 2/3] dev-util/gshards: new package, add 0.1 Anna (cybertailor) Vyalkova
2022-11-08 16:25 ` [gentoo-guru] [PATCH 3/3] shards.eclass: new eclass Anna (cybertailor) Vyalkova
2022-11-08 17:14 ` [gentoo-guru] [PATCH v2 1/3] crystal-utils.eclass: " Anna (cybertailor) Vyalkova
2022-11-08 17:14 ` [gentoo-guru] [PATCH v2 2/3] dev-util/gshards: new package, add 0.1 Anna (cybertailor) Vyalkova
2022-11-08 17:14 ` Anna (cybertailor) Vyalkova [this message]
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=20221108171423.20081-3-cyber+gentoo@sysrq.in \
--to=cyber+gentoo@sysrq.in \
--cc=gentoo-guru@lists.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