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

Contents of /eclass/vala.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (hide annotations) (download)
Sun Dec 21 12:25:49 2014 UTC (5 days, 23 hours ago) by eva
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +5 -5 lines
Add support for vala 0.26

1 tetromino 1.8 # Copyright 1999-2014 Gentoo Foundation
2 tetromino 1.1 # Distributed under the terms of the GNU General Public License v2
3 eva 1.11 # $Header: $
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 pacho 1.10 # Minimum vala API version (e.g. 0.20).
30     VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.20}
31 tetromino 1.1
32     # @ECLASS-VARIABLE: VALA_MAX_API_VERSION
33     # @DESCRIPTION:
34 eva 1.11 # Maximum vala API version (e.g. 0.26).
35     VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.26}
36 tetromino 1.1
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 pacho 1.9 [[ ${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 pacho 1.10 minimal_supported_minor_version="20"
54 pacho 1.9
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 tetromino 1.1 }
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 eva 1.11 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}(+)]"
69 tetromino 1.1
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 eva 1.11 [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}(+)]"
84 tetromino 1.1 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 pacho 1.5 # @USAGE: [--ignore-use] [--vala-api-version api_version]
91 tetromino 1.1 # @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 pacho 1.5 # 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 tetromino 1.1 vala_src_prepare() {
100 pacho 1.5 local p d valafoo version ignore_use
101 tetromino 1.1
102 pacho 1.5 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 tetromino 1.1 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 tetromino 1.2 valafoo=$(type -P vala-gen-introspect-${version})
128 tetromino 1.3 [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"
129 tetromino 1.1
130 tetromino 1.2 valafoo=$(type -P vapigen-${version})
131 tetromino 1.1 [[ ${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 tetromino 1.2 if [[ -e ${d}/${p}-${version}.pc ]]; then
142     ln -s "${d}/${p}-${version}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
143 tetromino 1.1 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