scripts: function adjustment and remove staging dir last time [1/1]

PD#SWPL-163329

Problem:
building will fail because last build remain the staging dir

Solution:
remove staging dir in last build

Verify:
local

Change-Id: Ie5acfb09af45027d567f12f197ec4001af0d304a
Signed-off-by: Dezhen Wang <dezhen.wang@amlogic.com>
diff --git a/amlogic_utils.sh b/amlogic_utils.sh
index edbc452..657de18 100644
--- a/amlogic_utils.sh
+++ b/amlogic_utils.sh
@@ -221,6 +221,10 @@
 	echo EXT_MODULES=${EXT_MODULES}
 
 	rm ${temp_file}
+
+	if [[ -d ${MODULES_STAGING_DIR} ]]; then
+		rm -rf ${MODULES_STAGING_DIR}
+	fi
 }
 export -f prepare_module_build
 
@@ -1883,9 +1887,11 @@
 
 function build_kernel_for_32bit () {
 	set -x
+	pre_defconfig_cmds
 	if [ "${SKIP_DEFCONFIG}" != "1" ] ; then
   		(cd ${KERNEL_DIR} && make ARCH=arm ${TOOL_ARGS} O=${OUT_DIR} "${MAKE_ARGS[@]}" ${DEFCONFIG})
 	fi
+	post_defconfig_cmds
 
 	echo "========================================================"
 	echo " Building kernel"
@@ -1917,8 +1923,6 @@
 
 	source ${KERNEL_DIR}/${COMMON_DRIVERS_DIR}/build.config.amlogic32
 
-	pre_defconfig_cmds
-
 	CC_CLANG=1
 
 	set_default_parameters_for_32bit
@@ -1933,8 +1937,6 @@
 
 	build_kernel_for_32bit
 
-	post_defconfig_cmds
-
 	eval ${POST_KERNEL_BUILD_CMDS}
 
 	modules_install_for_32bit