/[gentoo-x86]/eclass/oasis.eclass
Gentoo

Contents of /eclass/oasis.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Mar 27 21:24:42 2012 UTC (2 years, 5 months ago) by aballier
Branch: MAIN
Changes since 1.1: +15 -1 lines
Add OASIS_BUILD_TESTS variable to automatically enable tests at src_configure, allowing to factorise some more code

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/oasis.eclass,v 1.1 2012/03/27 21:01:15 aballier Exp $
4
5 # @ECLASS: oasis.eclass
6 # @MAINTAINER:
7 # ml@gentoo.org
8 # @AUTHOR:
9 # Original Author: Alexis Ballier <aballier@gentoo.org>
10 # @BLURB: Provides common ebuild phases for oasis-based packages.
11 # @DESCRIPTION:
12 # Provides common ebuild phases for oasis-based packages.
13 # Most of these packages will just have to inherit the eclass, set their
14 # dependencies and the DOCS variable for base.eclass to install it and be done.
15 #
16 # It inherits multilib, findlib, eutils and base eclasses.
17 # Ebuilds using oasis.eclass must be EAPI>=3.
18
19 # @ECLASS-VARIABLE: OASIS_BUILD_DOCS
20 # @DESCRIPTION:
21 # Will make oasis_src_compile build the documentation if this variable is
22 # defined and the doc useflag is enabled.
23 # The eclass takes care of setting doc in IUSE but the ebuild should take care
24 # of the extra dependencies it may need.
25 # Set before inheriting the eclass.
26
27 # @ECLASS-VARIABLE: OASIS_BUILD_TESTS
28 # @DESCRIPTION:
29 # Will make oasis_src_configure enable building the tests if the test useflag is
30 # enabled. oasis_src_test will then run them.
31 # Note that you sometimes need to enable this for src_test to be useful,
32 # sometimes not. It has to be enabled on a per-case basis.
33 # The eclass takes care of setting test in IUSE but the ebuild should take care
34 # of the extra dependencies it may need.
35 # Set before inheriting the eclass.
36
37 inherit multilib findlib eutils base
38
39 case ${EAPI:-0} in
40 0|1|2) die "You need at least EAPI-3 to use oasis.eclass";;
41 esac
42
43 IUSE="debug +ocamlopt"
44 [ -n "${OASIS_BUILD_DOCS}" ] && IUSE="${IUSE} doc"
45 [ -n "${OASIS_BUILD_TESTS}" ] && IUSE="${IUSE} test"
46
47 RDEPEND=">=dev-lang/ocaml-3.12[ocamlopt?]"
48 DEPEND="${RDEPEND}"
49
50 # @FUNCTION: oasis_use_enable
51 # @USAGE: < useflag > < variable >
52 # @DESCRIPTION:
53 # A use_enable-like function for oasis configure variables.
54 # Outputs '--override variable (true|false)', whether useflag is enabled or
55 # not.
56 # Typical usage: $(oasis_use_enable ocamlopt is_native) as an oasis configure
57 # argument.
58 oasis_use_enable() {
59 echo "--override $2 $(usex $1 true false)"
60 }
61
62 # @FUNCTION: oasis_src_configure
63 # @DESCRIPTION:
64 # src_configure phase shared by oasis-based packages.
65 # Extra arguments may be passed via oasis_configure_opts.
66 oasis_src_configure() {
67 local testargs=""
68 [ -n "${OASIS_BUILD_TESTS}" ] && testargs="$(use_enable test tests)"
69 ocaml setup.ml -configure \
70 --prefix "${EPREFIX}/usr" \
71 --libdir "${EPREFIX}/usr/$(get_libdir)" \
72 --docdir "${EPREFIX}/usr/share/doc/${PF}/html" \
73 --destdir "${D}" \
74 $(oasis_use_enable debug debug) \
75 $(oasis_use_enable ocamlopt is_native) \
76 ${testargs} \
77 ${oasis_configure_opts} \
78 || die
79 }
80
81 # @FUNCTION: oasis_src_compile
82 # @DESCRIPTION:
83 # Builds an oasis-based package.
84 # Will build documentation if OASIS_BUILD_DOCS is defined and the doc useflag is
85 # enabled.
86 oasis_src_compile() {
87 ocaml setup.ml -build || die
88 if [ -n "${OASIS_BUILD_DOCS}" ] && use doc; then
89 ocaml setup.ml -doc || die
90 fi
91 }
92
93 # @FUNCTION: oasis_src_test
94 # @DESCRIPTION:
95 # Runs the testsuite of an oasis-based package.
96 oasis_src_test() {
97 LD_LIBRARY_PATH="${S}/_build/lib" ocaml setup.ml -test || die
98 }
99
100 # @FUNCTION: oasis_src_install
101 # @DESCRIPTION:
102 # Installs an oasis-based package.
103 # It calls base_src_install_docs, so will install documentation declared in the
104 # DOCS variable.
105 oasis_src_install() {
106 findlib_src_preinst
107 ocaml setup.ml -install || die
108 base_src_install_docs
109 }
110
111 EXPORT_FUNCTIONS src_configure src_compile src_test src_install

  ViewVC Help
Powered by ViewVC 1.1.20