script: build-rpi4: Update script to clarify build errors 03/285003/3
authorHoegeun Kwon <hoegeun.kwon@samsung.com>
Fri, 2 Dec 2022 08:35:12 +0000 (17:35 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Mon, 5 Dec 2022 04:51:13 +0000 (13:51 +0900)
Update script to clarify build errors, also do not remove dtb files to
eliminate unnecessary rebuilds.

Change-Id: I34685c2b0dfa25d79a79795b24d18a64465ed4a3
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
build-rpi4.sh

index 45c1e8e..5ffc9ed 100755 (executable)
@@ -1,5 +1,9 @@
 #!/bin/bash
 
+COLOR_RED_BG=$(tput setab 1)
+COLOR_RED_BOLD=$(tput bold)$(tput setaf 1)
+COLOR_RESET=$(tput sgr0)
+
 NCPUS=`cat /proc/cpuinfo | grep processor | wc -l`
 NCPUS=$(($NCPUS * 2))
 
@@ -50,36 +54,28 @@ else
        echo "NORMAL" > ./.kernel_buildenv
 fi
 
+
 if [ $1 = "arm" ]; then
+       arch="arm"
+       cross_compile="${CCACHE} arm-linux-gnueabi-"
        echo "ARM"
-
-       rm -f arch/arm/boot/zImage
-       rm -f arch/arm/boot/dts/*.dtb
-
-       if ! [ -e .config ] ; then
-               make ARCH=arm CROSS_COMPILE="${CCACHE} arm-linux-gnueabi-" ${DEFCONFIG}
-       fi
-
-       make ARCH=arm CROSS_COMPILE="${CCACHE} arm-linux-gnueabi-" -j $NCPUS
-
-       if [ ! -f "./arch/arm/boot/zImage" ]; then
-               echo "Build fail"
-               exit 1
-       fi
 elif [ $1 = "arm64" ]; then
+       arch="arm64"
+       cross_compile="${CCACHE} aarch64-linux-gnu-"
        echo "ARM64"
+fi
 
-       rm -f arch/arm64/boot/Image
-       rm -f arch/arm64/boot/dts/broadcom/*.dtb
+if ! [ -e .config ] ; then
+       make ARCH="${arch}" CROSS_COMPILE="${cross_compile}" ${DEFCONFIG}
+fi
 
-       if ! [ -e .config ] ; then
-               make ARCH=arm64 CROSS_COMPILE="${CCACHE} aarch64-linux-gnu-" ${DEFCONFIG}
-       fi
-       make ARCH=arm64 CROSS_COMPILE="${CCACHE} aarch64-linux-gnu-" -j $NCPUS
-       if [ ! -f "./arch/arm64/boot/Image" ]; then
-               echo "Build fail"
-               exit 1
-       fi
+make ARCH="${arch}" CROSS_COMPILE="${cross_compile}" -j ${NCPUS} 2>&1 | \
+sed -e "/error:.*/{s/^.*error:/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}" \
+       -e "/Error.*/{s/^.*Error:/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}" \
+       -e "/ERROR.*/{s/^.*ERROR/$(echo -e "${COLOR_RED_BG}&${COLOR_RESET}")/g;q1}"
+if [ $? -ne 0 ]; then
+       echo -e "${COLOR_RED_BOLD}Failed to build${COLOR_RESET}"
+       exit 1
 fi
 
 scripts/mkbootimg_rpi4.sh