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

Replies

Subject Author
Re: [gentoo-dev] [PATCH v2] eclass/dune.eclass: fixes Sam James <sam@g.o>