multilib.eclass: consolidate save/restore list
authorSergei Trofimovich <slyfox@gentoo.org>
Sun, 24 May 2020 20:37:10 +0000 (21:37 +0100)
committerSergei Trofimovich <slyfox@gentoo.org>
Sun, 24 May 2020 21:03:30 +0000 (22:03 +0100)
To avoid duplicating save/restore variable lists
gathered the list into a separate helper local variables.

This change is a no-op.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
eclass/multilib.eclass

index 857829dd17b256a8a08636db899914dfdb311fe4..e13aae2bb7f7dc7bcb8e6ed5e333bf90435bb2e6 100644 (file)
@@ -456,9 +456,21 @@ multilib_toolchain_setup() {
 
        export ABI=$1
 
+       local save_restore_variables=(
+               CBUILD
+               CHOST
+               CC
+               CXX
+               F77
+               FC
+               LD
+               PKG_CONFIG_LIBDIR
+               PKG_CONFIG_PATH
+       )
+
        # First restore any saved state we have laying around.
        if [[ ${_DEFAULT_ABI_SAVED} == "true" ]] ; then
-               for v in CHOST CBUILD CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH} ; do
+               for v in "${save_restore_variables[@]}" ; do
                        vv="_abi_saved_${v}"
                        [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v}
                        unset ${vv}
@@ -468,7 +480,7 @@ multilib_toolchain_setup() {
 
        if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
                # Back that multilib-ass up so we can restore it later
-               for v in CHOST CBUILD CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH} ; do
+               for v in "${save_restore_variables[@]}" ; do
                        vv="_abi_saved_${v}"
                        [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv}
                done
@@ -481,6 +493,8 @@ multilib_toolchain_setup() {
 
                # Set the CHOST native first so that we pick up the native
                # toolchain and not a cross-compiler by accident #202811.
+               #
+               # Make sure ${save_restore_variables[@]} list matches below.
                export CHOST=$(get_abi_CHOST ${DEFAULT_ABI})
                export AR="$(tc-getAR)" # Avoid 'ar', use '${CHOST}-ar'
                export CC="$(tc-getCC) $(get_abi_CFLAGS)"