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

Contents of /eclass/vala.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Tue Nov 11 11:00:24 2014 UTC (5 weeks, 4 days ago) by pacho
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +4 -4 lines
0.20 is our new lower version

1 # Copyright 1999-2014 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.9 2014/10/30 13:21:25 pacho 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 eutils 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.20).
30 VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.20}
31
32 # @ECLASS-VARIABLE: VALA_MAX_API_VERSION
33 # @DESCRIPTION:
34 # Maximum vala API version (e.g. 0.22).
35 VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.24}
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 [[ ${VALA_MIN_API_VERSION} =~ ^0\.[[:digit:]]+$ ]] || die "Invalid syntax of VALA_MIN_API_VERSION"
48 [[ ${VALA_MAX_API_VERSION} =~ ^0\.[[:digit:]]+$ ]] || die "Invalid syntax of VALA_MAX_API_VERSION"
49
50 local minimal_supported_minor_version minor_version
51
52 # Dependency atoms are not generated for Vala versions older than 0.${minimal_supported_minor_version}.
53 minimal_supported_minor_version="20"
54
55 for ((minor_version = ${VALA_MAX_API_VERSION#*.}; minor_version >= ${VALA_MIN_API_VERSION#*.}; minor_version = minor_version - 2)); do
56 if ((minor_version >= minimal_supported_minor_version)); then
57 echo "0.${minor_version}"
58 fi
59 done
60 }
61
62 # @FUNCTION: vala_depend
63 # @DESCRIPTION:
64 # Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to
65 # VALA_MIN_API_VERSION
66 vala_depend() {
67 local u v versions=$(vala_api_versions)
68 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
69
70 echo -n "|| ("
71 for v in ${versions}; do
72 echo -n " dev-lang/vala:${v}${u}"
73 done
74 echo " )"
75 }
76
77 # @FUNCTION: vala_best_api_version
78 # @DESCRIPTION:
79 # Returns the highest installed vala API version satisfying
80 # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
81 vala_best_api_version() {
82 local u v
83 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
84 for v in $(vala_api_versions); do
85 has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return
86 done
87 }
88
89 # @FUNCTION: vala_src_prepare
90 # @USAGE: [--ignore-use] [--vala-api-version api_version]
91 # @DESCRIPTION:
92 # Sets up the environment variables and pkgconfig files for the
93 # specified API version, or, if no version is specified, for the
94 # highest installed vala API version satisfying
95 # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
96 # Is a no-op if called without --ignore-use when USE=-vala.
97 # Dies if the USE check is passed (or ignored) and a suitable vala
98 # version is not available.
99 vala_src_prepare() {
100 local p d valafoo version ignore_use
101
102 while [[ $1 ]]; do
103 case $1 in
104 "--ignore-use" )
105 ignore_use=1 ;;
106 "--vala-api-version" )
107 shift
108 version=$1
109 [[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
110 esac
111 shift
112 done
113
114 if [[ -z ${ignore_use} ]]; then
115 in_iuse vala && ! use vala && return 0
116 fi
117
118 if [[ ${version} ]]; then
119 has_version "dev-lang/vala:${version}" || die "No installed vala:${version}"
120 else
121 version=$(vala_best_api_version)
122 [[ ${version} ]] || die "No installed vala in $(vala_depend)"
123 fi
124
125 export VALAC=$(type -P valac-${version})
126
127 valafoo=$(type -P vala-gen-introspect-${version})
128 [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"
129
130 valafoo=$(type -P vapigen-${version})
131 [[ ${valafoo} ]] && export VAPIGEN="${valafoo}"
132
133 valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
134 [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"
135
136 export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"
137
138 mkdir -p "${T}/pkgconfig" || die "mkdir failed"
139 for p in libvala vapigen; do
140 for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
141 if [[ -e ${d}/${p}-${version}.pc ]]; then
142 ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
143 break
144 fi
145 done
146 done
147 : ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
148 export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
149 }

  ViewVC Help
Powered by ViewVC 1.1.20