1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/scons-utils.eclass | 102 ++---------------------------------- |
4 |
eclass/tests/scons-utils.sh | 64 ---------------------- |
5 |
2 files changed, 4 insertions(+), 162 deletions(-) |
6 |
delete mode 100755 eclass/tests/scons-utils.sh |
7 |
|
8 |
diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass |
9 |
index cbe92f6fc385..acb51300f348 100644 |
10 |
--- a/eclass/scons-utils.eclass |
11 |
+++ b/eclass/scons-utils.eclass |
12 |
@@ -71,8 +71,8 @@ |
13 |
# @DEFAULT_UNSET |
14 |
# @DESCRIPTION: |
15 |
# The default set of options to pass to scons. Similar to MAKEOPTS, |
16 |
-# supposed to be set in make.conf. If unset, escons() will use cleaned |
17 |
-# up MAKEOPTS instead. |
18 |
+# supposed to be set in make.conf. If unset, escons() will set -j |
19 |
+# based on MAKEOPTS. |
20 |
|
21 |
# @ECLASS_VARIABLE: EXTRA_ESCONS |
22 |
# @USER_VARIABLE |
23 |
@@ -148,11 +148,8 @@ escons() { |
24 |
die "EPYTHON unset in escons" |
25 |
fi |
26 |
|
27 |
- # if SCONSOPTS are _unset_, use cleaned MAKEOPTS |
28 |
- if [[ ! ${SCONSOPTS+set} ]]; then |
29 |
- local SCONSOPTS |
30 |
- _scons_clean_makeopts |
31 |
- fi |
32 |
+ # if SCONSOPTS are unset, grab -j from MAKEOPTS |
33 |
+ : "${SCONSOPTS:=-j$(makeopts_jobs)}" |
34 |
|
35 |
# pass ebuild environment variables through! |
36 |
local -x GENTOO_SCONS_ENV_PASSTHROUGH=1 |
37 |
@@ -161,94 +158,3 @@ escons() { |
38 |
echo "${@}" >&2 |
39 |
"${@}" || die -n "escons failed." |
40 |
} |
41 |
- |
42 |
-# @FUNCTION: _scons_clean_makeopts |
43 |
-# @USAGE: [makeflags] [...] |
44 |
-# @INTERNAL |
45 |
-# @DESCRIPTION: |
46 |
-# Strip the supplied makeflags (or ${MAKEOPTS} if called without |
47 |
-# an argument) of options not supported by SCons and make sure --jobs |
48 |
-# gets an argument. Output the resulting flag list (suitable |
49 |
-# for an assignment to SCONSOPTS). |
50 |
-_scons_clean_makeopts() { |
51 |
- local new_makeopts=() |
52 |
- |
53 |
- debug-print-function ${FUNCNAME} "${@}" |
54 |
- |
55 |
- if [[ ${#} -eq 0 ]]; then |
56 |
- debug-print "Using MAKEOPTS: [${MAKEOPTS}]" |
57 |
- set -- ${MAKEOPTS} |
58 |
- else |
59 |
- # unquote if necessary |
60 |
- set -- ${*} |
61 |
- fi |
62 |
- |
63 |
- # empty MAKEOPTS give out empty SCONSOPTS |
64 |
- # thus, we do need to worry about the initial setup |
65 |
- if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then |
66 |
- SCONSOPTS=${_SCONS_CACHE_SCONSOPTS} |
67 |
- debug-print "Cache hit: [${SCONSOPTS}]" |
68 |
- return |
69 |
- fi |
70 |
- _SCONS_CACHE_MAKEOPTS=${*} |
71 |
- |
72 |
- while [[ ${#} -gt 0 ]]; do |
73 |
- case ${1} in |
74 |
- # clean, simple to check -- we like that |
75 |
- --jobs=*|--keep-going) |
76 |
- new_makeopts+=( ${1} ) |
77 |
- ;; |
78 |
- # need to take a look at the next arg and guess |
79 |
- --jobs) |
80 |
- if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then |
81 |
- new_makeopts+=( ${1} ${2} ) |
82 |
- shift |
83 |
- else |
84 |
- # no value means no limit, let's pass a default instead |
85 |
- new_makeopts+=( ${1}=$(( $(get_nproc) + 1 )) ) |
86 |
- fi |
87 |
- ;; |
88 |
- # strip other long options |
89 |
- --*) |
90 |
- ;; |
91 |
- # short option hell |
92 |
- -*) |
93 |
- local str new_optstr |
94 |
- new_optstr= |
95 |
- str=${1#-} |
96 |
- |
97 |
- while [[ -n ${str} ]]; do |
98 |
- case ${str} in |
99 |
- k*) |
100 |
- new_optstr+=k |
101 |
- ;; |
102 |
- # -j needs to come last |
103 |
- j) |
104 |
- if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then |
105 |
- new_optstr+="j ${2}" |
106 |
- shift |
107 |
- else |
108 |
- new_optstr+="j $(( $(get_nproc) + 1 ))" |
109 |
- fi |
110 |
- ;; |
111 |
- # otherwise, everything after -j is treated as an arg |
112 |
- j*) |
113 |
- new_optstr+=${str} |
114 |
- break |
115 |
- ;; |
116 |
- esac |
117 |
- str=${str#?} |
118 |
- done |
119 |
- |
120 |
- if [[ -n ${new_optstr} ]]; then |
121 |
- new_makeopts+=( -${new_optstr} ) |
122 |
- fi |
123 |
- ;; |
124 |
- esac |
125 |
- shift |
126 |
- done |
127 |
- |
128 |
- SCONSOPTS=${new_makeopts[*]} |
129 |
- _SCONS_CACHE_SCONSOPTS=${SCONSOPTS} |
130 |
- debug-print "New SCONSOPTS: [${SCONSOPTS}]" |
131 |
-} |
132 |
diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh |
133 |
deleted file mode 100755 |
134 |
index 5f1cd2036047..000000000000 |
135 |
--- a/eclass/tests/scons-utils.sh |
136 |
+++ /dev/null |
137 |
@@ -1,64 +0,0 @@ |
138 |
-#!/bin/bash |
139 |
-# Copyright 1999-2021 Gentoo Authors |
140 |
-# Distributed under the terms of the GNU General Public License v2 |
141 |
- |
142 |
-EAPI=7 |
143 |
-_PYTHON_R1=1 |
144 |
-source tests-common.sh || exit |
145 |
- |
146 |
-inherit scons-utils |
147 |
- |
148 |
-test-scons_clean_makeopts() { |
149 |
- tbegin "scons_clean_makeopts() for ${1}" |
150 |
- |
151 |
- local SCONSOPTS ret=0 |
152 |
- _scons_clean_makeopts ${1} |
153 |
- |
154 |
- if [[ ${SCONSOPTS} != ${2-${1}} ]]; then |
155 |
- eerror "Self-test failed:" |
156 |
- eindent |
157 |
- eerror "MAKEOPTS: ${1}" |
158 |
- eerror "Expected: ${2-${1}}" |
159 |
- eerror "Actual: ${SCONSOPTS}" |
160 |
- eoutdent |
161 |
- ret=1 |
162 |
- fi |
163 |
- |
164 |
- tend ${ret} |
165 |
- return ${ret} |
166 |
-} |
167 |
- |
168 |
-# jobcount expected for non-specified state |
169 |
-jc=$(( $(get_nproc) + 1 )) |
170 |
-# failed test counter |
171 |
-failed=0 |
172 |
- |
173 |
-# sane MAKEOPTS |
174 |
-test-scons_clean_makeopts '--jobs=14 -k' |
175 |
-test-scons_clean_makeopts '--jobs=14 -k' |
176 |
-test-scons_clean_makeopts '--jobs 15 -k' |
177 |
-test-scons_clean_makeopts '--jobs=16 --keep-going' |
178 |
-test-scons_clean_makeopts '-j17 --keep-going' |
179 |
-test-scons_clean_makeopts '-j 18 --keep-going' |
180 |
- |
181 |
-# needing cleaning |
182 |
-test-scons_clean_makeopts '--jobs -k' "--jobs=${jc} -k" |
183 |
-test-scons_clean_makeopts '--jobs --keep-going' "--jobs=${jc} --keep-going" |
184 |
-test-scons_clean_makeopts '-kj' "-kj ${jc}" |
185 |
- |
186 |
-# broken by definition (but passed as it breaks make as well) |
187 |
-test-scons_clean_makeopts '-jk' |
188 |
-test-scons_clean_makeopts '--jobs=randum' |
189 |
-test-scons_clean_makeopts '-kjrandum' |
190 |
- |
191 |
-# needing stripping |
192 |
-test-scons_clean_makeopts '--load-average=25 -kj16' '-kj16' |
193 |
-test-scons_clean_makeopts '--load-average 25 -k -j17' '-k -j17' |
194 |
-test-scons_clean_makeopts '-j2 HOME=/tmp' '-j2' |
195 |
-test-scons_clean_makeopts '--jobs funnystuff -k' "--jobs=${jc} -k" |
196 |
- |
197 |
-# bug #388961 |
198 |
-test-scons_clean_makeopts '--jobs -l3' "--jobs=${jc}" |
199 |
-test-scons_clean_makeopts '-j -l3' "-j ${jc}" |
200 |
- |
201 |
-texit |
202 |
-- |
203 |
2.38.1 |