Gentoo Archives: gentoo-dev

From: Sergei Trofimovich <slyfox@g.o>
To: Andreas Sturmlechner <asturm@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] flag-o-matic.eclass: get rid of eutils in <EAPI-8, fix eclassdoc, make some funcs internal
Date: Wed, 31 Mar 2021 07:33:29
Message-Id: 20210331083321.24e5ead5@sf
In Reply to: [gentoo-dev] [PATCH] flag-o-matic.eclass: get rid of eutils in by Andreas Sturmlechner
1 On Wed, 31 Mar 2021 08:39:27 +0200
2 Andreas Sturmlechner <asturm@g.o> wrote:
3
4 > qa-reports showing >7300 ebuilds with EAPI-7 using eutils.eclass, that can't be right.
5 >
6 > - Restrict inherit eutils to <EAPI-8
7 > - Drop bogus multilib.eclass (inherited by toolchain-funcs.eclass anyway)
8 > - Several functions look like they should be internal
9 > - Fix eclassdoc issues, add missing docu
10 >
11 > See also:
12 > https://qa-reports.gentoo.org/output/eapi-per-eclass/eutils.eclass/
13 > https://github.com/gentoo/gentoo/pull/20207
14
15 Please post series as separate patches.
16
17 > diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
18 > index 20ee39d98ba..35dc09f94de 100644
19 > --- a/eclass/flag-o-matic.eclass
20 > +++ b/eclass/flag-o-matic.eclass
21 > @@ -1,4 +1,4 @@
22 > -# Copyright 1999-2020 Gentoo Authors
23 > +# Copyright 1999-2021 Gentoo Authors
24 > # Distributed under the terms of the GNU General Public License v2
25 >
26 > # @ECLASS: flag-o-matic.eclass
27 > @@ -12,16 +12,37 @@
28 > if [[ -z ${_FLAG_O_MATIC_ECLASS} ]]; then
29 > _FLAG_O_MATIC_ECLASS=1
30 >
31 > -inherit eutils toolchain-funcs multilib
32 > +inherit toolchain-funcs
33 >
34 > +case ${EAPI} in
35 > + [0-7]) inherit eutils ;;
36 > + *) ;;
37 > +esac
38 > +
39 > +# @FUNCTION: all-flag-vars
40 > +# @DESCRIPTION:
41 > # Return all the flag variables that our high level funcs operate on.
42 > all-flag-vars() {
43 > echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
44 > }
45 >
46 > +# @FUNCTION: setup-allowed-flags
47 > +# @INTERNAL
48 > +# @DESCRIPTION:
49 > # {C,CPP,CXX,CCAS,F,FC,LD}FLAGS that we allow in strip-flags
50 > # Note: shell globs and character lists are allowed
51 > setup-allowed-flags() {
52 > + [[ ${EAPI} == [0-7] ]] ||
53 > + die "Internal function ${FUNCNAME} is not available in >=EAPI-8."
54 > + _setup-allowed-flags
55 > +}
56 > +
57 > +# @FUNCTION: _setup-allowed-flags
58 > +# @INTERNAL
59 > +# @DESCRIPTION:
60 > +# {C,CPP,CXX,CCAS,F,FC,LD}FLAGS that we allow in strip-flags
61 > +# Note: shell globs and character lists are allowed
62 > +_setup-allowed-flags() {
63 > ALLOWED_FLAGS=(
64 > -pipe -O '-O[12sg]' -mcpu -march -mtune
65 > '-fstack-protector*' '-fsanitize*' '-fstack-check*' -fno-stack-check
66 > @@ -87,7 +108,10 @@ setup-allowed-flags() {
67 > )
68 > }
69 >
70 > -# inverted filters for hardened compiler. This is trying to unpick
71 > +# @FUNCTION: _filter-hardened
72 > +# @INTERNAL
73 > +# @DESCRIPTION:
74 > +# Inverted filters for hardened compiler. This is trying to unpick
75 > # the hardened compiler defaults.
76 > _filter-hardened() {
77 > local f
78 > @@ -121,6 +145,9 @@ _filter-hardened() {
79 > done
80 > }
81 >
82 > +# @FUNCTION: _filter-var
83 > +# @INTERNAL
84 > +# @DESCRIPTION:
85 > # Remove occurrences of strings from variable given in $1
86 > # Strings removed are matched as globs, so for example
87 > # '-O*' would remove -O1, -O2 etc.
88 > @@ -313,6 +340,11 @@ replace-cpu-flags() {
89 > return 0
90 > }
91 >
92 > +# @FUNCTION: _is_flagq
93 > +# @USAGE: <variable> <flag>
94 > +# @INTERNAL
95 > +# @DESCRIPTION:
96 > +# Returns shell true if <flag> is in a given <variable>, else returns shell false.
97 > _is_flagq() {
98 > local x var="$1[*]"
99 > for x in ${!var} ; do
100 > @@ -405,7 +437,7 @@ strip-flags() {
101 > local x y var
102 >
103 > local ALLOWED_FLAGS
104 > - setup-allowed-flags
105 > + _setup-allowed-flags
106 >
107 > set -f # disable pathname expansion
108 >
109 > @@ -438,7 +470,23 @@ strip-flags() {
110 > return 0
111 > }
112 >
113 > +# @FUNCTION: test-flag-PROG
114 > +# @USAGE: <compiler> <flag>
115 > +# @INTERNAL
116 > +# @DESCRIPTION:
117 > +# Returns shell true if <flag> is supported by given <compiler>, else returns shell false.
118 > test-flag-PROG() {
119 > + [[ ${EAPI} == [0-7] ]] ||
120 > + die "Internal function ${FUNCNAME} is not available in >=EAPI-8."
121 > + _test-flag-PROG
122 > +}
123 > +
124 > +# @FUNCTION: _test-flag-PROG
125 > +# @USAGE: <compiler> <flag>
126 > +# @INTERNAL
127 > +# @DESCRIPTION:
128 > +# Returns shell true if <flag> is supported by given <compiler>, else returns shell false.
129 > +_test-flag-PROG() {
130 > local comp=$1
131 > local lang=$2
132 > shift 2
133 > @@ -533,33 +581,49 @@ test-flag-PROG() {
134 > # @USAGE: <flag>
135 > # @DESCRIPTION:
136 > # Returns shell true if <flag> is supported by the C compiler, else returns shell false.
137 > -test-flag-CC() { test-flag-PROG "CC" c "$@"; }
138 > +test-flag-CC() { _test-flag-PROG "CC" c "$@"; }
139 >
140 > # @FUNCTION: test-flag-CXX
141 > # @USAGE: <flag>
142 > # @DESCRIPTION:
143 > # Returns shell true if <flag> is supported by the C++ compiler, else returns shell false.
144 > -test-flag-CXX() { test-flag-PROG "CXX" c++ "$@"; }
145 > +test-flag-CXX() { _test-flag-PROG "CXX" c++ "$@"; }
146 >
147 > # @FUNCTION: test-flag-F77
148 > # @USAGE: <flag>
149 > # @DESCRIPTION:
150 > # Returns shell true if <flag> is supported by the Fortran 77 compiler, else returns shell false.
151 > -test-flag-F77() { test-flag-PROG "F77" f77 "$@"; }
152 > +test-flag-F77() { _test-flag-PROG "F77" f77 "$@"; }
153 >
154 > # @FUNCTION: test-flag-FC
155 > # @USAGE: <flag>
156 > # @DESCRIPTION:
157 > # Returns shell true if <flag> is supported by the Fortran 90 compiler, else returns shell false.
158 > -test-flag-FC() { test-flag-PROG "FC" f95 "$@"; }
159 > +test-flag-FC() { _test-flag-PROG "FC" f95 "$@"; }
160 >
161 > # @FUNCTION: test-flag-CCLD
162 > # @USAGE: <flag>
163 > # @DESCRIPTION:
164 > # Returns shell true if <flag> is supported by the C compiler and linker, else returns shell false.
165 > -test-flag-CCLD() { test-flag-PROG "CC" c+ld "$@"; }
166 > +test-flag-CCLD() { _test-flag-PROG "CC" c+ld "$@"; }
167 >
168 > +# @FUNCTION: test-flags-PROG
169 > +# @USAGE: <compiler> <flag> [more flags...]
170 > +# @INTERNAL
171 > +# @DESCRIPTION:
172 > +# Returns shell true if <flags> are supported by given <compiler>, else returns shell false.
173 > test-flags-PROG() {
174 > + [[ ${EAPI} == [0-7] ]] ||
175 > + die "Internal function ${FUNCNAME} is not available in >=EAPI-8."
176 > + _test-flags-PROG
177 > +}
178 > +
179 > +# @FUNCTION: _test-flags-PROG
180 > +# @USAGE: <compiler> <flag> [more flags...]
181 > +# @INTERNAL
182 > +# @DESCRIPTION:
183 > +# Returns shell true if <flags> are supported by given <compiler>, else returns shell false.
184 > +_test-flags-PROG() {
185 > local comp=$1
186 > local flags=()
187 > local x
188 > @@ -596,31 +660,31 @@ test-flags-PROG() {
189 > # @USAGE: <flags>
190 > # @DESCRIPTION:
191 > # Returns shell true if <flags> are supported by the C compiler, else returns shell false.
192 > -test-flags-CC() { test-flags-PROG "CC" "$@"; }
193 > +test-flags-CC() { _test-flags-PROG "CC" "$@"; }
194 >
195 > # @FUNCTION: test-flags-CXX
196 > # @USAGE: <flags>
197 > # @DESCRIPTION:
198 > # Returns shell true if <flags> are supported by the C++ compiler, else returns shell false.
199 > -test-flags-CXX() { test-flags-PROG "CXX" "$@"; }
200 > +test-flags-CXX() { _test-flags-PROG "CXX" "$@"; }
201 >
202 > # @FUNCTION: test-flags-F77
203 > # @USAGE: <flags>
204 > # @DESCRIPTION:
205 > # Returns shell true if <flags> are supported by the Fortran 77 compiler, else returns shell false.
206 > -test-flags-F77() { test-flags-PROG "F77" "$@"; }
207 > +test-flags-F77() { _test-flags-PROG "F77" "$@"; }
208 >
209 > # @FUNCTION: test-flags-FC
210 > # @USAGE: <flags>
211 > # @DESCRIPTION:
212 > # Returns shell true if <flags> are supported by the Fortran 90 compiler, else returns shell false.
213 > -test-flags-FC() { test-flags-PROG "FC" "$@"; }
214 > +test-flags-FC() { _test-flags-PROG "FC" "$@"; }
215 >
216 > # @FUNCTION: test-flags-CCLD
217 > # @USAGE: <flags>
218 > # @DESCRIPTION:
219 > # Returns shell true if <flags> are supported by the C compiler and default linker, else returns shell false.
220 > -test-flags-CCLD() { test-flags-PROG "CCLD" "$@"; }
221 > +test-flags-CCLD() { _test-flags-PROG "CCLD" "$@"; }
222 >
223 > # @FUNCTION: test-flags
224 > # @USAGE: <flags>
225
226
227 --
228
229 Sergei

Replies