Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Gentoo: Dev

[RFC] new vala.eclass

 

 

Gentoo dev RSS feed   Index | Next | Previous | View Threaded


tetromino at gentoo

Aug 25, 2012, 9:09 AM

Post #1 of 18 (523 views)
Permalink
[RFC] new vala.eclass

Here's a proposed new eclass to make it less painful to build vala
bindings in the new, vala-0.18.x, vapigen.m4-using era. See
https://bugzilla.gnome.org/show_bug.cgi?id=682202 for why messing around
with PKG_CONFIG_PATH is unfortunately needed for vapigen.m4-using
packages from gnome-3.6 such as librsvg-2.36.2, networkmanager-0.9.6.0,
libsecret-0.9.x, libgnome-keyring-3.6.x, accountsservice-0.6.24, etc.


# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: vala.eclass
# @MAINTAINER:
# gnome [at] gentoo
# @AUTHOR:
# Alexandre Rostovtsev <tetromino [at] gentoo>
# @BLURB: Sets up the environment for using a specific version of vala.
# @DESCRIPTION:
# This eclass sets up commonly used environment variables for using a specific
# version of dev-lang/vala to configure and build a package. It is needed for
# packages whose build systems assume the existence of certain unversioned vala
# executables, pkgconfig files, etc., which Gentoo does not provide.
#
# This eclass provides one phase function: pkg_setup.

inherit multilib

case "${EAPI:-0}" in
0|1|2)
die "EAPI=${EAPI} is not supported"
;;
*)
EXPORT_FUNCTIONS pkg_setup
;;
esac

# @ECLASS-VARIABLE: VALA_API_VERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Vala API version (e.g. 0.16).

# @FUNCTION: vala_pkg_setup
# @DESCRIPTION:
# Sets up the environment variables and pkgconfig files for $VALA_API_VERSION.
vala_pkg_setup() {
if [[ -z "${VALA_API_VERSION}" ]]; then
die "VALA_API_VERSION not set"
fi

export VALAC=$(type -P valac-${VALA_API_VERSION})
export VALA=$(type -P vala-${VALA_API_VERSION})
export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${VALA_API_VERSION})
export VAPIGEN="$(type -P vapigen-${VALA_API_VERSION})"
export VAPIGEN_MAKEFILE="${EPREFIX}/usr/share/vala-${VALA_API_VERSION}/Makefile.vapigen"
export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"

if ! [[ -d "${T}/pkgconfig" ]]; then
mkdir "${T}/pkgconfig" || die "mkdir failed"
fi
local p
for p in libvala vapigen; do
local d
for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
if [[ -e "${d}/${p}-${VALA_API_VERSION}.pc" ]]; then
ln -s "${d}/${p}-${VALA_API_VERSION}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
break
fi
done
done
: ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
}


tomas.chvatal at gmail

Aug 25, 2012, 10:25 AM

Post #2 of 18 (520 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

2012/8/25 Alexandre Rostovtsev <tetromino [at] gentoo>:
Hi man,

*snip*
>
> case "${EAPI:-0}" in
> 0|1|2)
> die "EAPI=${EAPI} is not supported"
> ;;
> *)
> EXPORT_FUNCTIONS pkg_setup
> ;;
> esac

Any reson for not supporting ALL known eapis?

*snip*
> if [[ -z "${VALA_API_VERSION}" ]]; then
> die "VALA_API_VERSION not set"
> fi
You can use the && instead of conditional as you have longer lines in
the file anyway

*snip*
> if ! [[ -d "${T}/pkgconfig" ]]; then
> mkdir "${T}/pkgconfig" || die "mkdir failed"
> fi
Same as above

*snip*
> local p
You should put the var defs on the top, I know this aint ansi C but i
found that we tend to loose the variable declarations in long run
otherwise.

Cheers

Tom


flameeyes at flameeyes

Aug 25, 2012, 11:29 AM

Post #3 of 18 (515 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On 25/08/2012 10:25, Tomáš Chvátal wrote:
>> > if ! [[ -d "${T}/pkgconfig" ]]; then
>> > mkdir "${T}/pkgconfig" || die "mkdir failed"
>> > fi
> Same as above

Even better use mkdir -p.

--
Diego Elio Pettenò — Flameeyes
flameeyes [at] flameeyes — http://blog.flameeyes.eu/


tetromino at gentoo

Aug 25, 2012, 2:04 PM

Post #4 of 18 (516 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

Updated version, incorporating suggestions by Tomáš and Diego, and
fixing VAPIGEN_MAKEFILE to work with dev-lang/vala-common.

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: vala.eclass
# @MAINTAINER:
# gnome [at] gentoo
# @AUTHOR:
# Alexandre Rostovtsev <tetromino [at] gentoo>
# @BLURB: Sets up the environment for using a specific version of vala.
# @DESCRIPTION:
# This eclass sets up commonly used environment variables for using a specific
# version of dev-lang/vala to configure and build a package. It is needed for
# packages whose build systems assume the existence of certain unversioned vala
# executables, pkgconfig files, etc., which Gentoo does not provide.
#
# This eclass provides one phase function: pkg_setup.

inherit multilib

EXPORT_FUNCTIONS pkg_setup

# @ECLASS-VARIABLE: VALA_API_VERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Vala API version (e.g. 0.16).

# @FUNCTION: vala_pkg_setup
# @DESCRIPTION:
# Sets up the environment variables and pkgconfig files for $VALA_API_VERSION.
vala_pkg_setup() {
local p d

[[ -n "${VALA_API_VERSION}" ]] || die "VALA_API_VERSION not set"

export VALAC=$(type -P valac-${VALA_API_VERSION})
export VALA=$(type -P vala-${VALA_API_VERSION})
export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${VALA_API_VERSION})
export VAPIGEN="$(type -P vapigen-${VALA_API_VERSION})"
export VAPIGEN_MAKEFILE="${EPREFIX}/usr/share/vala/Makefile.vapigen"
export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"

mkdir -p "${T}/pkgconfig" || die "mkdir failed"
for p in libvala vapigen; do
for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
if [[ -e "${d}/${p}-${VALA_API_VERSION}.pc" ]]; then
ln -s "${d}/${p}-${VALA_API_VERSION}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
break
fi
done
done
: ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
}


ulm at gentoo

Aug 25, 2012, 2:45 PM

Post #5 of 18 (507 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

>>>>> On Sat, 25 Aug 2012, Alexandre Rostovtsev wrote:

> export VALAC=$(type -P valac-${VALA_API_VERSION})
> export VALA=$(type -P vala-${VALA_API_VERSION})
> export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${VALA_API_VERSION})
> export VAPIGEN="$(type -P vapigen-${VALA_API_VERSION})"

Is it guaranteed that these commands are present at pkg_setup time?

Ulrich


tetromino at gentoo

Aug 25, 2012, 11:59 PM

Post #6 of 18 (508 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sat, 2012-08-25 at 23:45 +0200, Ulrich Mueller wrote:
> >>>>> On Sat, 25 Aug 2012, Alexandre Rostovtsev wrote:
>
> > export VALAC=$(type -P valac-${VALA_API_VERSION})
> > export VALA=$(type -P vala-${VALA_API_VERSION})
> > export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${VALA_API_VERSION})
> > export VAPIGEN="$(type -P vapigen-${VALA_API_VERSION})"
>
> Is it guaranteed that these commands are present at pkg_setup time?

I am assuming that the ebuild writer has added the correct vala
dependency to DEPEND. Maybe something like this:

VALA_API_VERSION=0.16
DEPEND="vala? ( >=dev-lang/vala-0.16.1:${VALA_API_VERSION}[vapigen] )"

In which case, the vala commands that are pulled in via DEPEND will be
(unless I am completely wrong about how pkg_config works) available
during pkg_config.

Commands that are not pulled in via DEPEND of course might not be
available, in which case VALAC or VAPIGEN etc. would be set to the empty
string by vala_pkg_config.

For all vala-using build systems that I have seen, this should not break
anything.

However, for a cleaner and safer environment, I could do the following:

local path

path=$(type -P valac-${VALA_API_VERSION})
[[ -n "${path}" ]] && VALAC="${path}"

path=$(type -P vala-${VALA_API_VERSION})
[[ -n "${path}" ]] && VALA="${path}"

path=$(type -P vala-gen-introspect-${VALA_API_VERSION})
[[ -n "${path}" ]] && VALA_GEN_INTROSPECT="${path}"

path=$(type -P vapigen-${VALA_API_VERSION})
[[ -n "${path}" ]] && VAPIGEN="${path}"


tetromino at gentoo

Aug 26, 2012, 12:08 AM

Post #7 of 18 (511 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sun, 2012-08-26 at 02:59 -0400, Alexandre Rostovtsev wrote:
> path=$(type -P valac-${VALA_API_VERSION})
> [[ -n "${path}" ]] && VALAC="${path}"
>
> path=$(type -P vala-${VALA_API_VERSION})
> [[ -n "${path}" ]] && VALA="${path}"
>
> path=$(type -P vala-gen-introspect-${VALA_API_VERSION})
> [[ -n "${path}" ]] && VALA_GEN_INTROSPECT="${path}"
>
> path=$(type -P vapigen-${VALA_API_VERSION})
> [[ -n "${path}" ]] && VAPIGEN="${path}"

Sorry, meant

path=$(type -P valac-${VALA_API_VERSION})
[[ -n "${path}" ]] && export VALAC="${path}"

path=$(type -P vala-${VALA_API_VERSION})
[[ -n "${path}" ]] && export VALA="${path}"

path=$(type -P vala-gen-introspect-${VALA_API_VERSION})
[[ -n "${path}" ]] && export VALA_GEN_INTROSPECT="${path}"

path=$(type -P vapigen-${VALA_API_VERSION})
[[ -n "${path}" ]] && export VAPIGEN="${path}"


tetromino at gentoo

Aug 26, 2012, 12:20 AM

Post #8 of 18 (507 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sun, 2012-08-26 at 02:59 -0400, Alexandre Rostovtsev wrote:
> In which case, the vala commands that are pulled in via DEPEND will be
> (unless I am completely wrong about how pkg_config works) available
> during pkg_config.
>
> Commands that are not pulled in via DEPEND of course might not be
> available, in which case VALAC or VAPIGEN etc. would be set to the empty
> string by vala_pkg_config.

s/pkg_config/pkg_setup/g


1i5t5.duncan at cox

Aug 26, 2012, 3:32 PM

Post #9 of 18 (507 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

Alexandre Rostovtsev posted on Sat, 25 Aug 2012 17:04:36 -0400 as
excerpted:

> [[ -n "${VALA_API_VERSION}" ]] || die "VALA_API_VERSION not set"

It's just style, but...

1) [[ ]] manages non-word characters (whitespace, etc) hidden behind
variables, so quotes are only necessary if they appear in string-
literals, not the case here. I know eliminating the quotes is gentoo
policy as I've seen it suggested many times before.

2) Gentoo policy regarding implied -n? I know gentoo policy prefers {}
cuddled varnames to make the varname explicit, but does it prefer
explicit -n as well, since that's implicit test behavior and thus does
not need to be explicitly specified?

To my way of thinking [[ ${var} ]] is even clearer than [[ -n ${var} ]]
since there's only one way to interpret the former and I have to
correctly parse the -n (as opposed to -any-other-letter) given the
latter. They're even listed together in bash's "help test" output, so
are considered to have identical behavior to the point of being listed
together by bash itself.

Incorporating both suggestions:

[[ ${VALA_API_VERSION} ]] || die "VALA_API_VERSION not set"

But regardless of #2, definitely eliminate the quotes inside the [[ ]],
as I've seen that suggested numerous times in other cases. The better
quote handling regarding variables is in fact one of the reasons the
[[ ]] form is preferred to the POSIX compliant [ ] form.

--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman


zmedico at gentoo

Aug 26, 2012, 3:45 PM

Post #10 of 18 (509 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On 08/25/2012 11:59 PM, Alexandre Rostovtsev wrote:
> On Sat, 2012-08-25 at 23:45 +0200, Ulrich Mueller wrote:
>>>>>>> On Sat, 25 Aug 2012, Alexandre Rostovtsev wrote:
>>
>>> export VALAC=$(type -P valac-${VALA_API_VERSION})
>>> export VALA=$(type -P vala-${VALA_API_VERSION})
>>> export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${VALA_API_VERSION})
>>> export VAPIGEN="$(type -P vapigen-${VALA_API_VERSION})"
>>
>> Is it guaranteed that these commands are present at pkg_setup time?
>
> I am assuming that the ebuild writer has added the correct vala
> dependency to DEPEND. Maybe something like this:

Note that pkg_setup is called for binary packages too, which means that
DEPEND may not necessarily be installed. In EAPI 4 you can check the
MERGE_TYPE variable which can have a value of binary, source, orbuildonly.
--
Thanks,
Zac


tetromino at gentoo

Aug 26, 2012, 4:43 PM

Post #11 of 18 (507 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sun, 2012-08-26 at 15:45 -0700, Zac Medico wrote:
> Note that pkg_setup is called for binary packages too, which means that
> DEPEND may not necessarily be installed. In EAPI 4 you can check the
> MERGE_TYPE variable which can have a value of binary, source, orbuildonly.

The variables that vala_pkg_setup sets are needed only at build time.


tetromino at gentoo

Aug 26, 2012, 6:20 PM

Post #12 of 18 (508 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

Second update, incorporating suggestions by Ulrich and Duncan.

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: vala.eclass
# @MAINTAINER:
# gnome [at] gentoo
# @AUTHOR:
# Alexandre Rostovtsev <tetromino [at] gentoo>
# @BLURB: Sets up the environment for using a specific version of vala.
# @DESCRIPTION:
# This eclass sets up commonly used environment variables for using a specific
# version of dev-lang/vala to configure and build a package. It is needed for
# packages whose build systems assume the existence of certain unversioned vala
# executables, pkgconfig files, etc., which Gentoo does not provide.
#
# This eclass provides one phase function: pkg_setup.

inherit multilib

EXPORT_FUNCTIONS pkg_setup

# @ECLASS-VARIABLE: VALA_API_VERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Vala API version (e.g. 0.16).

# @FUNCTION: vala_pkg_setup
# @DESCRIPTION:
# Sets up the environment variables and pkgconfig files for $VALA_API_VERSION.
vala_pkg_setup() {
local p d valafoo

[[ ${VALA_API_VERSION} ]] || die "VALA_API_VERSION not set"

valafoo=$(type -P valac-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALAC="${valafoo}"

valafoo=$(type -P vala-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALA="${valafoo}"

valafoo=$(type -P vala-gen-introspect-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"

valafoo=$(type -P vapigen-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VAPIGEN="${valafoo}"

valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
[[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"

export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"

mkdir -p "${T}/pkgconfig" || die "mkdir failed"
for p in libvala vapigen; do
for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
if [[ -e ${d}/${p}-${VALA_API_VERSION}.pc ]]; then
ln -s "${d}/${p}-${VALA_API_VERSION}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
break
fi
done
done
: ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
}


aballier at gentoo

Aug 26, 2012, 7:45 PM

Post #13 of 18 (509 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sun, 26 Aug 2012 19:43:32 -0400
Alexandre Rostovtsev <tetromino [at] gentoo> wrote:

> On Sun, 2012-08-26 at 15:45 -0700, Zac Medico wrote:
> > Note that pkg_setup is called for binary packages too, which means
> > that DEPEND may not necessarily be installed. In EAPI 4 you can
> > check the MERGE_TYPE variable which can have a value of binary,
> > source, orbuildonly.
>
> The variables that vala_pkg_setup sets are needed only at build time.

so it should be vala_src_prepare / unpack instead ?
definitely not anything pkg_* imho


tetromino at gentoo

Aug 26, 2012, 9:45 PM

Post #14 of 18 (508 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sun, 2012-08-26 at 22:45 -0400, Alexis Ballier wrote:
> On Sun, 26 Aug 2012 19:43:32 -0400
> Alexandre Rostovtsev <tetromino [at] gentoo> wrote:
> > The variables that vala_pkg_setup sets are needed only at build time.
>
> so it should be vala_src_prepare / unpack instead ?
> definitely not anything pkg_* imho

IMHO src_prepare or src_unpack would be misleading because the function
does not modify the package's source and has nothing to do with
unpacking. It's not an unusual idiom to set various environment
variables in pkg_setup even if those variables are relevant only at
build time; gnome-extra/zeitgeist and xfce4-vala/xfce4-vala are typical
examples that already export VALAC in their pkg_setup().


aballier at gentoo

Aug 27, 2012, 5:19 AM

Post #15 of 18 (498 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Mon, 27 Aug 2012 00:45:45 -0400
Alexandre Rostovtsev <tetromino [at] gentoo> wrote:

> On Sun, 2012-08-26 at 22:45 -0400, Alexis Ballier wrote:
> > On Sun, 26 Aug 2012 19:43:32 -0400
> > Alexandre Rostovtsev <tetromino [at] gentoo> wrote:
> > > The variables that vala_pkg_setup sets are needed only at build
> > > time.
> >
> > so it should be vala_src_prepare / unpack instead ?
> > definitely not anything pkg_* imho
>
> IMHO src_prepare or src_unpack would be misleading because the
> function does not modify the package's source and has nothing to do
> with unpacking.

it creates files as far as i understood the code;
the point of vala.eclass is to prepare the environment for building
the package, right ?

you can probably get a valid point for a src_setup phase in a
future eapi, but so far with current eapi, src_prepare seems the best
choice

> It's not an unusual idiom to set various environment
> variables in pkg_setup even if those variables are relevant only at
> build time; gnome-extra/zeitgeist and xfce4-vala/xfce4-vala are
> typical examples that already export VALAC in their pkg_setup().

lots of bad examples does not make it good :)
this is just wasted cpu cycles for binpkgs, moreover these two examples
only set a variable and call type -P; the eclass does set a couple
more of variables and writes to $T


anyway its your call, but given that the eclass is only useful for
building it seems bad practices to put its code in a pkg_ phase.


tetromino at gentoo

Aug 27, 2012, 6:21 AM

Post #16 of 18 (496 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

Third update; Alexis made a convincing argument that vala_pkg_setup
should be changed to vala_src_prepare.

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: vala.eclass
# @MAINTAINER:
# gnome [at] gentoo
# @AUTHOR:
# Alexandre Rostovtsev <tetromino [at] gentoo>
# @BLURB: Sets up the environment for using a specific version of vala.
# @DESCRIPTION:
# This eclass sets up commonly used environment variables for using a specific
# version of dev-lang/vala to configure and build a package. It is needed for
# packages whose build systems assume the existence of certain unversioned vala
# executables, pkgconfig files, etc., which Gentoo does not provide.
#
# This eclass provides one phase function: src_prepare.

inherit multilib

case "${EAPI:-0}" in
0|1)
;;
*)
EXPORT_FUNCTIONS src_prepare
;;
esac

# @ECLASS-VARIABLE: VALA_API_VERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Vala API version (e.g. 0.16).

# @FUNCTION: vala_src_prepare
# @DESCRIPTION:
# Sets up the environment variables and pkgconfig files for $VALA_API_VERSION.
vala_src_prepare() {
local p d valafoo

[[ ${VALA_API_VERSION} ]] || die "VALA_API_VERSION not set"

valafoo=$(type -P valac-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALAC="${valafoo}"

valafoo=$(type -P vala-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALA="${valafoo}"

valafoo=$(type -P vala-gen-introspect-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALA_GEN_INTROSPECT="${valafoo}"

valafoo=$(type -P vapigen-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VAPIGEN="${valafoo}"

valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
[[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"

export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"

mkdir -p "${T}/pkgconfig" || die "mkdir failed"
for p in libvala vapigen; do
for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
if [[ -e ${d}/${p}-${VALA_API_VERSION}.pc ]]; then
ln -s "${d}/${p}-${VALA_API_VERSION}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
break
fi
done
done
: ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
}


tetromino at gentoo

Sep 9, 2012, 7:09 PM

Post #17 of 18 (456 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

Revised proposal with suggestions from Nirbheek. VALA_API_VERSION has
been split into max and min to make it easier for packages to depend on
a range of vala slots.

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: vala.eclass
# @MAINTAINER:
# gnome [at] gentoo
# @AUTHOR:
# Alexandre Rostovtsev <tetromino [at] gentoo>
# @BLURB: Sets up the environment for using a specific version of vala.
# @DESCRIPTION:
# This eclass sets up commonly used environment variables for using a specific
# version of dev-lang/vala to configure and build a package. It is needed for
# packages whose build systems assume the existence of certain unversioned vala
# executables, pkgconfig files, etc., which Gentoo does not provide.
#
# This eclass provides one phase function: src_prepare.

inherit multilib

case "${EAPI:-0}" in
0) die "EAPI=0 is not supported" ;;
1) ;;
*) EXPORT_FUNCTIONS src_prepare ;;
esac

# @ECLASS-VARIABLE: VALA_MIN_API_VERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Minimum vala API version (e.g. 0.16).
VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.10}

# @ECLASS-VARIABLE: VALA_MAX_API_VERSION
# @DEFAULT_UNSET
# @DESCRIPTION:
# Maximum vala API version (e.g. 0.18).
VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.18}

# @ECLASS-VARIABLE: VALA_USE_DEPEND
# @DEFAULT_UNSET
# @DESCRIPTION:
# USE dependencies that vala must be built with (e.g. vapigen).

# @FUNCTION: vala_api_versions
# @DESCRIPTION:
# Outputs a list of vala API versions from VALA_MAX_API_VERSION down to
# VALA_MIN_API_VERSION.
vala_api_versions() {
eval "echo 0.{${VALA_MAX_API_VERSION#0.}..${VALA_MIN_API_VERSION#0.}..2}"
}

# @FUNCTION: vala_depend
# @DESCRIPTION:
# Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to
# VALA_MIN_API_VERSION
vala_depend() {
local u v versions=$(vala_api_versions)
[[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"

echo -n "|| ("
for v in ${versions}; do
echo -n " dev-lang/vala:${v}${u}"
done
echo " )"
}

# @FUNCTION: vala_best_api_version
# @DESCRIPTION:
# Returns the highest installed vala API version satisfying
# VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
vala_best_api_version() {
local u v
[[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
for v in $(vala_api_versions); do
has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return
done
}

# @FUNCTION: vala_src_prepare
# @USAGE: [--vala-api-version api_version]
# @DESCRIPTION:
# Sets up the environment variables and pkgconfig files for the
# specified API version, or, if no version is specified, for the
# highest installed vala API version satisfying
# VALA_MIN_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
vala_src_prepare() {
local p d valafoo version

if [[ $1 = "--vala-api-version" ]]; then
version=$2
[[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
else
version=$(vala_best_api_version)
[[ ${version} ]] || die "No installed vala in $(vala_depend)"
fi

export VALAC=$(type -P valac-${version})

valafoo=$(type -P vala-gen-introspect-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${version})

valafoo=$(type -P vapigen-${VALA_API_VERSION})
[[ ${valafoo} ]] && export VAPIGEN="${valafoo}"

valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
[[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"

export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"

mkdir -p "${T}/pkgconfig" || die "mkdir failed"
for p in libvala vapigen; do
for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
if [[ -e ${d}/${p}-${VALA_API_VERSION}.pc ]]; then
ln -s "${d}/${p}-${VALA_API_VERSION}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
break
fi
done
done
: ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
}


tetromino at gentoo

Sep 12, 2012, 1:24 PM

Post #18 of 18 (447 views)
Permalink
Re: [RFC] new vala.eclass [In reply to]

On Sun, 2012-09-09 at 22:09 -0400, Alexandre Rostovtsev wrote:
> Revised proposal with suggestions from Nirbheek. VALA_API_VERSION has
> been split into max and min to make it easier for packages to depend on
> a range of vala slots.
>
> # Copyright 1999-2012 Gentoo Foundation
> # Distributed under the terms of the GNU General Public License v2
> # $Header: $
>
> # @ECLASS: vala.eclass
> # @MAINTAINER:
> # gnome [at] gentoo
> # @AUTHOR:
> # Alexandre Rostovtsev <tetromino [at] gentoo>
> # @BLURB: Sets up the environment for using a specific version of vala.
> # @DESCRIPTION:
> # This eclass sets up commonly used environment variables for using a specific
> # version of dev-lang/vala to configure and build a package. It is needed for
> # packages whose build systems assume the existence of certain unversioned vala
> # executables, pkgconfig files, etc., which Gentoo does not provide.
> #
> # This eclass provides one phase function: src_prepare.
>
> inherit multilib
>
> case "${EAPI:-0}" in
> 0) die "EAPI=0 is not supported" ;;
> 1) ;;
> *) EXPORT_FUNCTIONS src_prepare ;;
> esac
>
> # @ECLASS-VARIABLE: VALA_MIN_API_VERSION
> # @DEFAULT_UNSET
> # @DESCRIPTION:
> # Minimum vala API version (e.g. 0.16).
> VALA_MIN_API_VERSION=${VALA_MIN_API_VERSION:-0.10}
>
> # @ECLASS-VARIABLE: VALA_MAX_API_VERSION
> # @DEFAULT_UNSET
> # @DESCRIPTION:
> # Maximum vala API version (e.g. 0.18).
> VALA_MAX_API_VERSION=${VALA_MAX_API_VERSION:-0.18}
>
> # @ECLASS-VARIABLE: VALA_USE_DEPEND
> # @DEFAULT_UNSET
> # @DESCRIPTION:
> # USE dependencies that vala must be built with (e.g. vapigen).
>
> # @FUNCTION: vala_api_versions
> # @DESCRIPTION:
> # Outputs a list of vala API versions from VALA_MAX_API_VERSION down to
> # VALA_MIN_API_VERSION.
> vala_api_versions() {
> eval "echo 0.{${VALA_MAX_API_VERSION#0.}..${VALA_MIN_API_VERSION#0.}..2}"
> }
>
> # @FUNCTION: vala_depend
> # @DESCRIPTION:
> # Outputs a ||-dependency string on vala from VALA_MAX_API_VERSION down to
> # VALA_MIN_API_VERSION
> vala_depend() {
> local u v versions=$(vala_api_versions)
> [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
>
> echo -n "|| ("
> for v in ${versions}; do
> echo -n " dev-lang/vala:${v}${u}"
> done
> echo " )"
> }
>
> # @FUNCTION: vala_best_api_version
> # @DESCRIPTION:
> # Returns the highest installed vala API version satisfying
> # VALA_MAX_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
> vala_best_api_version() {
> local u v
> [[ ${VALA_USE_DEPEND} ]] && u="[${VALA_USE_DEPEND}]"
> for v in $(vala_api_versions); do
> has_version "dev-lang/vala:${v}${u}" && echo "${v}" && return
> done
> }
>
> # @FUNCTION: vala_src_prepare
> # @USAGE: [--vala-api-version api_version]
> # @DESCRIPTION:
> # Sets up the environment variables and pkgconfig files for the
> # specified API version, or, if no version is specified, for the
> # highest installed vala API version satisfying
> # VALA_MIN_API_VERSION, VALA_MIN_API_VERSION, and VALA_USE_DEPEND.
> vala_src_prepare() {
> local p d valafoo version
>
> if [[ $1 = "--vala-api-version" ]]; then
> version=$2
> [[ ${version} ]] || die "'--vala-api-version' option requires API version parameter."
> else
> version=$(vala_best_api_version)
> [[ ${version} ]] || die "No installed vala in $(vala_depend)"
> fi
>
> export VALAC=$(type -P valac-${version})
>
> valafoo=$(type -P vala-gen-introspect-${VALA_API_VERSION})
> [[ ${valafoo} ]] && export VALA_GEN_INTROSPECT=$(type -P vala-gen-introspect-${version})
>
> valafoo=$(type -P vapigen-${VALA_API_VERSION})
> [[ ${valafoo} ]] && export VAPIGEN="${valafoo}"
>
> valafoo="${EPREFIX}/usr/share/vala/Makefile.vapigen"
> [[ -e ${valafoo} ]] && export VAPIGEN_MAKEFILE="${valafoo}"
>
> export VAPIGEN_VAPIDIR="${EPREFIX}/usr/share/vala/vapi"
>
> mkdir -p "${T}/pkgconfig" || die "mkdir failed"
> for p in libvala vapigen; do
> for d in "${EPREFIX}/usr/$(get_libdir)/pkgconfig" "${EPREFIX}/usr/share/pkgconfig"; do
> if [[ -e ${d}/${p}-${VALA_API_VERSION}.pc ]]; then
> ln -s "${d}/${p}-${VALA_API_VERSION}.pc" "${T}/pkgconfig/${p}.pc" || die "ln failed"
> break
> fi
> done
> done
> : ${PKG_CONFIG_PATH:="${EPREFIX}/usr/$(get_libdir)/pkgconfig:${EPREFIX}/usr/share/pkgconfig"}
> export PKG_CONFIG_PATH="${T}/pkgconfig:${PKG_CONFIG_PATH}"
> }

Now in portage.

Gentoo dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.