summaryrefslogtreecommitdiff
blob: 39b192f16a3ce9fe17576b2a87eef0bd0112ba2c (plain)
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
69
70
71
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=5

inherit findlib

DESCRIPTION="Map OCaml arrays onto C-like structs"
HOMEPAGE="https://github.com/mirage/ocaml-cstruct https://mirage.io"
SRC_URI="https://github.com/mirage/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="ISC"
SLOT="0/${PV}"
KEYWORDS="~amd64"
IUSE="async +lwt +ppx test"

RDEPEND="
	async? (
		dev-ml/async_kernel:=
		dev-ml/async_unix:=
		dev-ml/core_kernel:=
	)
	lwt? ( dev-ml/lwt:= )
	ppx? (
		dev-ml/ppx_tools:=
		dev-ml/ocaml-migrate-parsetree:=
		>=dev-ml/ppx_tools_versioned-5.0.1:=
	)
	>=dev-lang/ocaml-4.01:=
	dev-ml/ocplib-endian:=
	dev-ml/sexplib:=
	dev-ml/type-conv:=
"
DEPEND="
	dev-ml/jbuilder
	dev-ml/opam
	test? ( dev-ml/ounit )
	${RDEPEND}
"

get_targets() {
	local tgt="cstruct,cstruct-unix"
	use lwt && tgt+=",cstruct-lwt"
	use async && tgt+=",cstruct-async"
	use ppx && tgt+=",ppx_cstruct"
	echo "${tgt}"
}

src_compile() {
	jbuilder build -p $(get_targets) || die
}

src_test() {
	jbuilder runtest -p $(get_targets) || die
}

oinstall() {
	opam-installer -i \
		--prefix="${ED}/usr" \
		--libdir="${D}/$(ocamlc -where)" \
		--docdir="${ED}/usr/share/doc/${PF}" \
		${1}.install || die
}

src_install() {
	oinstall cstruct
	oinstall cstruct-unix
	use lwt && oinstall cstruct-lwt
	use async && oinstall cstruct-async
	use ppx && oinstall ppx_cstruct
}