forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dune.eclass
68 lines (57 loc) · 1.71 KB
/
dune.eclass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: dune.eclass
# @MAINTAINER:
# Mark Wright <[email protected]>
# @AUTHOR:
# Rafael Kitover <[email protected]>
# @SUPPORTED_EAPIS: 5 6 7
# @BLURB: Provides functions for installing dune packages.
# @DESCRIPTION:
# Provides dependencies on dune and ocaml and default src_compile, src_test and
# src_install for dune-based packages.
# @ECLASS-VARIABLE: DUNE_PKG_NAME
# @DESCRIPTION:
# Sets the actual dune package name, if different from gentoo package name.
# Set before inheriting the eclass.
case ${EAPI:-0} in
5|6|7) ;;
*) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
esac
EXPORT_FUNCTIONS src_compile src_test src_install
RDEPEND=">=dev-lang/ocaml-4:=[ocamlopt?]"
case ${EAPI:-0} in
0|1|2|3|4|5|6) DEPEND="${RDEPEND} dev-ml/dune";;
*) BDEPEND="dev-ml/dune dev-lang/ocaml"; DEPEND="${RDEPEND}" ;;
esac
dune_src_compile() {
dune build @install || die
}
dune_src_test() {
dune runtest || die
}
# @FUNCTION: dune-install
# @USAGE: <list of packages>
# @DESCRIPTION:
# Installs the dune packages given as arguments. For each "${pkg}" element in
# that list, "${pkg}.install" must be readable from "${PWD}/_build/default"
dune-install() {
local pkg
for pkg ; do
dune install \
--prefix="${ED%/}/usr" \
--libdir="${D%/}$(ocamlc -where)" \
"${pkg}" || die
done
}
dune_src_install() {
local pkg="${1:-${DUNE_PKG_NAME:-${PN}}}"
dune-install "${pkg}"
# Move docs to the appropriate place.
if [ -d "${ED%/}/usr/doc/${pkg}" ] ; then
mkdir -p "${ED%/}/usr/share/doc/${PF}/" || die
mv "${ED%/}/usr/doc/${pkg}/"* "${ED%/}/usr/share/doc/${PF}/" || die
rm -rf "${ED%/}/usr/doc" || die
fi
}