From 12f092c3522d6b51c211b2deb46f4616526b413e Mon Sep 17 00:00:00 2001
From: Xilin Wu <strongtz@yeah.net>
Date: Mon, 12 Sep 2022 18:22:32 +0800
Subject: [PATCH] Add support for skipping SimpleInit rootfs generation

---
 build.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/build.sh b/build.sh
index 4ca3db4..e3371b3 100755
--- a/build.sh
+++ b/build.sh
@@ -42,6 +42,7 @@ function _help(){
 	echo "	--release MODE, -r MODE: Release mode for building, default is 'RELEASE', 'DEBUG' alternatively."
 	echo "	--toolchain TOOLCHAIN:   Set toolchain, default is 'GCC5'."
 	echo "	--uart, -u:              compile with UART support, print debug messages to uart debug port."
+	echo " 	--skip-rootfs-gen:       skip generating SimpleInit rootfs to speed up building."
 	echo "	--acpi, -A:              compile DSDT using MS asl with wine"
 	echo "	--clean, -C:             clean workspace and output."
 	echo "	--distclean, -D:         clean up all files that are not in repo."
@@ -140,7 +141,8 @@ TOOLCHAIN=GCC5
 USE_UART=0
 export OUTDIR="${PWD}"
 export GEN_ACPI=false
-OPTS="$(getopt -o t:d:hacACDO:r:u -l toolchain:,device:,help,all,chinese,acpi,uart,clean,distclean,outputdir:,release: -n 'build.sh' -- "$@")"||exit 1
+export GEN_ROOTFS=true
+OPTS="$(getopt -o t:d:hacACDO:r:u -l toolchain:,device:,help,all,chinese,acpi,skip-rootfs-gen,uart,clean,distclean,outputdir:,release: -n 'build.sh' -- "$@")"||exit 1
 eval set -- "${OPTS}"
 while true
 do	case "${1}" in
@@ -151,6 +153,7 @@ do	case "${1}" in
 		-C|--clean)CLEAN=true;shift;;
 		-D|--distclean)DISTCLEAN=true;shift;;
 		-O|--outputdir)OUTDIR="${2}";shift 2;;
+		--skip-rootfs-gen)GEN_ROOTFS=false;shift;;
 		-r|--release)MODE="${2}";shift 2;;
 		-t|--toolchain)TOOLCHAIN="${2}";shift 2;;
 		-u|--uart)USE_UART=1;shift;;
@@ -242,9 +245,11 @@ do	[ -f "${i}" ]||continue
 	mkdir -p "${_path}"
 	msgfmt -o "${_path}/simple-init.mo" "${i}"
 done
-bash "${_SIMPLE_INIT}/scripts/gen-rootfs-source.sh" \
+if "${GEN_ROOTFS}"
+then bash "${_SIMPLE_INIT}/scripts/gen-rootfs-source.sh" \
 	"${_SIMPLE_INIT}" \
 	"${_SIMPLE_INIT}/build"
+fi
 if [ "${DEVICE}" == "all" ]
 then	E=0
 	for i in "${DEVICES[@]}"
-- 
2.47.1