Gentoo Archives: gentoo-commits

From: Anna Vyalkova <cyber+gentoo@×××××.in>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/
Date: Tue, 08 Nov 2022 17:55:42
Message-Id: 1667927491.af71c1f7c459d3372295b424457f759838cb3e7f.cybertailor@gentoo
1 commit: af71c1f7c459d3372295b424457f759838cb3e7f
2 Author: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq <DOT> in>
3 AuthorDate: Tue Nov 8 16:14:52 2022 +0000
4 Commit: Anna Vyalkova <cyber+gentoo <AT> sysrq <DOT> in>
5 CommitDate: Tue Nov 8 17:11:31 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=af71c1f7
7
8 shards.eclass: new eclass
9
10 Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo <AT> sysrq.in>
11
12 eclass/shards.eclass | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++
13 1 file changed, 126 insertions(+)
14
15 diff --git a/eclass/shards.eclass b/eclass/shards.eclass
16 new file mode 100644
17 index 000000000..548c86bce
18 --- /dev/null
19 +++ b/eclass/shards.eclass
20 @@ -0,0 +1,126 @@
21 +# Copyright 2022 Gentoo Authors
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +# @ECLASS: shards.eclass
25 +# @MAINTAINER:
26 +# Anna <cyber+gentoo@×××××.in>
27 +# @AUTHOR:
28 +# Anna <cyber+gentoo@×××××.in>
29 +# @SUPPORTED_EAPIS: 8
30 +# @PROVIDES: crystal-utils
31 +# @BLURB: eclass to build Crystal packages using Shards
32 +# @DESCRIPTION:
33 +# This eclass contains the default phase function for packages which use Crystal
34 +# Shards as a build system.
35 +#
36 +# If the package has no shard.yml(5) file, use crystal-utils.eclass(5) instead.
37 +
38 +case ${EAPI} in
39 + 8) ;;
40 + *) die "${ECLASS}: EAPI ${EAPI} unsupported."
41 +esac
42 +
43 +if [[ ! ${_SHARDS_ECLASS} ]]; then
44 +_SHARDS_ECLASS=1
45 +
46 +inherit crystal-utils multiprocessing toolchain-funcs
47 +
48 +BDEPEND="
49 + ${CRYSTAL_DEPS}
50 + dev-util/gshards
51 +"
52 +IUSE="debug doc"
53 +
54 +# Crystal packages do not use CFLAGS
55 +QA_FLAGS_IGNORED='.*'
56 +
57 +# @FUNCTION: shards_get_libdir
58 +# @RETURN: the library path for Crystal packages
59 +shards_get_libdir() {
60 + echo "${BROOT}"/usr/lib/shards
61 +}
62 +
63 +# @FUNCTION: shards_get_pkgname
64 +# @RETURN: the package name as specified in shard.yml
65 +shards_get_pkgname() {
66 + debug-print-function ${FUNCNAME} "${@}"
67 +
68 + gshards-get-pkgname || die "Parsing package name failed"
69 +}
70 +
71 +# @FUNCTION: shards_src_configure
72 +# @DESCRIPTION:
73 +# Function for configuring Crystal to match user settings.
74 +shards_src_configure() {
75 + debug-print-function ${FUNCNAME} "${@}"
76 +
77 + crystal_configure
78 + einfo "CRYSTAL_OPTS='${CRYSTAL_OPTS}'"
79 +
80 + export CRYSTAL_PATH="$(shards_get_libdir):$(crystal env CRYSTAL_PATH || die "'crystal env' failed")"
81 + einfo "CRYSTAL_PATH='${CRYSTAL_PATH}'"
82 +
83 + tc-export CC
84 +}
85 +
86 +# @FUNCTION: shards_src_compile
87 +# @USAGE: [<args>...]
88 +# @DESCRIPTION:
89 +# General function for building packages using Shards.
90 +shards_src_compile() {
91 + debug-print-function ${FUNCNAME} "${@}"
92 +
93 + local build_args=(
94 + --threads=$(makeopts_jobs)
95 + --verbose
96 + "${@}"
97 + )
98 +
99 + if gshards-has-targets; then
100 + eshards build "${build_args[@]}"
101 + fi
102 +
103 + if use doc; then
104 + ecrystal docs
105 + HTML_DOCS=( docs/. )
106 + fi
107 +
108 + return 0
109 +}
110 +
111 +# @FUNCTION: shards_src_test
112 +# @USAGE: [<args>...]
113 +# @DESCRIPTION:
114 +# Function for testing the package.
115 +shards_src_test() {
116 + debug-print-function ${FUNCNAME} "${@}"
117 +
118 + if [[ -d "spec" ]]; then
119 + ecrystal spec "${@}" || die "Tests failed"
120 + fi
121 +
122 + return 0
123 +}
124 +
125 +# @FUNCTION: shards_src_install
126 +# @DESCRIPTION:
127 +# Function for installing the package.
128 +shards_src_install() {
129 + debug-print-function ${FUNCNAME} "${@}"
130 +
131 + if [[ -d "bin" ]]; then
132 + dobin bin/*
133 + fi
134 +
135 + if [[ -d "src" ]]; then
136 + insinto "$(shards_get_libdir)/$(shards_get_pkgname)"
137 + doins -r src
138 + doins shard.yml
139 + fi
140 +
141 + einstalldocs
142 +}
143 +
144 +fi
145 +
146 +EXPORT_FUNCTIONS src_configure src_compile src_test src_install