shell 脚本模板

BS_DIR_TOP=$(cd `dirname $0` ; pwd)
BS_DIR_OUTPUT=${BS_DIR_TOP}/output
BS_DIR_COPY_CHIPRAM=${BS_DIR_TOP}/bsp/out/ums512_1h10/dist/chipram
BS_DIR_COPY_UBOOT=${BS_DIR_TOP}/bsp/out/ums512_1h10/dist/u-boot15
BS_DIR_COPY_MODULES_KO=${BS_DIR_TOP}/bsp/out/ums512_1h10/dist/modules
BS_DIR_COPY=${BS_DIR_TOP}/out/target/product/ums512_1h10
BS_DIR_COPY_ALL=${BS_DIR_TOP}/vendor/sprd/release/IDH/ImageFiles

COLOURS_RED="\033[31m"
COLOURS_GREEN="\033[32m"
COLOURS_END="\033[0m"


if [ ! -d "output" ];then
    mkdir output
fi
build_chipram()
{
    echo -e "  ${COLOURS_GREEN}   start compile to chipram ..... ${COLOURS_END}"
	cd ${BS_DIR_TOP}/bsp
	. build/envsetup.sh 
	lunch ums512_1h10_ctcc-userdebug-androidq 
	make chipram -j${threads}
	cp -rf ${BS_DIR_COPY_CHIPRAM}/ddr_scan-sign.bin ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_CHIPRAM}/fdl1-sign.bin ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_CHIPRAM}/u-boot-spl-16k-sign.bin ${BS_DIR_OUTPUT}
	
	echo "end compile to chipram ....."
	cd ${BS_DIR_TOP}
	return 0
}

build_bootloader_uboot()
{
    echo -e "  ${COLOURS_GREEN}   start compile to uboot ..... ${COLOURS_END}"
	cd ${BS_DIR_TOP}/bsp
	. build/envsetup.sh 
	lunch ums512_1h10_ctcc-userdebug-androidq 
	make  bootloader -j${threads}  || return 1
	cp -rf ${BS_DIR_COPY_UBOOT}/u-boot-sign.bin ${BS_DIR_OUTPUT}
	
	echo "end compile to uboot ....."
	cd ${BS_DIR_TOP}
	return 0
}

build_kernel()
{
	echo "start compile to kernel ....."
	cd ${BS_DIR_TOP}
	
#  . build/envsetup.sh
#   lunch ums512_1h10_ctcc-userdebug-androidq
#   make bootimage -j${threads}|| return 1

	
	. zq_envsetup.sh
	lunch ums512_1h10_ctcc-userdebug-androidq
	cd vendor/sprd/release/IDH/Script
	./build_pac.sh -a ${LUNCH_NAME} -b build -j200
	
	cp -rf ${BS_DIR_COPY}/u-boot-sign.bin ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY}/boot.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY}/dtbo.img ${BS_DIR_OUTPUT}
	
	cd ${BS_DIR_TOP}
	echo "end compile to kernel ....."
	cd ${BS_DIR_TOP}
	return 0
}

build_modules()
{
	echo "start compile to modules ....."
	cd ${BS_DIR_TOP}
   . build/envsetup.sh
    lunch ums512_1h10_ctcc-userdebug-androidq
 
	make sockoimage -j${threads} || return 1
	cp -rf ${BS_DIR_COPY}/socko.img ${BS_DIR_OUTPUT}
	
	#make vendorimage -j${threads} || return 1
	#cp -rf ${BS_DIR_COPY}/vendor.img ${BS_DIR_OUTPUT}
	
	echo "end compile to modules ....."
	cd ${BS_DIR_TOP}
	return 0
}

build_modules_ko()
{
	echo -e "  ${COLOURS_GREEN}   start compile to build_modules_ko ..... ${COLOURS_END}"
	cd ${BS_DIR_TOP}/bsp
   . build/envsetup.sh
    lunch ums512_1h10_ctcc-userdebug-androidq
	make modules -j${threads} || return 1 #Compile all Ko's
    #make modules –m sprd_camera.ko || return 1
	#make modules –m sprd_sensor.ko || return 1
	#make modules –m sprd_fd.ko || return 1
	cp -rf ${BS_DIR_COPY_MODULES_KO}/sprd_camera.ko ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_MODULES_KO}/sprd_sensor.ko ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_MODULES_KO}/sprd_fd.ko ${BS_DIR_OUTPUT}
	cd ${BS_DIR_TOP}
	echo -e "  ${COLOURS_GREEN}   end compile to build_modules_ko success..... ${COLOURS_END}"
	return 0
}

build_android()
{
	echo "start compile to modules ....."
	cd ${BS_DIR_TOP}
	. zq_envsetup.sh
	#m
	mmm vendor/sprd/modules/libcamera/ -j100

	if [ ! -d "${BS_DIR_OUTPUT}/lib" ];then
		mkdir ${BS_DIR_OUTPUT}/lib
	fi
	
	if [ ! -d "${BS_DIR_OUTPUT}/lib64" ];then
		mkdir ${BS_DIR_OUTPUT}/lib64
	fi	
	
	cd ${BS_DIR_TOP}
	cp -rf ${BS_DIR_COPY}/vendor/lib/libsensor_tp9950.so ${BS_DIR_OUTPUT}/lib
	cp -rf ${BS_DIR_COPY}/vendor/lib64/libsensor_tp9950.so ${BS_DIR_OUTPUT}/lib64
	echo "end compile to modules ....."
	cd ${BS_DIR_TOP}
	return 0
}
build_default()
{
	cd ${BS_DIR_TOP}
	. zq_envsetup.sh
	./zq_build_ota_system.sh
	cp -rf ${BS_DIR_COPY_ALL}/fdl1-sign.bin ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/fdl2-sign.bin ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/sharkl5pro_pubcp_nvitem.bin ${BS_DIR_OUTPUT}


	cp -rf ${BS_DIR_COPY_ALL}/prodnv.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/vbmeta-sign.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/vbmeta_system.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/vbmeta_vendor.img ${BS_DIR_OUTPUT}
	
	cp -rf ${BS_DIR_COPY_ALL}/userdata.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/super.img ${BS_DIR_OUTPUT}	
	
	
	cp -rf ${BS_DIR_COPY_ALL}/boot.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/dtbo.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/socko.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/vbmeta_vendor.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/userdata.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/super.img ${BS_DIR_OUTPUT}
	
	cp -rf ${BS_DIR_COPY_ALL}/cache.img ${BS_DIR_OUTPUT}
	cp -rf ${BS_DIR_COPY_ALL}/recovery.img ${BS_DIR_OUTPUT}


	cp -rf ${BS_DIR_COPY_ALL}/config.bin ${BS_DIR_OUTPUT}
	
	
}
threads=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}')
uboot=no
kernel=no
modules=no
chipram=no
android=no
modules_ko=no
default=no

if [ -z $1 ]; then
	uboot=yes
	kernel=yes
	modules=yes
    chipram=yes
	android=yes
	modules_ko=yes
	default=yes
fi
while [ "$1" ]; do
    case "$1" in
	-j=*)
		x=$1 
		threads=${x#-j=}
	    ;;
	-u|--uboot)
		uboot=yes
	    ;;
	-k|--kernel)
		kernel=yes
	    ;;
	-m|--modules)
		modules=yes
	;;
	-c|--chipram)
		chipram=yes
	;;
	-A|--android)
		android=yes
	;;
	-M|--modules_ko)
		modules_ko=yes	
	;;
	-a|--all)
		default=yes
	    ;;
	-h|--help)
	echo -e "${COLOURS_GREEN}
Usage: ./mk.sh [OPTION]
Build script for compile the source of telechips project.

  -j=n                 using n threads when building source project (example: -j=16)
  -u, --uboot          build bootloader uboot from source
  -k, --kernel         build kernel from source
  -m, --modules         build modules from source
  -M, --modules_ko      build modules_ko from source
  -c, --chipram         build chipram from source
  -A, --android         build android from source
  -a, --all            build all, include anything
  -h, --help           display this help and exit
		${COLOURS_END}"
	    exit 0
	    ;;
	*)
	    exit 1
	    ;;
    esac
    shift
done

if [ "${uboot}" = yes ]; then
	build_bootloader_uboot || exit 1
fi

if [ "${kernel}" = yes ]; then
	build_kernel || exit 1
fi

if [ "${modules}" = yes ]; then
	build_modules || exit 1
fi

if [ "${modules_ko}" = yes ]; then
	build_modules_ko || exit 1
fi

if [ "${chipram}" = yes ]; then
	build_chipram || exit 1
fi

if [ "${android}" = yes ]; then
	build_android || exit 1
fi

if [ "${default}" = yes ]; then
	build_default || exit 1
fi

exit 0

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小猿东哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值