Gentoo Archives: gentoo-dev

From: Anna <cyber+gentoo@×××××.in>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] eclass/dune.eclass: introduce edune and dune-compile
Date: Mon, 02 Jan 2023 23:08:38
Message-Id: Y7NjxS/5ygunB3Av@sysrq.in
In Reply to: [gentoo-dev] [PATCH] eclass/dune.eclass: introduce edune and dune-compile by "Maciej Barć"
1 On 2023-01-02 22:37, Maciej Barć wrote:
2 > edune is a thin wrapper for dune, which will help to run special,
3 > uncommon dune commands;
4 > dune-compile is a function to selectively pick which packages will be
5 > compiled "for-release" (as dune call it);
6 > dune-compile without any arguments replaces the current dune_src_compile
7 >
8 > Signed-off-by: Maciej Barć <xgqt@g.o>
9 > ---
10 > eclass/dune.eclass | 47 ++++++++++++++++++++++++++++++++++++++++++----
11 > 1 file changed, 43 insertions(+), 4 deletions(-)
12 >
13 > diff --git a/eclass/dune.eclass b/eclass/dune.eclass
14 > index 4bc73eda8..6c760accd 100644
15 > --- a/eclass/dune.eclass
16 > +++ b/eclass/dune.eclass
17 > @@ -1,4 +1,4 @@
18 > -# Copyright 1999-2022 Gentoo Authors
19 > +# Copyright 1999-2023 Gentoo Authors
20 > # Distributed under the terms of the GNU General Public License v2
21 >
22 > # @ECLASS: dune.eclass
23 > @@ -44,15 +44,54 @@ BDEPEND="
24 > dev-ml/dune
25 > "
26 >
27 > +# @FUNCTION: edune
28 > +# @USAGE: <arg> ...
29 > +# @DESCRIPTION:
30 > +# A thin wrapper for the `dune` command.
31 > +# Runs `dune` with given arguments and dies on failure.
32 > +#
33 > +# Example use:
34 > +# @CODE
35 > +# edune clean
36 > +# @CODE
37 > +edune() {
38 > + debug-print-function ${FUNCNAME} "${@}"
39 > +
40 > + dune "${@}" || die "dune call failed, given arguments: ${@}"
41
42 Please use "edo" to also log the command being executed.
43
44 > +}
45 > +
46 > +# @FUNCTION: dune-compile
47 > +# @USAGE: [package] ...
48 > +# @DESCRIPTION:
49 > +# Compiles either all of packages sources in current directory or selected
50 > +# packages. In case of all packages the package detection is done via dune
51 > +# itself.
52 > +#
53 > +# Example use:
54 > +# @CODE
55 > +# dune-compile menhir menhirLib menhirSdk
56 > +# @CODE
57 > +dune-compile() {
58 > + local -a myduneopts=(
59 > + -j $(makeopts_jobs)
60 > + --profile release
61 > + )
62 > + if [[ -n "${1}" ]] ; then
63 > + myduneopts+=( --for-release-of-packages="$(IFS="," ; echo "${*}")" )
64 > + fi
65 > +
66 > + edune build @install "${myduneopts[@]}"
67 > +}
68 > +
69 > dune_src_compile() {
70 > ebegin "Building"
71 > - dune build @install -j $(makeopts_jobs) --profile release
72 > + dune-compile
73 > eend $? || die
74 > }
75 >
76 > dune_src_test() {
77 > ebegin "Testing"
78 > - dune runtest -j $(makeopts_jobs) --profile release
79 > + edune runtest -j $(makeopts_jobs) --profile release
80 > eend $? || die
81 > }
82 >
83 > @@ -80,7 +119,7 @@ dune-install() {
84 > local pkg
85 > for pkg in "${pkgs[@]}" ; do
86 > ebegin "Installing ${pkg}"
87 > - dune install ${myduneopts[@]} ${pkg}
88 > + edune install ${myduneopts[@]} ${pkg}
89 > eend $? || die
90 >
91 > # Move docs to the appropriate place.
92 > --
93 > 2.38.2
94 >
95 >