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 11/15] scons-utils.eclass: _scons_clean_makeopts, fix result caching
Date: Fri, 01 Jan 2016 16:48:23
Message-Id: 1451666481-22145-12-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 00/15] scons-utils.eclass: EAPI 6, better docs and cleanup by "Michał Górny"
1 Stop calling _scons_clean_makeopts in a subshell in order to make
2 it possible for the cache to be preserved. Pass the result through
3 SCONSOPTS variable.
4 ---
5 eclass/scons-utils.eclass | 15 +++++++++------
6 eclass/tests/scons-utils.sh | 7 ++++---
7 2 files changed, 13 insertions(+), 9 deletions(-)
8
9 diff --git a/eclass/scons-utils.eclass b/eclass/scons-utils.eclass
10 index e5e309b..4da2c4a 100644
11 --- a/eclass/scons-utils.eclass
12 +++ b/eclass/scons-utils.eclass
13 @@ -124,8 +124,12 @@ escons() {
14 fi
15
16 # if SCONSOPTS are _unset_, use cleaned MAKEOPTS
17 - set -- scons ${SCONSOPTS-$(_scons_clean_makeopts)} ${EXTRA_ESCONS} \
18 - "${@}"
19 + if [[ ! ${SCONSOPTS+set} ]]; then
20 + local SCONSOPTS
21 + _scons_clean_makeopts
22 + fi
23 +
24 + set -- scons ${SCONSOPTS} ${EXTRA_ESCONS} "${@}"
25 echo "${@}" >&2
26 "${@}"
27 ret=${?}
28 @@ -169,9 +173,8 @@ _scons_clean_makeopts() {
29 # empty MAKEOPTS give out empty SCONSOPTS
30 # thus, we do need to worry about the initial setup
31 if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
32 - set -- ${_SCONS_CACHE_SCONSOPTS}
33 - debug-print "Cache hit: [${*}]"
34 - echo ${*}
35 + SCONSOPTS=${_SCONS_CACHE_SCONSOPTS}
36 + debug-print "Cache hit: [${SCONSOPTS}]"
37 return
38 fi
39 export _SCONS_CACHE_MAKEOPTS=${*}
40 @@ -235,7 +238,7 @@ _scons_clean_makeopts() {
41 set -- ${new_makeopts}
42 export _SCONS_CACHE_SCONSOPTS=${*}
43 debug-print "New SCONSOPTS: [${*}]"
44 - echo ${*}
45 + SCONSOPTS=${*}
46 }
47
48 # @FUNCTION: use_scons
49 diff --git a/eclass/tests/scons-utils.sh b/eclass/tests/scons-utils.sh
50 index df8af7a..6355c54 100755
51 --- a/eclass/tests/scons-utils.sh
52 +++ b/eclass/tests/scons-utils.sh
53 @@ -10,14 +10,15 @@ inherit scons-utils
54 test-scons_clean_makeopts() {
55 tbegin "scons_clean_makeopts() for ${1}"
56
57 - local sconsopts=$(_scons_clean_makeopts ${1}) ret=0
58 + local SCONSOPTS ret=0
59 + _scons_clean_makeopts ${1}
60
61 - if [[ ${sconsopts} != ${2-${1}} ]]; then
62 + if [[ ${SCONSOPTS} != ${2-${1}} ]]; then
63 eerror "Self-test failed:"
64 eindent
65 eerror "MAKEOPTS: ${1}"
66 eerror "Expected: ${2-${1}}"
67 - eerror "Actual: ${sconsopts}"
68 + eerror "Actual: ${SCONSOPTS}"
69 eoutdent
70 ret=1
71 fi
72 --
73 2.6.4