scons-utils.eclass: _scons_clean_makeopts, fix result caching
authorMichał Górny <mgorny@gentoo.org>
Fri, 1 Jan 2016 12:55:26 +0000 (13:55 +0100)
committerMichał Górny <mgorny@gentoo.org>
Fri, 8 Jan 2016 05:14:36 +0000 (06:14 +0100)
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.

eclass/scons-utils.eclass
eclass/tests/scons-utils.sh

index e5e309be13c40151b116d4db0578136873de7080..4da2c4ac7a5c92b3b8fbc0584c35c18dbc65d041 100644 (file)
@@ -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=${?}
@@ -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=${*}
@@ -235,7 +238,7 @@ _scons_clean_makeopts() {
        set -- ${new_makeopts}
        export _SCONS_CACHE_SCONSOPTS=${*}
        debug-print "New SCONSOPTS: [${*}]"
-       echo ${*}
+       SCONSOPTS=${*}
 }
 
 # @FUNCTION: use_scons
index df8af7a7713c821aa230fca5f53143309e6e0e50..6355c54517dba731d8542a318f17b024ffed42e6 100755 (executable)
@@ -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