Skip to content

Commit

Permalink
scons-utils.eclass: _scons_clean_makeopts, fix result caching
Browse files Browse the repository at this point in the history
Stop calling _scons_clean_makeopts in a subshell in order to make
it possible for the cache to be preserved. Pass the result through
SCONSOPTS variable.
  • Loading branch information
mgorny committed Jan 8, 2016
1 parent a4de8aa commit de0c03e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 9 additions & 6 deletions eclass/scons-utils.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ escons() {
fi

# if SCONSOPTS are _unset_, use cleaned MAKEOPTS
set -- scons ${SCONSOPTS-$(_scons_clean_makeopts)} ${EXTRA_ESCONS} \
"${@}"
if [[ ! ${SCONSOPTS+set} ]]; then
local SCONSOPTS
_scons_clean_makeopts
fi

set -- scons ${SCONSOPTS} ${EXTRA_ESCONS} "${@}"
echo "${@}" >&2
"${@}"
ret=${?}
Expand Down Expand Up @@ -169,9 +173,8 @@ _scons_clean_makeopts() {
# empty MAKEOPTS give out empty SCONSOPTS
# thus, we do need to worry about the initial setup
if [[ ${*} = ${_SCONS_CACHE_MAKEOPTS} ]]; then
set -- ${_SCONS_CACHE_SCONSOPTS}
debug-print "Cache hit: [${*}]"
echo ${*}
SCONSOPTS=${_SCONS_CACHE_SCONSOPTS}
debug-print "Cache hit: [${SCONSOPTS}]"
return
fi
export _SCONS_CACHE_MAKEOPTS=${*}
Expand Down Expand Up @@ -235,7 +238,7 @@ _scons_clean_makeopts() {
set -- ${new_makeopts}
export _SCONS_CACHE_SCONSOPTS=${*}
debug-print "New SCONSOPTS: [${*}]"
echo ${*}
SCONSOPTS=${*}
}

# @FUNCTION: use_scons
Expand Down
7 changes: 4 additions & 3 deletions eclass/tests/scons-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ inherit scons-utils
test-scons_clean_makeopts() {
tbegin "scons_clean_makeopts() for ${1}"

local sconsopts=$(_scons_clean_makeopts ${1}) ret=0
local SCONSOPTS ret=0
_scons_clean_makeopts ${1}

if [[ ${sconsopts} != ${2-${1}} ]]; then
if [[ ${SCONSOPTS} != ${2-${1}} ]]; then
eerror "Self-test failed:"
eindent
eerror "MAKEOPTS: ${1}"
eerror "Expected: ${2-${1}}"
eerror "Actual: ${sconsopts}"
eerror "Actual: ${SCONSOPTS}"
eoutdent
ret=1
fi
Expand Down

0 comments on commit de0c03e

Please sign in to comment.