Gentoo Archives: gentoo-dev

From: Florian Schmaus <flow@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] eclass/dune.eclass: introduce edune and dune-compile (v2)
Date: Tue, 03 Jan 2023 06:55:17
Message-Id: 1c891810-6f91-07ef-7b98-e6baa0f2831d@gentoo.org
In Reply to: [gentoo-dev] [PATCH] eclass/dune.eclass: introduce edune and dune-compile (v2) by "Maciej Barć"
1 On 03/01/2023 00.19, 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 | 49 +++++++++++++++++++++++++++++++++++++++++-----
11 > 1 file changed, 44 insertions(+), 5 deletions(-)
12 >
13 > diff --git a/eclass/dune.eclass b/eclass/dune.eclass
14 > index 4bc73eda8..384908a40 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 > @@ -29,7 +29,7 @@ _DUNE_ECLASS=1
24 > # Set before inheriting the eclass.
25 > : ${DUNE_PKG_NAME:=${PN}}
26 >
27 > -inherit multiprocessing
28 > +inherit edo multiprocessing
29 >
30 > # Do not complain about CFLAGS etc since ml projects do not use them.
31 > QA_FLAGS_IGNORED='.*'
32 > @@ -44,15 +44,54 @@ BDEPEND="
33 > dev-ml/dune
34 > "
35 >
36 > +# @FUNCTION: edune
37 > +# @USAGE: <arg> ...
38 > +# @DESCRIPTION:
39 > +# A thin wrapper for the `dune` command.
40 > +# Runs `dune` with given arguments and dies on failure.
41 > +#
42 > +# Example use:
43 > +# @CODE
44 > +# edune clean
45 > +# @CODE
46 > +edune() {
47 > + debug-print-function ${FUNCNAME} "${@}"
48 > +
49 > + edo dune "${@}"
50 > +}
51 > +
52 > +# @FUNCTION: dune-compile
53 > +# @USAGE: [package] ...
54 > +# @DESCRIPTION:
55 > +# Compiles either all of packages sources in current directory or selected
56 > +# packages. In case of all packages the package detection is done via dune
57 > +# itself.
58 > +#
59 > +# Example use:
60 > +# @CODE
61 > +# dune-compile menhir menhirLib menhirSdk
62 > +# @CODE
63 > +dune-compile() {
64 > + local -a myduneopts=(
65 > + -j $(makeopts_jobs)
66 > + --profile release
67 > + )
68 > + if [[ -n "${1}" ]] ; then
69 > + myduneopts+=( --for-release-of-packages="$(IFS="," ; echo "${*}")" )
70 > + fi
71 > +
72 > + edune build @install "${myduneopts[@]}"
73 > +}
74 > +
75 > dune_src_compile() {
76 > ebegin "Building"
77 > - dune build @install -j $(makeopts_jobs) --profile release
78 > + dune-compile
79 > eend $? || die
80 > }
81 >
82 > dune_src_test() {
83 > ebegin "Testing"
84 > - dune runtest -j $(makeopts_jobs) --profile release
85 > + edune runtest -j $(makeopts_jobs) --profile release
86 > eend $? || die
87 > }
88 >
89 > @@ -80,7 +119,7 @@ dune-install() {
90 > local pkg
91 > for pkg in "${pkgs[@]}" ; do
92 > ebegin "Installing ${pkg}"
93 > - dune install ${myduneopts[@]} ${pkg}
94 > + edune install ${myduneopts[@]} ${pkg}
95 > eend $? || die
96 >
97 > # Move docs to the appropriate place.
98
99 It appears there is additional output between the ebegin / eend. You may
100 want to consider dropping ebegin and eend. In general, the pattern
101 ebegin, edo, eend should probably be avoided.
102
103 - Flow

Replies