forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eclass/dune.eclass: fix dune-install function
Support EAPI 8 and drop support for EAPI 5. Set DUNE_PKG_NAME to PN by default. Move "Move docs to the appropriate place" block to dune-install to make dune-install now handle a list of subpackages correctly. Use ebegin and eend for dune calls instead of "|| die". Thanks to ULM for bash fixes. Signed-off-by: Maciej Barć <[email protected]>
- Loading branch information
Showing
1 changed file
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
# ML <[email protected]> | ||
# @AUTHOR: | ||
# Rafael Kitover <[email protected]> | ||
# @SUPPORTED_EAPIS: 5 6 7 | ||
# @SUPPORTED_EAPIS: 6 7 8 | ||
# @BLURB: Provides functions for installing Dune packages. | ||
# @DESCRIPTION: | ||
# Provides dependencies on dDne and OCaml and default src_compile, src_test and | ||
|
@@ -19,9 +19,10 @@ | |
# @DESCRIPTION: | ||
# Sets the actual Dune package name, if different from Gentoo package name. | ||
# Set before inheriting the eclass. | ||
: ${DUNE_PKG_NAME:-${PN}} | ||
|
||
case ${EAPI:-0} in | ||
5|6|7) ;; | ||
6|7|8) ;; | ||
*) die "${ECLASS}: EAPI ${EAPI} not supported" ;; | ||
esac | ||
|
||
|
@@ -32,7 +33,7 @@ EXPORT_FUNCTIONS src_compile src_test src_install | |
|
||
RDEPEND=">=dev-lang/ocaml-4:=[ocamlopt?] dev-ml/dune:=" | ||
case ${EAPI:-0} in | ||
5|6) | ||
6) | ||
DEPEND="${RDEPEND} dev-ml/dune" | ||
;; | ||
*) | ||
|
@@ -42,38 +43,51 @@ case ${EAPI:-0} in | |
esac | ||
|
||
dune_src_compile() { | ||
dune build @install --profile release || die | ||
ebegin "Building" | ||
dune build @install --profile release | ||
eend $? || die | ||
} | ||
|
||
dune_src_test() { | ||
dune runtest || die | ||
ebegin "Testing" | ||
dune runtest | ||
eend $? || 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" | ||
# | ||
# Example use: | ||
# @CODE | ||
# dune-install menhir menhirLib menhirSdk | ||
# @CODE | ||
dune-install() { | ||
local -a pkgs=( "${@}" ) | ||
[[ ${#pkgs[@]} -eq 0 ]] && pkgs=( "${DUNE_PKG_NAME}" ) | ||
|
||
local -a myduneopts=( | ||
--prefix="${ED%/}/usr" | ||
--libdir="${D%/}$(ocamlc -where)" | ||
--mandir="${ED%/}/usr/share/man" | ||
) | ||
local pkg | ||
for pkg ; do | ||
dune install \ | ||
--prefix="${ED%/}/usr" \ | ||
--libdir="${D%/}$(ocamlc -where)" \ | ||
--mandir="${ED%/}/usr/share/man" \ | ||
"${pkg}" || die | ||
for pkg in "${pkgs[@]}" ; do | ||
ebegin "Installing ${pkg}" | ||
dune install ${myduneopts[@]} ${pkg} | ||
eend $? || die | ||
|
||
# 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 | ||
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 | ||
dune-install ${1:-${DUNE_PKG_NAME}} | ||
} |