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

Contents of /eclass/vala.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Sun Dec 2 11:26:07 2012 UTC (19 months, 1 week ago) by pacho
Branch: MAIN
Changes since 1.4: +25 -9 lines
making vala_src_prepare() into a no-op in the
common situation where vala is in IUSE and USE=-vala as discussed with the team via mail. Thanks a lot to Alexandre Rostovtsev for the work.

1 tetromino 1.1 # Copyright 1999-2012 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 pacho 1.5 # $Header: /var/cvsroot/gentoo-x86/eclass/vala.eclass,v 1.4 2012/09/20 04:48:26 tetromino Exp $
4 tetromino 1.1
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 pacho 1.5 inherit eutils multilib
20 tetromino 1.1
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 pacho 1.5 # @USAGE: [--ignore-use] [--vala-api-version api_version]
79 tetromino 1.1 # @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 pacho 1.5 # Is a no-op if called without --ignore-use when USE=-vala.
85     # Dies if the USE check is passed (or ignored) and a suitable vala
86     # version is not available.
87 tetromino 1.1 vala_src_prepare() {
88 pacho 1.5 local p d valafoo version ignore_use
89 tetromino 1.1
90 pacho 1.5 while [[ $1 ]]; do
91     case $1 in
92     "--ignore-use" )
93     ignore_use=1 ;;
94     "--vala-api-version" )
95     shift
96     version=$1
97     [[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
98     esac
99     shift
100     done
101    
102     if [[ -z ${ignore_use} ]]; then
103     in_iuse vala && ! use vala && return 0
104     fi
105    
106     if [[ ${version} ]]; then
107     has_version "dev-lang/vala:${version}" || die "No installed vala:${version}"
108 tetromino 1.1 else
109     version=$(vala_best_api_version)
110     [[ ${version} ]] || die "No installed vala in $(vala_depend)"
111     fi
112    
113     export VALAC=$(type -P valac-${version})
114    
115 tetromino 1.2 valafoo=$(type -P vala-gen-introspect-${version})
116 tetromino 1.3 [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"
117 tetromino 1.1
118 tetromino 1.2 valafoo=$(type -P vapigen-${version})
119 tetromino 1.1 [[ ${valafoo} ]] && export VAPIGEN="${valafoo}"
120    
121     valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
122     [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"
123    
124     export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"
125    
126     mkdir -p "${T}/pkgconfig" || die "mkdir failed"
127     for p in libvala vapigen; do
128     for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
129 tetromino 1.2 if [[ -e ${d}/${p}-${version}.pc ]]; then
130     ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
131 tetromino 1.1 break
132     fi
133     done
134     done
135     : ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
136     export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
137     }

  ViewVC Help
Powered by ViewVC 1.1.20