1 |
Reliably allow empty pattern lists (equivalent to no restrictions) |
2 |
in all pattern-based generator functions, notably python_gen_cond_dep. |
3 |
Previously, only some of the functions accepted them while others |
4 |
failed via _python_impl_matches function. |
5 |
|
6 |
Signed-off-by: Michał Górny <mgorny@g.o> |
7 |
--- |
8 |
eclass/python-r1.eclass | 13 ++++++------- |
9 |
eclass/python-single-r1.eclass | 9 ++++----- |
10 |
eclass/python-utils-r1.eclass | 6 ++++-- |
11 |
3 files changed, 14 insertions(+), 14 deletions(-) |
12 |
|
13 |
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass |
14 |
index 833a581fc59f..72ae7f82428a 100644 |
15 |
--- a/eclass/python-r1.eclass |
16 |
+++ b/eclass/python-r1.eclass |
17 |
@@ -278,7 +278,7 @@ _python_validate_useflags() { |
18 |
|
19 |
# @FUNCTION: _python_gen_usedep |
20 |
# @INTERNAL |
21 |
-# @USAGE: <pattern> [...] |
22 |
+# @USAGE: [<pattern>...] |
23 |
# @DESCRIPTION: |
24 |
# Output a USE dependency string for Python implementations which |
25 |
# are both in PYTHON_COMPAT and match any of the patterns passed |
26 |
@@ -353,7 +353,7 @@ python_gen_usedep() { |
27 |
} |
28 |
|
29 |
# @FUNCTION: python_gen_useflags |
30 |
-# @USAGE: <pattern> [...] |
31 |
+# @USAGE: [<pattern>...] |
32 |
# @DESCRIPTION: |
33 |
# Output a list of USE flags for Python implementations which |
34 |
# are both in PYTHON_COMPAT and match any of the patterns passed |
35 |
@@ -390,7 +390,7 @@ python_gen_useflags() { |
36 |
} |
37 |
|
38 |
# @FUNCTION: python_gen_cond_dep |
39 |
-# @USAGE: <dependency> <pattern> [...] |
40 |
+# @USAGE: <dependency> [<pattern>...] |
41 |
# @DESCRIPTION: |
42 |
# Output a list of <dependency>-ies made conditional to USE flags |
43 |
# of Python implementations which are both in PYTHON_COMPAT and match |
44 |
@@ -486,9 +486,8 @@ python_gen_impl_dep() { |
45 |
local PYTHON_REQ_USE=${1} |
46 |
shift |
47 |
|
48 |
- local patterns=( "${@-*}" ) |
49 |
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
50 |
- if _python_impl_matches "${impl}" "${patterns[@]}"; then |
51 |
+ if _python_impl_matches "${impl}" "${@}"; then |
52 |
local PYTHON_PKG_DEP |
53 |
python_export "${impl}" PYTHON_PKG_DEP |
54 |
matches+=( "python_targets_${impl}? ( ${PYTHON_PKG_DEP} )" ) |
55 |
@@ -566,7 +565,7 @@ python_gen_any_dep() { |
56 |
|
57 |
local i PYTHON_PKG_DEP out= |
58 |
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
59 |
- if _python_impl_matches "${i}" "${@-*}"; then |
60 |
+ if _python_impl_matches "${i}" "${@}"; then |
61 |
local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)" |
62 |
python_export "${i}" PYTHON_PKG_DEP |
63 |
|
64 |
@@ -763,7 +762,7 @@ python_setup() { |
65 |
fi |
66 |
|
67 |
# check patterns |
68 |
- _python_impl_matches "${impl}" "${@-*}" || continue |
69 |
+ _python_impl_matches "${impl}" "${@}" || continue |
70 |
|
71 |
python_export "${impl}" EPYTHON PYTHON |
72 |
|
73 |
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass |
74 |
index f2ad4881135d..fff816570703 100644 |
75 |
--- a/eclass/python-single-r1.eclass |
76 |
+++ b/eclass/python-single-r1.eclass |
77 |
@@ -252,7 +252,7 @@ if [[ ! ${_PYTHON_SINGLE_R1} ]]; then |
78 |
|
79 |
# @FUNCTION: _python_gen_usedep |
80 |
# @INTERNAL |
81 |
-# @USAGE: <pattern> [...] |
82 |
+# @USAGE: [<pattern>...] |
83 |
# @DESCRIPTION: |
84 |
# Output a USE dependency string for Python implementations which |
85 |
# are both in PYTHON_COMPAT and match any of the patterns passed |
86 |
@@ -327,7 +327,7 @@ python_gen_usedep() { |
87 |
} |
88 |
|
89 |
# @FUNCTION: python_gen_useflags |
90 |
-# @USAGE: <pattern> [...] |
91 |
+# @USAGE: [<pattern>...] |
92 |
# @DESCRIPTION: |
93 |
# Output a list of USE flags for Python implementations which |
94 |
# are both in PYTHON_COMPAT and match any of the patterns passed |
95 |
@@ -364,7 +364,7 @@ python_gen_useflags() { |
96 |
} |
97 |
|
98 |
# @FUNCTION: python_gen_cond_dep |
99 |
-# @USAGE: <dependency> <pattern> [...] |
100 |
+# @USAGE: <dependency> [<pattern>...] |
101 |
# @DESCRIPTION: |
102 |
# Output a list of <dependency>-ies made conditional to USE flags |
103 |
# of Python implementations which are both in PYTHON_COMPAT and match |
104 |
@@ -463,9 +463,8 @@ python_gen_impl_dep() { |
105 |
local PYTHON_REQ_USE=${1} |
106 |
shift |
107 |
|
108 |
- local patterns=( "${@-*}" ) |
109 |
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
110 |
- if _python_impl_matches "${impl}" "${patterns[@]}"; then |
111 |
+ if _python_impl_matches "${impl}" "${@}"; then |
112 |
local PYTHON_PKG_DEP |
113 |
python_export "${impl}" PYTHON_PKG_DEP |
114 |
matches+=( "python_single_target_${impl}? ( ${PYTHON_PKG_DEP} )" ) |
115 |
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass |
116 |
index 4f3ac66f2150..3eadc50f93e6 100644 |
117 |
--- a/eclass/python-utils-r1.eclass |
118 |
+++ b/eclass/python-utils-r1.eclass |
119 |
@@ -164,11 +164,12 @@ _python_set_impls() { |
120 |
} |
121 |
|
122 |
# @FUNCTION: _python_impl_matches |
123 |
-# @USAGE: <impl> <pattern>... |
124 |
+# @USAGE: <impl> [<pattern>...] |
125 |
# @INTERNAL |
126 |
# @DESCRIPTION: |
127 |
# Check whether the specified <impl> matches at least one |
128 |
# of the patterns following it. Return 0 if it does, 1 otherwise. |
129 |
+# Matches if no patterns are provided. |
130 |
# |
131 |
# <impl> can be in PYTHON_COMPAT or EPYTHON form. The patterns can be |
132 |
# either: |
133 |
@@ -176,7 +177,8 @@ _python_set_impls() { |
134 |
# b) '-2' to indicate all Python 2 variants (= !python_is_python3) |
135 |
# c) '-3' to indicate all Python 3 variants (= python_is_python3) |
136 |
_python_impl_matches() { |
137 |
- [[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters" |
138 |
+ [[ ${#} -ge 1 ]] || die "${FUNCNAME}: takes at least 1 parameter" |
139 |
+ [[ ${#} -eq 1 ]] && return 0 |
140 |
|
141 |
local impl=${1} pattern |
142 |
shift |
143 |
-- |
144 |
2.24.0 |