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 1/6] scons-utils.eclass: Remove support for EAPI 0..6
Date: Fri, 28 Oct 2022 17:51:42
Message-Id: 20221028175111.5064-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/6] scons-utils.eclass: EAPI 8 support and cleanup by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/scons-utils.eclass | 126 +++++---------------------------------
4 1 file changed, 17 insertions(+), 109 deletions(-)
5
6 diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
7 index ff6550ae048a..ef26b564fb8c 100644
8 --- a/eclass/scons-utils.eclass
9 +++ b/eclass/scons-utils.eclass
10 @@ -4,7 +4,7 @@
11 # @ECLASS: scons-utils.eclass
12 # @MAINTAINER:
13 # mgorny@g.o
14 -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
15 +# @SUPPORTED_EAPIS: 7
16 # @BLURB: helper functions to deal with SCons buildsystem
17 # @DESCRIPTION:
18 # This eclass provides a set of function to help developers sanely call
19 @@ -38,7 +38,7 @@
20 # PYTHON_COMPAT=( python2_7 )
21 # inherit python-any-r1 scons-utils toolchain-funcs
22 #
23 -# EAPI=5
24 +# EAPI=7
25 #
26 # src_configure() {
27 # MYSCONS=(
28 @@ -64,14 +64,6 @@
29 # @DESCRIPTION:
30 # The minimal version of SCons required for the build to work.
31
32 -# @VARIABLE: myesconsargs
33 -# @DEFAULT_UNSET
34 -# @DESCRIPTION:
35 -# DEPRECATED, EAPI 0..5 ONLY: pass options to escons instead
36 -#
37 -# List of package-specific options to pass to all SCons calls. Supposed to be
38 -# set in src_configure().
39 -
40 # @ECLASS_VARIABLE: SCONSOPTS
41 # @USER_VARIABLE
42 # @DEFAULT_UNSET
43 @@ -88,24 +80,10 @@
44 # Much like EXTRA_EMAKE, this is not supposed to be used in make.conf
45 # and not in ebuilds!
46
47 -# @ECLASS_VARIABLE: USE_SCONS_TRUE
48 -# @DESCRIPTION:
49 -# DEPRECATED: use usex instead
50 -#
51 -# The default value for truth in scons-use() (1 by default).
52 -: ${USE_SCONS_TRUE:=1}
53 -
54 -# @ECLASS_VARIABLE: USE_SCONS_FALSE
55 -# @DESCRIPTION:
56 -# DEPRECATED: use usex instead
57 -#
58 -# The default value for false in scons-use() (0 by default).
59 -: ${USE_SCONS_FALSE:=0}
60 -
61 # -- EAPI support check --
62
63 case ${EAPI:-0} in
64 - 0|1|2|3|4|5|6|7) ;;
65 + 7) ;;
66 *) die "EAPI ${EAPI} unsupported."
67 esac
68
69 @@ -132,16 +110,13 @@ elif [[ ${_PYTHON_SINGLE_R1} ]]; then
70 BDEPEND="
71 $(python_gen_cond_dep "${SCONS_DEPEND}[\${PYTHON_USEDEP}]")
72 ${PYTHON_DEPS}"
73 -elif [[ ${EAPI:-0} == [0123456] ]]; then
74 - # in older EAPIs, just force Python 2.7
75 - BDEPEND="${SCONS_DEPEND}[python_targets_python2_7]"
76 elif [[ ${_PYTHON_R1} ]]; then
77 # when using python-r1, you need to depend on scons yourself
78 # (depending on whether you need any-r1 or full -r1 API)
79 # -- since this is a breaking API change, it applies to EAPI 7+ only
80 BDEPEND=""
81 -elif [[ ${EAPI:-0} != [0123456] ]]; then
82 - # in EAPI 7+, require appropriate eclass use
83 +else
84 + # require appropriate eclass use
85 eerror "Using scons-utils.eclass without any python-r1 suite eclass is not supported."
86 eerror "Please make sure to configure and inherit appropriate -r1 eclass."
87 eerror "For more information and examples, please see:"
88 @@ -149,44 +124,30 @@ elif [[ ${EAPI:-0} != [0123456] ]]; then
89 die "Invalid use of scons-utils.eclass"
90 fi
91
92 -if [[ ${EAPI:-0} == [0123456] ]]; then
93 - DEPEND=${BDEPEND}
94 - unset BDEPEND
95 -fi
96 -
97 # -- public functions --
98
99 # @FUNCTION: escons
100 # @USAGE: [<args>...]
101 # @DESCRIPTION:
102 # Call scons, passing the supplied arguments. Like emake, this function
103 -# does die on failure in EAPI 4. Respects nonfatal in EAPI 6 and newer.
104 +# dies on failure, unless nonfatal is used.
105 escons() {
106 local ret
107
108 debug-print-function ${FUNCNAME} "${@}"
109
110 if [[ ! ${EPYTHON} ]]; then
111 - if [[ ${EAPI:-0} != [0123456] ]]; then
112 - eerror "EPYTHON is unset while calling escons. This most likely means that"
113 - eerror "the ebuild did not call the appropriate eclass function before calling scons."
114 - if [[ ${_PYTHON_ANY_R1} ]]; then
115 - eerror "Please ensure that python-any-r1_pkg_setup is called in pkg_setup()."
116 - elif [[ ${_PYTHON_SINGLE_R1} ]]; then
117 - eerror "Please ensure that python-single-r1_pkg_setup is called in pkg_setup()."
118 - else # python-r1
119 - eerror "Please ensure that python_setup is called before escons, or that escons"
120 - eerror "is used within python_foreach_impl as appropriate."
121 - fi
122 - die "EPYTHON unset in escons"
123 - else
124 - local -x EPYTHON=python2.7
125 + eerror "EPYTHON is unset while calling escons. This most likely means that"
126 + eerror "the ebuild did not call the appropriate eclass function before calling scons."
127 + if [[ ${_PYTHON_ANY_R1} ]]; then
128 + eerror "Please ensure that python-any-r1_pkg_setup is called in pkg_setup()."
129 + elif [[ ${_PYTHON_SINGLE_R1} ]]; then
130 + eerror "Please ensure that python-single-r1_pkg_setup is called in pkg_setup()."
131 + else # python-r1
132 + eerror "Please ensure that python_setup is called before escons, or that escons"
133 + eerror "is used within python_foreach_impl as appropriate."
134 fi
135 - fi
136 -
137 - # Use myesconsargs in EAPI 5 and older
138 - if [[ ${EAPI} == [012345] ]]; then
139 - set -- "${myesconsargs[@]}" "${@}"
140 + die "EPYTHON unset in escons"
141 fi
142
143 # if SCONSOPTS are _unset_, use cleaned MAKEOPTS
144 @@ -200,22 +161,7 @@ escons() {
145
146 set -- scons ${SCONSOPTS} ${EXTRA_ESCONS} "${@}"
147 echo "${@}" >&2
148 - "${@}"
149 - ret=${?}
150 -
151 - if [[ ${ret} -ne 0 ]]; then
152 - case "${EAPI:-0}" in
153 - 0|1|2|3) # nonfatal in EAPIs 0 through 3
154 - ;;
155 - 4|5) # 100% fatal in 4 & 5
156 - die "escons failed."
157 - ;;
158 - *) # respect nonfatal in 6 onwards
159 - die -n "escons failed."
160 - ;;
161 - esac
162 - fi
163 - return ${ret}
164 + "${@}" || die -n "escons failed."
165 }
166
167 # @FUNCTION: _scons_clean_makeopts
168 @@ -308,41 +254,3 @@ _scons_clean_makeopts() {
169 _SCONS_CACHE_SCONSOPTS=${SCONSOPTS}
170 debug-print "New SCONSOPTS: [${SCONSOPTS}]"
171 }
172 -
173 -# @FUNCTION: use_scons
174 -# @USAGE: <use-flag> [var-name] [var-opt-true] [var-opt-false]
175 -# @DESCRIPTION:
176 -# DEPRECATED, EAPI 0..5 ONLY: use usex instead
177 -#
178 -# Output a SCons parameter with value depending on the USE flag state.
179 -# If the USE flag is set, output <var-name>=<var-opt-true>; otherwise
180 -# <var-name>=<var-opt-false>.
181 -#
182 -# If <var-name> is omitted, <use-flag> will be used instead. However,
183 -# if <use-flag> starts with an exclamation mark (!flag), 'no' will be
184 -# prepended to the name (e.g. noflag).
185 -#
186 -# If <var-opt-true> and/or <var-opt-false> are omitted,
187 -# ${USE_SCONS_TRUE} and/or ${USE_SCONS_FALSE} will be used instead.
188 -use_scons() {
189 - [[ ${EAPI} == [012345] ]] \
190 - || die "${FUNCNAME} is banned in EAPI ${EAPI}, use usex instead"
191 -
192 - local flag=${1}
193 - local varname=${2:-${flag/\!/no}}
194 - local vartrue=${3:-${USE_SCONS_TRUE}}
195 - local varfalse=${4:-${USE_SCONS_FALSE}}
196 -
197 - debug-print-function ${FUNCNAME} "${@}"
198 -
199 - if [[ ${#} -eq 0 ]]; then
200 - eerror "Usage: scons-use <use-flag> [var-name] [var-opt-true] [var-opt-false]"
201 - die 'scons-use(): not enough arguments'
202 - fi
203 -
204 - if use "${flag}"; then
205 - echo "${varname}=${vartrue}"
206 - else
207 - echo "${varname}=${varfalse}"
208 - fi
209 -}
210 --
211 2.38.1