@@ -84,26 +84,33 @@ build_linux() {
8484 # info "Cleaning Linux: make distclean"
8585 # make distclean || true
8686
87- if [[ ${# commands[@]} -eq 0 ]] || [[ " ${commands[0]} " == " all" ]]; then
88- info " Configuring Linux: make ARCH=${linux_arch} CROSS_COMPILE=${cross_compile} ${defconfig} "
89- make ARCH=" ${linux_arch} " CROSS_COMPILE=" ${cross_compile} " " ${defconfig} "
90- fi
91-
92- info " Building Linux: make -j$( nproc) ARCH=${linux_arch} CROSS_COMPILE=${cross_compile} ${commands[@]} "
93- make -j" $( nproc) " ARCH=" ${linux_arch} " CROSS_COMPILE=" ${cross_compile} " " ${commands[@]} "
94-
95- popd > /dev/null
96-
97- # If it's a full build, copy the image and create the root filesystem
98- if [[ ${# commands[@]} -eq 0 ]] || [[ " ${commands[0]} " == " all" ]]; then
99- mkdir -p " ${LINUX_IMAGES_DIR} /${ARCH:- } "
100- KIMG_PATH=" ${LINUX_SRC_DIR} /${kimg_subpath} "
101- [[ -f " ${KIMG_PATH} " ]] || die " Kernel image not found: ${KIMG_PATH} "
102- info " Copying image: ${KIMG_PATH} -> ${LINUX_IMAGES_DIR} /${ARCH:- } "
103- cp -f " ${KIMG_PATH} " " ${LINUX_IMAGES_DIR} /${ARCH:- } /"
87+ if [[ " $@ " != * " clean" * ]]; then
88+ if [[ ${# commands[@]} -eq 0 ]] || [[ " ${commands[0]} " == " all" ]]; then
89+ info " Configuring Linux: make ARCH=${linux_arch} CROSS_COMPILE=${cross_compile} ${defconfig} "
90+ make ARCH=" ${linux_arch} " CROSS_COMPILE=" ${cross_compile} " " ${defconfig} "
91+ fi
92+
93+ info " Building Linux: make -j$( nproc) ARCH=${linux_arch} CROSS_COMPILE=${cross_compile} ${commands[@]} "
94+ make -j" $( nproc) " ARCH=" ${linux_arch} " CROSS_COMPILE=" ${cross_compile} " " ${commands[@]} "
10495
105- info " Creating root filesystem: ${SCRIPT_DIR} /mkfs.sh -> ${LINUX_IMAGES_DIR} /${ARCH:- } "
106- build_rootfs
96+ popd > /dev/null
97+
98+ # If it's a full build, copy the image and create the root filesystem
99+ if [[ ${# commands[@]} -eq 0 ]] || [[ " ${commands[0]} " == " all" ]]; then
100+ mkdir -p " ${LINUX_IMAGES_DIR} /${ARCH:- } "
101+ KIMG_PATH=" ${LINUX_SRC_DIR} /${kimg_subpath} "
102+ [[ -f " ${KIMG_PATH} " ]] || die " Kernel image not found: ${KIMG_PATH} "
103+ info " Copying image: ${KIMG_PATH} -> ${LINUX_IMAGES_DIR} /${ARCH:- } "
104+ cp -f " ${KIMG_PATH} " " ${LINUX_IMAGES_DIR} /${ARCH:- } /"
105+
106+ info " Creating root filesystem: ${SCRIPT_DIR} /mkfs.sh -> ${LINUX_IMAGES_DIR} /${ARCH:- } "
107+ build_rootfs
108+ fi
109+ else
110+ info " Building Linux: make -j$( nproc) ARCH=${linux_arch} CROSS_COMPILE=${cross_compile} clean"
111+ make -j" $( nproc) " ARCH=" ${linux_arch} " CROSS_COMPILE=" ${cross_compile} " " clean"
112+ info " Removing ${LINUX_IMAGES_DIR} /*"
113+ rm ${LINUX_IMAGES_DIR} /${ARCH:- } /* || true
107114 fi
108115}
109116
@@ -162,6 +169,8 @@ build_arceos() {
162169 info " Copying build artifacts -> $ARCEOS_IMAGES_DIR /${ARCH:- } "
163170 mkdir -p " $ARCEOS_IMAGES_DIR /${ARCH:- } "
164171 cp " $ARCEOS_SRC_DIR /examples/helloworld-myplat/helloworld-myplat_$app_features .bin" " $ARCEOS_IMAGES_DIR /${ARCH:- } /arceos-${ARCH} -dyn-smp1.bin"
172+ else
173+ rm -rf $ARCEOS_IMAGES_DIR /${ARCH:- } /arceos-${ARCH} -dyn-smp1.bin || true
165174 fi
166175}
167176
0 commit comments