Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 17/30] python-single-r1.eclass: Inline & simplify USE-deps in gen_cond_dep
Date: Sun, 06 Feb 2022 12:54:21
Message-Id: 20220206124841.1299133-18-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/30] One batch of Python eclass updates to rule them all by "Michał Górny"
1 Generate simpler USE-deps inline in python_gen_cond_dep() and remove
2 _python_gen_usedep(). The original code always repeated USE deps
3 on all targets to aid Portage in giving better suggestions. However,
4 since there always will be exactly one implementation selected, this
5 is unnecessary and we can just have every cond-dep match exactly that
6 one target.
7
8 Signed-off-by: Michał Górny <mgorny@g.o>
9 ---
10 eclass/python-single-r1.eclass | 45 +++-------------------------------
11 1 file changed, 3 insertions(+), 42 deletions(-)
12
13 diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
14 index 574ee9cfc04e..73afcdc3ed6c 100644
15 --- a/eclass/python-single-r1.eclass
16 +++ b/eclass/python-single-r1.eclass
17 @@ -259,40 +259,6 @@ unset -f _python_single_set_globals
18
19 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
20
21 -# @FUNCTION: _python_gen_usedep
22 -# @USAGE: [<pattern>...]
23 -# @INTERNAL
24 -# @DESCRIPTION:
25 -# Output a USE dependency string for Python implementations which
26 -# are both in PYTHON_COMPAT and match any of the patterns passed
27 -# as parameters to the function.
28 -#
29 -# The patterns are fnmatch-style patterns (matched via bash
30 -# == operator against PYTHON_COMPAT values). Remember to escape
31 -# or quote the fnmatch patterns to prevent accidental shell filename
32 -# expansion.
33 -#
34 -# This is an internal function used to implement python_gen_cond_dep.
35 -_python_gen_usedep() {
36 - debug-print-function ${FUNCNAME} "${@}"
37 -
38 - local impl matches=()
39 -
40 - _python_verify_patterns "${@}"
41 - for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
42 - if _python_impl_matches "${impl}" "${@}"; then
43 - matches+=(
44 - "python_single_target_${impl}(-)?"
45 - )
46 - fi
47 - done
48 -
49 - [[ ${matches[@]} ]] || die "No supported implementations match python_gen_usedep patterns: ${@}"
50 -
51 - local out=${matches[@]}
52 - echo "${out// /,}"
53 -}
54 -
55 # @FUNCTION: python_gen_useflags
56 # @USAGE: [<pattern>...]
57 # @DESCRIPTION:
58 @@ -372,13 +338,7 @@ python_gen_cond_dep() {
59 _python_verify_patterns "${@}"
60 for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
61 if _python_impl_matches "${impl}" "${@}"; then
62 - # substitute ${PYTHON_SINGLE_USEDEP} if used
63 - # (since python_gen_usedep() will not return
64 - # ${PYTHON_SINGLE_USEDEP}, the code is run at most once)
65 - if [[ ${dep} == *'${PYTHON_SINGLE_USEDEP}'* ]]; then
66 - local usedep=$(_python_gen_usedep "${@}")
67 - dep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${usedep}}
68 - fi
69 + local single_usedep="python_single_target_${impl}(-)"
70 local multi_usedep="python_targets_${impl}(-)"
71
72 if [[ ${EAPI} != [67] ]]; then
73 @@ -387,7 +347,8 @@ python_gen_cond_dep() {
74 fi
75 fi
76
77 - local subdep=${dep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}}
78 + local subdep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${single_usedep}}
79 + subdep=${subdep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}}
80 matches+=( "python_single_target_${impl}? (
81 ${subdep//\$\{PYTHON_USEDEP\}/${multi_usedep}} )" )
82 fi
83 --
84 2.35.1