1 |
I don't have a good idea how to make enforcing USE deps inside easier |
2 |
than $(python_gen_cond_dep dev-foo/bar[$(python_gen_usedep IMPLS)] |
3 |
IMPLS) without adding some risky magic. |
4 |
--- |
5 |
gx86/eclass/python-r1.eclass | 47 ++++++++++++++++++++++++++++++++++++++++++-- |
6 |
1 file changed, 45 insertions(+), 2 deletions(-) |
7 |
|
8 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
9 |
index 40ce68b..32ac3ca 100644 |
10 |
--- a/gx86/eclass/python-r1.eclass |
11 |
+++ b/gx86/eclass/python-r1.eclass |
12 |
@@ -178,7 +178,7 @@ _python_set_globals() { |
13 |
_python_set_globals |
14 |
|
15 |
# @FUNCTION: python_gen_usedep |
16 |
-# @USAGE: pattern [...] |
17 |
+# @USAGE: <pattern> [...] |
18 |
# @DESCRIPTION: |
19 |
# Output a USE dependency string for Python implementations which |
20 |
# are both in PYTHON_COMPAT and match any of the patterns passed |
21 |
@@ -221,7 +221,7 @@ python_gen_usedep() { |
22 |
} |
23 |
|
24 |
# @FUNCTION: python_gen_useflags |
25 |
-# @USAGE: pattern [...] |
26 |
+# @USAGE: <pattern> [...] |
27 |
# @DESCRIPTION: |
28 |
# Output a list of USE flags for Python implementations which |
29 |
# are both in PYTHON_COMPAT and match any of the patterns passed |
30 |
@@ -255,6 +255,49 @@ python_gen_useflags() { |
31 |
echo ${matches[@]} |
32 |
} |
33 |
|
34 |
+# @FUNCTION: python_gen_cond_dep |
35 |
+# @USAGE: <dependency> <pattern> [...] |
36 |
+# @DESCRIPTION: |
37 |
+# Output a list of <dependency>-ies made conditional to USE flags |
38 |
+# of Python implementations which are both in PYTHON_COMPAT and match |
39 |
+# any of the patterns passed as the remaining parameters. |
40 |
+# |
41 |
+# Please note that USE constraints on the package need to be enforced |
42 |
+# separately. Therefore, the dependency usually needs to use |
43 |
+# python_gen_usedep as well. |
44 |
+# |
45 |
+# Example: |
46 |
+# @CODE |
47 |
+# PYTHON_COMPAT=( python{2_5,2_6,2_7} ) |
48 |
+# RDEPEND="$(python_gen_cond_dep dev-python/unittest2 python{2_5,2_6})" |
49 |
+# @CODE |
50 |
+# |
51 |
+# It will cause the variable to look like: |
52 |
+# @CODE |
53 |
+# RDEPEND="python_targets_python2_5? ( dev-python/unittest2 ) |
54 |
+# python_targets_python2_6? ( dev-python/unittest2 )" |
55 |
+# @CODE |
56 |
+python_gen_cond_dep() { |
57 |
+ debug-print-function ${FUNCNAME} "${@}" |
58 |
+ |
59 |
+ local impl pattern |
60 |
+ local matches=() |
61 |
+ |
62 |
+ local dep=${1} |
63 |
+ shift |
64 |
+ |
65 |
+ for impl in "${PYTHON_COMPAT[@]}"; do |
66 |
+ for pattern; do |
67 |
+ if [[ ${impl} == ${pattern} ]]; then |
68 |
+ matches+=( "python_targets_${impl}? ( ${dep} )" ) |
69 |
+ break |
70 |
+ fi |
71 |
+ done |
72 |
+ done |
73 |
+ |
74 |
+ echo ${matches[@]} |
75 |
+} |
76 |
+ |
77 |
# @ECLASS-VARIABLE: BUILD_DIR |
78 |
# @DESCRIPTION: |
79 |
# The current build directory. In global scope, it is supposed to |
80 |
-- |
81 |
1.8.0.2 |