summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorRafael Kitover <rkitover@gmail.com>2020-06-11 19:27:14 +0000
committerJoonas Niilola <juippis@gentoo.org>2020-06-24 13:25:33 +0300
commit633c73f60097058b43dba7210723af4d84b39008 (patch)
treec09055d54bb0ec511b60095d418eb97421022050 /eclass
parentx11-misc/xscreensaver: Add IUSE="gdk-pixbuf gtk locking" (diff)
downloadgentoo-633c73f60097058b43dba7210723af4d84b39008.tar.gz
gentoo-633c73f60097058b43dba7210723af4d84b39008.tar.bz2
gentoo-633c73f60097058b43dba7210723af4d84b39008.zip
dune.eclass: new eclass
New eclass for the Dune build system for OCaml. https://github.com/ocaml/dune Based on oasis.eclass and opam.eclass for OCaml. Signed-off-by: Rafael Kitover <rkitover@gmail.com> Signed-off-by: Joonas Niilola <juippis@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/dune.eclass65
1 files changed, 65 insertions, 0 deletions
diff --git a/eclass/dune.eclass b/eclass/dune.eclass
new file mode 100644
index 000000000000..9ab6ec204c21
--- /dev/null
+++ b/eclass/dune.eclass
@@ -0,0 +1,65 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dune.eclass
+# @MAINTAINER:
+# rkitover@gmail.com
+# @AUTHOR:
+# Rafael Kitover <rkitover@gmail.com>
+# @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?]"
+DEPEND="${RDEPEND}
+ dev-ml/dune"
+
+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
+}