summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2012-12-27 22:56:21 +0000
committerMichał Górny <mgorny@gentoo.org>2012-12-27 22:56:21 +0000
commitd19b75f7e4ec137766dc9c107a8e6cd72804a8c3 (patch)
tree10701b373a1d11d8b56dcc70c7eb98c2a61709dd /eclass/python-r1.eclass
parentAdd missing gdbus-codegen dependency (bug #448916, thanks to Mark). (diff)
downloadgentoo-2-d19b75f7e4ec137766dc9c107a8e6cd72804a8c3.tar.gz
gentoo-2-d19b75f7e4ec137766dc9c107a8e6cd72804a8c3.tar.bz2
gentoo-2-d19b75f7e4ec137766dc9c107a8e6cd72804a8c3.zip
Introduce python_gen_usedep() and python_gen_flags() to make writing complex dependencies easier.
Diffstat (limited to 'eclass/python-r1.eclass')
-rw-r--r--eclass/python-r1.eclass80
1 files changed, 79 insertions, 1 deletions
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index cc66f2cc9d39..70d7423bb5df 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.31 2012/12/20 23:35:17 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.32 2012/12/27 22:56:21 mgorny Exp $
# @ECLASS: python-r1
# @MAINTAINER:
@@ -162,6 +162,84 @@ _python_set_globals() {
}
_python_set_globals
+# @FUNCTION: python_gen_usedep
+# @USAGE: pattern [...]
+# @DESCRIPTION:
+# Output a USE dependency string for Python implementations which
+# are both in PYTHON_COMPAT and match any of the patterns passed
+# as parameters to the function.
+#
+# When all implementations are requested, please use ${PYTHON_USEDEP}
+# instead. Please also remember to set an appropriate REQUIRED_USE
+# to avoid ineffective USE flags.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_7,3_2} )
+# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep python2*)] )"
+# @CODE
+#
+# It will cause the dependency to look like:
+# @CODE
+# DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
+# @CODE
+python_gen_usedep() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local impl pattern
+ local matches=()
+
+ for impl in "${PYTHON_COMPAT[@]}"; do
+ for pattern; do
+ if [[ ${impl} == ${pattern} ]]; then
+ matches+=(
+ "python_targets_${impl}?"
+ "-python_single_target_${impl}(-)"
+ )
+ break
+ fi
+ done
+ done
+
+ local out=${matches[@]}
+ echo ${out// /,}
+}
+
+# @FUNCTION: python_gen_useflags
+# @USAGE: pattern [...]
+# @DESCRIPTION:
+# Output a list of USE flags for Python implementations which
+# are both in PYTHON_COMPAT and match any of the patterns passed
+# as parameters to the function.
+#
+# Example:
+# @CODE
+# PYTHON_COMPAT=( python{2_7,3_2} )
+# REQUIRED_USE="doc? ( || ( $(python_gen_useflags python2*) ) )"
+# @CODE
+#
+# It will cause the variable to look like:
+# @CODE
+# REQUIRED_USE="doc? ( || ( python_targets_python2_7 ) )"
+# @CODE
+python_gen_useflags() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local impl pattern
+ local matches=()
+
+ for impl in "${PYTHON_COMPAT[@]}"; do
+ for pattern; do
+ if [[ ${impl} == ${pattern} ]]; then
+ matches+=( "python_targets_${impl}" )
+ break
+ fi
+ done
+ done
+
+ echo ${matches[@]}
+}
+
# @ECLASS-VARIABLE: BUILD_DIR
# @DESCRIPTION:
# The current build directory. In global scope, it is supposed to