public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [RFC] new vala.eclass
@ 2012-08-25 16:09 Alexandre Rostovtsev
  2012-08-25 17:25 ` Tomáš Chvátal
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-25 16:09 UTC (permalink / raw
  To: gentoo-dev

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@gentoo.org
# @AUTHOR:
# Alexandre Rostovtsev <tetromino@gentoo.org>
# @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}"
}



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 16:09 [gentoo-dev] [RFC] new vala.eclass Alexandre Rostovtsev
@ 2012-08-25 17:25 ` Tomáš Chvátal
  2012-08-25 18:29   ` Diego Elio Pettenò
  2012-08-25 21:04 ` Alexandre Rostovtsev
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Tomáš Chvátal @ 2012-08-25 17:25 UTC (permalink / raw
  To: gentoo-dev

2012/8/25 Alexandre Rostovtsev <tetromino@gentoo.org>:
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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 17:25 ` Tomáš Chvátal
@ 2012-08-25 18:29   ` Diego Elio Pettenò
  0 siblings, 0 replies; 18+ messages in thread
From: Diego Elio Pettenò @ 2012-08-25 18:29 UTC (permalink / raw
  To: gentoo-dev

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@flameeyes.eu — http://blog.flameeyes.eu/


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 16:09 [gentoo-dev] [RFC] new vala.eclass Alexandre Rostovtsev
  2012-08-25 17:25 ` Tomáš Chvátal
@ 2012-08-25 21:04 ` Alexandre Rostovtsev
  2012-08-25 21:45   ` Ulrich Mueller
  2012-08-26 22:32   ` [gentoo-dev] " Duncan
  2012-08-27  1:20 ` [gentoo-dev] " Alexandre Rostovtsev
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-25 21:04 UTC (permalink / raw
  To: gentoo-dev

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@gentoo.org
# @AUTHOR:
# Alexandre Rostovtsev <tetromino@gentoo.org>
# @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}"
}



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 21:04 ` Alexandre Rostovtsev
@ 2012-08-25 21:45   ` Ulrich Mueller
  2012-08-26  6:59     ` Alexandre Rostovtsev
  2012-08-26 22:32   ` [gentoo-dev] " Duncan
  1 sibling, 1 reply; 18+ messages in thread
From: Ulrich Mueller @ 2012-08-25 21:45 UTC (permalink / raw
  To: gentoo-dev

>>>>> 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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 21:45   ` Ulrich Mueller
@ 2012-08-26  6:59     ` Alexandre Rostovtsev
  2012-08-26  7:08       ` Alexandre Rostovtsev
                         ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-26  6:59 UTC (permalink / raw
  To: gentoo-dev

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}"



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-26  6:59     ` Alexandre Rostovtsev
@ 2012-08-26  7:08       ` Alexandre Rostovtsev
  2012-08-26  7:20       ` Alexandre Rostovtsev
  2012-08-26 22:45       ` Zac Medico
  2 siblings, 0 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-26  7:08 UTC (permalink / raw
  To: gentoo-dev

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}"



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-26  6:59     ` Alexandre Rostovtsev
  2012-08-26  7:08       ` Alexandre Rostovtsev
@ 2012-08-26  7:20       ` Alexandre Rostovtsev
  2012-08-26 22:45       ` Zac Medico
  2 siblings, 0 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-26  7:20 UTC (permalink / raw
  To: gentoo-dev

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* [gentoo-dev] Re: [RFC] new vala.eclass
  2012-08-25 21:04 ` Alexandre Rostovtsev
  2012-08-25 21:45   ` Ulrich Mueller
@ 2012-08-26 22:32   ` Duncan
  1 sibling, 0 replies; 18+ messages in thread
From: Duncan @ 2012-08-26 22:32 UTC (permalink / raw
  To: gentoo-dev

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



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-26  6:59     ` Alexandre Rostovtsev
  2012-08-26  7:08       ` Alexandre Rostovtsev
  2012-08-26  7:20       ` Alexandre Rostovtsev
@ 2012-08-26 22:45       ` Zac Medico
  2012-08-26 23:43         ` Alexandre Rostovtsev
  2 siblings, 1 reply; 18+ messages in thread
From: Zac Medico @ 2012-08-26 22:45 UTC (permalink / raw
  To: gentoo-dev

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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-26 22:45       ` Zac Medico
@ 2012-08-26 23:43         ` Alexandre Rostovtsev
  2012-08-27  2:45           ` Alexis Ballier
  0 siblings, 1 reply; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-26 23:43 UTC (permalink / raw
  To: gentoo-dev

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.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 16:09 [gentoo-dev] [RFC] new vala.eclass Alexandre Rostovtsev
  2012-08-25 17:25 ` Tomáš Chvátal
  2012-08-25 21:04 ` Alexandre Rostovtsev
@ 2012-08-27  1:20 ` Alexandre Rostovtsev
  2012-08-27 13:21 ` Alexandre Rostovtsev
  2012-09-10  2:09 ` Alexandre Rostovtsev
  4 siblings, 0 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-27  1:20 UTC (permalink / raw
  To: gentoo-dev

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@gentoo.org
# @AUTHOR:
# Alexandre Rostovtsev <tetromino@gentoo.org>
# @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}"
}



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-26 23:43         ` Alexandre Rostovtsev
@ 2012-08-27  2:45           ` Alexis Ballier
  2012-08-27  4:45             ` Alexandre Rostovtsev
  0 siblings, 1 reply; 18+ messages in thread
From: Alexis Ballier @ 2012-08-27  2:45 UTC (permalink / raw
  To: gentoo-dev

On Sun, 26 Aug 2012 19:43:32 -0400
Alexandre Rostovtsev <tetromino@gentoo.org> 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


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-27  2:45           ` Alexis Ballier
@ 2012-08-27  4:45             ` Alexandre Rostovtsev
  2012-08-27 12:19               ` Alexis Ballier
  0 siblings, 1 reply; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-27  4:45 UTC (permalink / raw
  To: gentoo-dev

On Sun, 2012-08-26 at 22:45 -0400, Alexis Ballier wrote:
> On Sun, 26 Aug 2012 19:43:32 -0400
> Alexandre Rostovtsev <tetromino@gentoo.org> 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().



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-27  4:45             ` Alexandre Rostovtsev
@ 2012-08-27 12:19               ` Alexis Ballier
  0 siblings, 0 replies; 18+ messages in thread
From: Alexis Ballier @ 2012-08-27 12:19 UTC (permalink / raw
  To: gentoo-dev

On Mon, 27 Aug 2012 00:45:45 -0400
Alexandre Rostovtsev <tetromino@gentoo.org> 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@gentoo.org> 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.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 16:09 [gentoo-dev] [RFC] new vala.eclass Alexandre Rostovtsev
                   ` (2 preceding siblings ...)
  2012-08-27  1:20 ` [gentoo-dev] " Alexandre Rostovtsev
@ 2012-08-27 13:21 ` Alexandre Rostovtsev
  2012-09-10  2:09 ` Alexandre Rostovtsev
  4 siblings, 0 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-08-27 13:21 UTC (permalink / raw
  To: gentoo-dev

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@gentoo.org
# @AUTHOR:
# Alexandre Rostovtsev <tetromino@gentoo.org>
# @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}"
}



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-08-25 16:09 [gentoo-dev] [RFC] new vala.eclass Alexandre Rostovtsev
                   ` (3 preceding siblings ...)
  2012-08-27 13:21 ` Alexandre Rostovtsev
@ 2012-09-10  2:09 ` Alexandre Rostovtsev
  2012-09-12 20:24   ` Alexandre Rostovtsev
  4 siblings, 1 reply; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-09-10  2:09 UTC (permalink / raw
  To: gentoo-dev

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@gentoo.org
# @AUTHOR:
# Alexandre Rostovtsev <tetromino@gentoo.org>
# @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}"
}




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [gentoo-dev] [RFC] new vala.eclass
  2012-09-10  2:09 ` Alexandre Rostovtsev
@ 2012-09-12 20:24   ` Alexandre Rostovtsev
  0 siblings, 0 replies; 18+ messages in thread
From: Alexandre Rostovtsev @ 2012-09-12 20:24 UTC (permalink / raw
  To: gentoo-dev

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@gentoo.org
> # @AUTHOR:
> # Alexandre Rostovtsev <tetromino@gentoo.org>
> # @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.




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-09-12 20:25 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-25 16:09 [gentoo-dev] [RFC] new vala.eclass Alexandre Rostovtsev
2012-08-25 17:25 ` Tomáš Chvátal
2012-08-25 18:29   ` Diego Elio Pettenò
2012-08-25 21:04 ` Alexandre Rostovtsev
2012-08-25 21:45   ` Ulrich Mueller
2012-08-26  6:59     ` Alexandre Rostovtsev
2012-08-26  7:08       ` Alexandre Rostovtsev
2012-08-26  7:20       ` Alexandre Rostovtsev
2012-08-26 22:45       ` Zac Medico
2012-08-26 23:43         ` Alexandre Rostovtsev
2012-08-27  2:45           ` Alexis Ballier
2012-08-27  4:45             ` Alexandre Rostovtsev
2012-08-27 12:19               ` Alexis Ballier
2012-08-26 22:32   ` [gentoo-dev] " Duncan
2012-08-27  1:20 ` [gentoo-dev] " Alexandre Rostovtsev
2012-08-27 13:21 ` Alexandre Rostovtsev
2012-09-10  2:09 ` Alexandre Rostovtsev
2012-09-12 20:24   ` Alexandre Rostovtsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox