public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] New eclass: oasis.eclass for oasis-based ocaml packages.
@ 2012-03-23  8:15 Alexis Ballier
  2012-03-23 15:58 ` Mike Gilbert
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Alexis Ballier @ 2012-03-23  8:15 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

Hi,

Oasis [1] is becoming the de factor standard for ocaml packages. I've
been bored of copy/pasting always the same code from ebuilds to ebuilds
and thus decided to write an eclass simplifying everything.

Attached: said eclass, a diff of a random dev-ml package I've
converted to illustrate and said random ebuild now.

Comments welcome,

Alexis.

[1] http://oasis.forge.ocamlcore.org/

[-- Attachment #2: oasis.eclass --]
[-- Type: application/octet-stream, Size: 2724 bytes --]

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: oasis.eclass
# @MAINTAINER: 
# ml@gentoo.org
# @AUTHOR:
# Original Author: Alexis Ballier <aballier@gentoo.org>
# @BLURB: Provides common ebuild phases for oasis-based packages.
# @DESCRIPTION:
# Provides common ebuild phases for oasis-based packages.
# Most of these packages will just have to inherit the eclass, set their
# dependencies and the DOCS variable for base.eclass to install it and be done.
#
# It inherits multilib, findlib and base eclasses.
# Ebuilds using oasis.eclass must be EAPI>=2.
#

inherit multilib findlib base

case ${EAPI:-0} in
	0|1) die "You need at least EAPI-2 to use oasis.eclass";;
esac

IUSE="debug +ocamlopt"

DEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]"
DEPEND="${RDEPEND}"

# @FUNCTION: oasis_use_enable
# @USAGE: < useflag > < variable >
# @DESCRIPTION:
# A use_enable-like function for oasis configure variables.
# Outputs variable=(true|false), whether useflag is enabled or not.
# Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
# argument.
oasis_use_enable() {
	    echo "--override $2 `use $1 && echo \"true\" || echo \"false\"`"
}

# @FUNCTION: oasis_src_configure
# @DESCRIPTION:
# src_configure phase shared by oasis-based ebuilds.
# Extra arguments may be passed via oasis_configure_opts.
oasis_src_configure() {
	ocaml setup.ml -configure \
		--prefix usr \
		--libdir /usr/$(get_libdir) \
		--docdir /usr/share/doc/${PF}/html \
		--destdir "${D}" \
		$(oasis_use_enable debug debug) \
		$(oasis_use_enable ocamlopt is_native) \
		${oasis_configure_opts} \
		|| die
}

# @FUNCTION: oasis_src_compile_no_doc
# @DESCRIPTION:
# Build the package.
# oasis_src_compile will build documentation if doc is in IUSE and enabled, this
# function may be used to override this behavior.
oasis_src_compile_no_doc() {
	ocaml setup.ml -build || die
}

# @FUNCTION: oasis_src_compile
# @DESCRIPTION:
# Builds an oasis-based package.
# Will build documentation if doc is in IUSE and enabled.
oasis_src_compile() {
	oasis_src_compile_no_doc
	if has doc ${IUSE} && use doc; then
		ocaml setup.ml -doc || die
	fi
}

# @FUNCTION: oasis_src_test
# @DESCRIPTION:
# Runs the testsuite of an oasis-based package.
oasis_src_test() {
	 LD_LIBRARY_PATH="${S}/_build/lib" ocaml setup.ml -test || die
}

# @FUNCTION: oasis_src_install
# @DESCRIPTION:
# Installs an oasis-based package.
# It calls base_src_install_docs, so will install documentation declared in the
# DOCS variable.
oasis_src_install() {
	findlib_src_preinst
	ocaml setup.ml -install || die
	base_src_install_docs
}

EXPORT_FUNCTIONS src_configure src_compile src_test src_install

[-- Attachment #3: fieldslib.diff --]
[-- Type: text/x-patch, Size: 1277 bytes --]

Index: fieldslib-0.1.2.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-ml/fieldslib/fieldslib-0.1.2.ebuild,v
retrieving revision 1.1
diff -u -B -r1.1 fieldslib-0.1.2.ebuild
--- fieldslib-0.1.2.ebuild	25 Jun 2011 18:56:36 -0000	1.1
+++ fieldslib-0.1.2.ebuild	23 Mar 2012 08:13:31 -0000
@@ -3,7 +3,7 @@
 # $Header: /var/cvsroot/gentoo-x86/dev-ml/fieldslib/fieldslib-0.1.2.ebuild,v 1.1 2011/06/25 18:56:36 aballier Exp $
 
 EAPI="2"
-inherit findlib multilib
+inherit oasis
 
 DESCRIPTION="Folding over record fields"
 HOMEPAGE="http://www.janestreet.com/ocaml"
@@ -12,28 +12,9 @@
 LICENSE="LGPL-2.1-linking-exception"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="debug +ocamlopt"
+IUSE=""
 
-DEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]
-	>=dev-ml/type-conv-2.3.0"
+DEPEND=">=dev-ml/type-conv-2.3.0"
 RDEPEND="${DEPEND}"
 
-oasis_use_enable() {
-	echo "--override $2 `use $1 && echo \"true\" || echo \"false\"`"
-}
-
-src_configure() {
-	./configure --prefix usr \
-		--libdir /usr/$(get_libdir) \
-		--destdir "${D}" \
-		$(oasis_use_enable debug debug) \
-		$(oasis_use_enable ocamlopt is_native) \
-		|| die
-}
-
-src_install() {
-	findlib_src_install
-
-	# install documentation
-	dodoc README || die
-}
+DOCS=( "README" )

[-- Attachment #4: fieldslib-0.1.2.ebuild --]
[-- Type: application/octet-stream, Size: 533 bytes --]

# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-ml/fieldslib/fieldslib-0.1.2.ebuild,v 1.1 2011/06/25 18:56:36 aballier Exp $

EAPI="2"
inherit oasis

DESCRIPTION="Folding over record fields"
HOMEPAGE="http://www.janestreet.com/ocaml"
SRC_URI="http://www.janestreet.com/ocaml/${P}.tar.gz"

LICENSE="LGPL-2.1-linking-exception"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

DEPEND=">=dev-ml/type-conv-2.3.0"
RDEPEND="${DEPEND}"

DOCS=( "README" )

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-03-27 21:02 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-23  8:15 [gentoo-dev] New eclass: oasis.eclass for oasis-based ocaml packages Alexis Ballier
2012-03-23 15:58 ` Mike Gilbert
2012-03-23 16:02   ` Ciaran McCreesh
2012-03-23 16:14     ` Ian Stakenvicius
2012-03-23 16:19       ` Ciaran McCreesh
2012-03-23 16:32         ` Ian Stakenvicius
2012-03-23 16:36           ` Ian Stakenvicius
2012-03-23 16:43           ` Ciaran McCreesh
2012-03-23 16:50     ` Mike Gilbert
2012-03-23 16:52       ` Ciaran McCreesh
2012-03-23 16:58         ` Mike Gilbert
2012-03-23 17:09       ` Alexandre Rostovtsev
2012-03-23 18:17         ` Alec Warner
2012-03-23 19:37           ` Ciaran McCreesh
2012-03-23 20:11             ` Alec Warner
2012-03-23 18:03   ` Alexis Ballier
2012-03-23 20:11 ` Sergei Trofimovich
2012-03-23 20:24   ` Alexis Ballier
2012-03-23 20:41     ` Alexandre Rostovtsev
2012-03-24 13:22       ` Alexis Ballier
2012-03-23 21:02     ` Sergei Trofimovich
2012-03-24 13:19       ` Alexis Ballier
2012-03-24 13:44 ` Alexis Ballier
2012-03-27 21:01   ` Alexis Ballier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox