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

Contents of /eclass/vala.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Thu Sep 20 04:48:26 2012 UTC (18 months, 3 weeks ago) by tetromino
Branch: MAIN
Changes since 1.3: +1 -3 lines
VALA_{MIN,MAX}_API_VERSION are not unset by default.

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/vala.eclass,v 1.3 2012/09/12 20:47:27 tetromino Exp $
4
5 # @ECLASS: vala.eclass
6 # @MAINTAINER:
7 # gnome@gentoo.org
8 # @AUTHOR:
9 # Alexandre Rostovtsev <tetromino@gentoo.org>
10 # @BLURB: Sets up the environment for using a specific version of vala.
11 # @DESCRIPTION:
12 # This eclass sets up commonly used environment variables for using a specific
13 # version of dev-lang/vala to configure and build a package. It is needed for
14 # packages whose build systems assume the existence of certain unversioned vala
15 # executables, pkgconfig files, etc., which Gentoo does not provide.
16 #
17 # This eclass provides one phase function: src_prepare.
18
19 inherit multilib
20
21 case "${EAPI:-0}" in
22 0) die "EAPI=0 is not supported" ;;
23 1) ;;
24 *) EXPORT_FUNCTIONS src_prepare ;;
25 esac
26
27 # @ECLASS-VARIABLE: VALA_MIN_API_VERSION
28 # @DESCRIPTION:
29 # Minimum vala API version (e.g. 0.16).
30 VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.10}
31
32 # @ECLASS-VARIABLE: VALA_MAX_API_VERSION
33 # @DESCRIPTION:
34 # Maximum vala API version (e.g. 0.18).
35 VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.18}
36
37 # @ECLASS-VARIABLE: VALA_USE_DEPEND
38 # @DEFAULT_UNSET
39 # @DESCRIPTION:
40 # USE dependencies that vala must be built with (e.g. vapigen).
41
42 # @FUNCTION: vala_api_versions
43 # @DESCRIPTION:
44 # Outputs a list of vala API versions from VALA_MAX_API_VERSION down to
45 # VALA_MIN_API_VERSION.
46 vala_api_versions() {
47 eval "echo 0.{${VALA_MAX_API_VERSION#0.}..${VALA_MIN_API_VERSION#0.}..2}"
48 }
49
50 # @FUNCTION: vala_depend
51 # @DESCRIPTION:
52 # Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to
53 # VALA_MIN_API_VERSION
54 vala_depend() {
55 local u v versions=$(vala_api_versions)
56 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
57
58 echo -n "|| ("
59 for v in ${versions}; do
60 echo -n " dev-lang/vala:${v}${u}"
61 done
62 echo " )"
63 }
64
65 # @FUNCTION: vala_best_api_version
66 # @DESCRIPTION:
67 # Returns the highest installed vala API version satisfying
68 # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
69 vala_best_api_version() {
70 local u v
71 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
72 for v in $(vala_api_versions); do
73 has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return
74 done
75 }
76
77 # @FUNCTION: vala_src_prepare
78 # @USAGE: [--vala-api-version api_version]
79 # @DESCRIPTION:
80 # Sets up the environment variables and pkgconfig files for the
81 # specified API version, or, if no version is specified, for the
82 # highest installed vala API version satisfying
83 # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
84 # Dies if called without --vala-api-version and no suitable vala
85 # version is found.
86 vala_src_prepare() {
87 local p d valafoo version
88
89 if [[ $1 = "--vala-api-version" ]]; then
90 version=$2
91 [[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
92 else
93 version=$(vala_best_api_version)
94 [[ ${version} ]] || die "No installed vala in $(vala_depend)"
95 fi
96
97 export VALAC=$(type -P valac-${version})
98
99 valafoo=$(type -P vala-gen-introspect-${version})
100 [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"
101
102 valafoo=$(type -P vapigen-${version})
103 [[ ${valafoo} ]] && export VAPIGEN="${valafoo}"
104
105 valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
106 [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"
107
108 export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"
109
110 mkdir -p "${T}/pkgconfig" || die "mkdir failed"
111 for p in libvala vapigen; do
112 for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
113 if [[ -e ${d}/${p}-${version}.pc ]]; then
114 ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
115 break
116 fi
117 done
118 done
119 : ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
120 export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
121 }

  ViewVC Help
Powered by ViewVC 1.1.20