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

Contents of /eclass/vala.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Wed Sep 12 20:47:27 2012 UTC (21 months, 3 weeks ago) by tetromino
Branch: MAIN
Changes since 1.2: +2 -2 lines
Small stylistic fix.

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.2 2012/09/12 20:43:08 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 # @DEFAULT_UNSET
29 # @DESCRIPTION:
30 # Minimum vala API version (e.g. 0.16).
31 VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.10}
32
33 # @ECLASS-VARIABLE: VALA_MAX_API_VERSION
34 # @DEFAULT_UNSET
35 # @DESCRIPTION:
36 # Maximum vala API version (e.g. 0.18).
37 VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.18}
38
39 # @ECLASS-VARIABLE: VALA_USE_DEPEND
40 # @DEFAULT_UNSET
41 # @DESCRIPTION:
42 # USE dependencies that vala must be built with (e.g. vapigen).
43
44 # @FUNCTION: vala_api_versions
45 # @DESCRIPTION:
46 # Outputs a list of vala API versions from VALA_MAX_API_VERSION down to
47 # VALA_MIN_API_VERSION.
48 vala_api_versions() {
49 eval "echo 0.{${VALA_MAX_API_VERSION#0.}..${VALA_MIN_API_VERSION#0.}..2}"
50 }
51
52 # @FUNCTION: vala_depend
53 # @DESCRIPTION:
54 # Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to
55 # VALA_MIN_API_VERSION
56 vala_depend() {
57 local u v versions=$(vala_api_versions)
58 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
59
60 echo -n "|| ("
61 for v in ${versions}; do
62 echo -n " dev-lang/vala:${v}${u}"
63 done
64 echo " )"
65 }
66
67 # @FUNCTION: vala_best_api_version
68 # @DESCRIPTION:
69 # Returns the highest installed vala API version satisfying
70 # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
71 vala_best_api_version() {
72 local u v
73 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
74 for v in $(vala_api_versions); do
75 has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return
76 done
77 }
78
79 # @FUNCTION: vala_src_prepare
80 # @USAGE: [--vala-api-version api_version]
81 # @DESCRIPTION:
82 # Sets up the environment variables and pkgconfig files for the
83 # specified API version, or, if no version is specified, for the
84 # highest installed vala API version satisfying
85 # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
86 # Dies if called without --vala-api-version and no suitable vala
87 # version is found.
88 vala_src_prepare() {
89 local p d valafoo version
90
91 if [[ $1 = "--vala-api-version" ]]; then
92 version=$2
93 [[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
94 else
95 version=$(vala_best_api_version)
96 [[ ${version} ]] || die "No installed vala in $(vala_depend)"
97 fi
98
99 export VALAC=$(type -P valac-${version})
100
101 valafoo=$(type -P vala-gen-introspect-${version})
102 [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"
103
104 valafoo=$(type -P vapigen-${version})
105 [[ ${valafoo} ]] && export VAPIGEN="${valafoo}"
106
107 valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
108 [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"
109
110 export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"
111
112 mkdir -p "${T}/pkgconfig" || die "mkdir failed"
113 for p in libvala vapigen; do
114 for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
115 if [[ -e ${d}/${p}-${version}.pc ]]; then
116 ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
117 break
118 fi
119 done
120 done
121 : ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
122 export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
123 }

  ViewVC Help
Powered by ViewVC 1.1.20