scons-utils.eclass: _scons_clean_makeopts, clean up and simplify
authorMichał Górny <mgorny@gentoo.org>
Fri, 1 Jan 2016 13:03:19 +0000 (14:03 +0100)
committerMichał Górny <mgorny@gentoo.org>
Fri, 8 Jan 2016 05:14:36 +0000 (06:14 +0100)
eclass/scons-utils.eclass

index 82e45e3c080e624835ad499b479c48ef43a8de88..31852820472994815987f7c2f2205e2bcbda7856 100644 (file)
@@ -158,7 +158,7 @@ escons() {
 # gets an argument. Output the resulting flag list (suitable
 # for an assignment to SCONSOPTS).
 _scons_clean_makeopts() {
-       local new_makeopts
+       local new_makeopts=()
 
        debug-print-function ${FUNCNAME} "${@}"
 
@@ -183,16 +183,16 @@ _scons_clean_makeopts() {
                case ${1} in
                        # clean, simple to check -- we like that
                        --jobs=*|--keep-going)
-                               new_makeopts=${new_makeopts+${new_makeopts} }${1}
+                               new_makeopts+=( ${1} )
                                ;;
                        # need to take a look at the next arg and guess
                        --jobs)
                                if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
-                                       new_makeopts="${new_makeopts+${new_makeopts} }${1} ${2}"
+                                       new_makeopts+=( ${1} ${2} )
                                        shift
                                else
                                        # no value means no limit, let's pass a random int
-                                       new_makeopts=${new_makeopts+${new_makeopts} }${1}=5
+                                       new_makeopts+=( ${1}=5 )
                                fi
                                ;;
                        # strip other long options
@@ -207,20 +207,20 @@ _scons_clean_makeopts() {
                                while [[ -n ${str} ]]; do
                                        case ${str} in
                                                k*)
-                                                       new_optstr=${new_optstr}k
+                                                       new_optstr+=k
                                                        ;;
                                                # -j needs to come last
                                                j)
                                                        if [[ ${#} -gt 1 && ${2} =~ ^[0-9]+$ ]]; then
-                                                               new_optstr="${new_optstr}j ${2}"
+                                                               new_optstr+="j ${2}"
                                                                shift
                                                        else
-                                                               new_optstr="${new_optstr}j 5"
+                                                               new_optstr+="j 5"
                                                        fi
                                                        ;;
                                                # otherwise, everything after -j is treated as an arg
                                                j*)
-                                                       new_optstr=${new_optstr}${str}
+                                                       new_optstr+=${str}
                                                        break
                                                        ;;
                                        esac
@@ -228,17 +228,16 @@ _scons_clean_makeopts() {
                                done
 
                                if [[ -n ${new_optstr} ]]; then
-                                       new_makeopts=${new_makeopts+${new_makeopts} }-${new_optstr}
+                                       new_makeopts+=( -${new_optstr} )
                                fi
                                ;;
                esac
                shift
        done
 
-       set -- ${new_makeopts}
-       _SCONS_CACHE_SCONSOPTS=${*}
-       debug-print "New SCONSOPTS: [${*}]"
-       SCONSOPTS=${*}
+       SCONSOPTS=${new_makeopts[*]}
+       _SCONS_CACHE_SCONSOPTS=${SCONSOPTS}
+       debug-print "New SCONSOPTS: [${SCONSOPTS}]"
 }
 
 # @FUNCTION: use_scons