Gentoo Archives: gentoo-dev

From: "Maciej Barć" <xgqt@g.o>
To: gentoo-dev@l.g.o
Cc: ml@g.o, "Maciej Barć" <xgqt@g.o>
Subject: [gentoo-dev] [PATCH v4] eclass/dune.eclass: fix dune-install function
Date: Fri, 10 Dec 2021 10:03:47
Message-Id: 20211210100316.16033-1-xgqt@gentoo.org
1 Support EAPI 8 and drop support for EAPI 5.
2 Set DUNE_PKG_NAME to PN by default.
3 Move "Move docs to the appropriate place" block to dune-install
4 to make dune-install now handle a list of subpackages correctly.
5 Use ebegin and eend for dune calls instead of "|| die".
6 Thanks to ULM for bash fixes.
7
8 Signed-off-by: Maciej Barć <xgqt@g.o>
9 ---
10 eclass/dune.eclass | 56 +++++++++++++++++++++++++++++-----------------
11 1 file changed, 35 insertions(+), 21 deletions(-)
12
13 diff --git a/eclass/dune.eclass b/eclass/dune.eclass
14 index 02a8a870e..69aad3692 100644
15 --- a/eclass/dune.eclass
16 +++ b/eclass/dune.eclass
17 @@ -8,7 +8,7 @@
18 # ML <ml@g.o>
19 # @AUTHOR:
20 # Rafael Kitover <rkitover@×××××.com>
21 -# @SUPPORTED_EAPIS: 5 6 7
22 +# @SUPPORTED_EAPIS: 6 7 8
23 # @BLURB: Provides functions for installing Dune packages.
24 # @DESCRIPTION:
25 # Provides dependencies on dDne and OCaml and default src_compile, src_test and
26 @@ -19,9 +19,10 @@
27 # @DESCRIPTION:
28 # Sets the actual Dune package name, if different from Gentoo package name.
29 # Set before inheriting the eclass.
30 +: ${DUNE_PKG_NAME:-${PN}}
31
32 case ${EAPI:-0} in
33 - 5|6|7) ;;
34 + 6|7|8) ;;
35 *) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
36 esac
37
38 @@ -32,7 +33,7 @@ EXPORT_FUNCTIONS src_compile src_test src_install
39
40 RDEPEND=">=dev-lang/ocaml-4:=[ocamlopt?] dev-ml/dune:="
41 case ${EAPI:-0} in
42 - 5|6)
43 + 6)
44 DEPEND="${RDEPEND} dev-ml/dune"
45 ;;
46 *)
47 @@ -42,11 +43,15 @@ case ${EAPI:-0} in
48 esac
49
50 dune_src_compile() {
51 - dune build @install --profile release || die
52 + ebegin "Building"
53 + dune build @install --profile release
54 + eend $? || die
55 }
56
57 dune_src_test() {
58 - dune runtest || die
59 + ebegin "Testing"
60 + dune runtest
61 + eend $? || die
62 }
63
64 # @FUNCTION: dune-install
65 @@ -54,26 +59,35 @@ dune_src_test() {
66 # @DESCRIPTION:
67 # Installs the dune packages given as arguments. For each "${pkg}" element in
68 # that list, "${pkg}.install" must be readable from "${PWD}/_build/default"
69 +#
70 +# Example use:
71 +# @CODE
72 +# dune-install menhir menhirLib menhirSdk
73 +# @CODE
74 dune-install() {
75 + local -a pkgs=( "${@}" )
76 + [[ ${#pkgs[@]} -eq 0 ]] && pkgs=( "${DUNE_PKG_NAME}" )
77 +
78 + local -a myduneopts=(
79 + --prefix="${ED%/}/usr"
80 + --libdir="${D%/}$(ocamlc -where)"
81 + --mandir="${ED%/}/usr/share/man"
82 + )
83 local pkg
84 - for pkg ; do
85 - dune install \
86 - --prefix="${ED%/}/usr" \
87 - --libdir="${D%/}$(ocamlc -where)" \
88 - --mandir="${ED%/}/usr/share/man" \
89 - "${pkg}" || die
90 + for pkg in "${pkgs[@]}" ; do
91 + ebegin "Installing ${pkg}"
92 + dune install ${myduneopts[@]} ${pkg}
93 + eend $? || die
94 +
95 + # Move docs to the appropriate place.
96 + if [ -d "${ED%/}/usr/doc/${pkg}" ] ; then
97 + mkdir -p "${ED%/}/usr/share/doc/${PF}/" || die
98 + mv "${ED%/}/usr/doc/${pkg}" "${ED%/}/usr/share/doc/${PF}/" || die
99 + rm -rf "${ED%/}/usr/doc" || die
100 + fi
101 done
102 }
103
104 dune_src_install() {
105 - local pkg="${1:-${DUNE_PKG_NAME:-${PN}}}"
106 -
107 - dune-install "${pkg}"
108 -
109 - # Move docs to the appropriate place.
110 - if [ -d "${ED%/}/usr/doc/${pkg}" ] ; then
111 - mkdir -p "${ED%/}/usr/share/doc/${PF}/" || die
112 - mv "${ED%/}/usr/doc/${pkg}/"* "${ED%/}/usr/share/doc/${PF}/" || die
113 - rm -rf "${ED%/}/usr/doc" || die
114 - fi
115 + dune-install ${1:-${DUNE_PKG_NAME}}
116 }
117 --
118 2.32.0