Gentoo Archives: gentoo-commits

From: "Michal Gorny (mgorny)" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog python-r1.eclass
Date: Thu, 27 Dec 2012 22:56:32
Message-Id: 20121227225621.B4CFB2171D@flycatcher.gentoo.org
1 mgorny 12/12/27 22:56:21
2
3 Modified: ChangeLog python-r1.eclass
4 Log:
5 Introduce python_gen_usedep() and python_gen_flags() to make writing complex dependencies easier.
6
7 Revision Changes Path
8 1.577 eclass/ChangeLog
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.577&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.577&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.576&r2=1.577
13
14 Index: ChangeLog
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
17 retrieving revision 1.576
18 retrieving revision 1.577
19 diff -u -r1.576 -r1.577
20 --- ChangeLog 26 Dec 2012 23:08:53 -0000 1.576
21 +++ ChangeLog 27 Dec 2012 22:56:21 -0000 1.577
22 @@ -1,6 +1,10 @@
23 # ChangeLog for eclass directory
24 # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.576 2012/12/26 23:08:53 ottxor Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.577 2012/12/27 22:56:21 mgorny Exp $
27 +
28 + 27 Dec 2012; Michał Górny <mgorny@g.o> python-r1.eclass:
29 + Introduce python_gen_usedep() and python_gen_flags() to make writing complex
30 + dependencies easier.
31
32 26 Dec 2012; Christoph Junghans <ottxor@g.o> mercurial.eclass:
33 added EHG_BOOTSTRAP (bug #340153), EHG_REVISION defaults to 'defaults (bug
34
35
36
37 1.32 eclass/python-r1.eclass
38
39 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-r1.eclass?rev=1.32&view=markup
40 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-r1.eclass?rev=1.32&content-type=text/plain
41 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/python-r1.eclass?r1=1.31&r2=1.32
42
43 Index: python-r1.eclass
44 ===================================================================
45 RCS file: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v
46 retrieving revision 1.31
47 retrieving revision 1.32
48 diff -u -r1.31 -r1.32
49 --- python-r1.eclass 20 Dec 2012 23:35:17 -0000 1.31
50 +++ python-r1.eclass 27 Dec 2012 22:56:21 -0000 1.32
51 @@ -1,6 +1,6 @@
52 # Copyright 1999-2012 Gentoo Foundation
53 # Distributed under the terms of the GNU General Public License v2
54 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.31 2012/12/20 23:35:17 mgorny Exp $
55 +# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.32 2012/12/27 22:56:21 mgorny Exp $
56
57 # @ECLASS: python-r1
58 # @MAINTAINER:
59 @@ -162,6 +162,84 @@
60 }
61 _python_set_globals
62
63 +# @FUNCTION: python_gen_usedep
64 +# @USAGE: pattern [...]
65 +# @DESCRIPTION:
66 +# Output a USE dependency string for Python implementations which
67 +# are both in PYTHON_COMPAT and match any of the patterns passed
68 +# as parameters to the function.
69 +#
70 +# When all implementations are requested, please use ${PYTHON_USEDEP}
71 +# instead. Please also remember to set an appropriate REQUIRED_USE
72 +# to avoid ineffective USE flags.
73 +#
74 +# Example:
75 +# @CODE
76 +# PYTHON_COMPAT=( python{2_7,3_2} )
77 +# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep python2*)] )"
78 +# @CODE
79 +#
80 +# It will cause the dependency to look like:
81 +# @CODE
82 +# DEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
83 +# @CODE
84 +python_gen_usedep() {
85 + debug-print-function ${FUNCNAME} "${@}"
86 +
87 + local impl pattern
88 + local matches=()
89 +
90 + for impl in "${PYTHON_COMPAT[@]}"; do
91 + for pattern; do
92 + if [[ ${impl} == ${pattern} ]]; then
93 + matches+=(
94 + "python_targets_${impl}?"
95 + "-python_single_target_${impl}(-)"
96 + )
97 + break
98 + fi
99 + done
100 + done
101 +
102 + local out=${matches[@]}
103 + echo ${out// /,}
104 +}
105 +
106 +# @FUNCTION: python_gen_useflags
107 +# @USAGE: pattern [...]
108 +# @DESCRIPTION:
109 +# Output a list of USE flags for Python implementations which
110 +# are both in PYTHON_COMPAT and match any of the patterns passed
111 +# as parameters to the function.
112 +#
113 +# Example:
114 +# @CODE
115 +# PYTHON_COMPAT=( python{2_7,3_2} )
116 +# REQUIRED_USE="doc? ( || ( $(python_gen_useflags python2*) ) )"
117 +# @CODE
118 +#
119 +# It will cause the variable to look like:
120 +# @CODE
121 +# REQUIRED_USE="doc? ( || ( python_targets_python2_7 ) )"
122 +# @CODE
123 +python_gen_useflags() {
124 + debug-print-function ${FUNCNAME} "${@}"
125 +
126 + local impl pattern
127 + local matches=()
128 +
129 + for impl in "${PYTHON_COMPAT[@]}"; do
130 + for pattern; do
131 + if [[ ${impl} == ${pattern} ]]; then
132 + matches+=( "python_targets_${impl}" )
133 + break
134 + fi
135 + done
136 + done
137 +
138 + echo ${matches[@]}
139 +}
140 +
141 # @ECLASS-VARIABLE: BUILD_DIR
142 # @DESCRIPTION:
143 # The current build directory. In global scope, it is supposed to