toolchain-external: reduce nesting in copy_toolchain_sysroot
authorThomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Tue, 7 Feb 2017 21:56:38 +0000 (22:56 +0100)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Wed, 1 Mar 2017 22:21:54 +0000 (23:21 +0100)
As discussed with Thomas Petazzoni, we can reduce the nesting level by early
returning on an invalid iteration.

I did not move the 'else' case (the common case) outside the if-else because
it would make the code less symmetrical and IMO makes it _less_ clear.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
toolchain/helpers.mk

index 72e7292353882f96a754c3d9312e616e191f726f..8cae996a31efc60b445386847ceca96e6c540629 100644 (file)
@@ -89,11 +89,12 @@ copy_toolchain_sysroot = \
        ARCH_LIB_DIR="$(strip $4)" ; \
        SUPPORT_LIB_DIR="$(strip $5)" ; \
        for i in etc $${ARCH_LIB_DIR} sbin usr usr/$${ARCH_LIB_DIR}; do \
-               if [ -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
-                       rsync -au --chmod=u=rwX,go=rX --exclude 'usr/lib/locale' \
-                               --include '/libexec*/' --exclude '/lib*/' \
-                               $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
+               if [ ! -d $${ARCH_SYSROOT_DIR}/$$i ] ; then \
+                       continue ; \
                fi ; \
+               rsync -au --chmod=u=rwX,go=rX --exclude 'usr/lib/locale' \
+                       --include '/libexec*/' --exclude '/lib*/' \
+                       $${ARCH_SYSROOT_DIR}/$$i/ $(STAGING_DIR)/$$i/ ; \
        done ; \
        if [ `readlink -f $${SYSROOT_DIR}` != `readlink -f $${ARCH_SYSROOT_DIR}` ] ; then \
                if [ ! -d $${ARCH_SYSROOT_DIR}/usr/include ] ; then \