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