作者:多米音乐_34176403 | 来源:互联网 | 2023-09-17 09:51
#!binbashCPU_JOB_NUM$(grepprocessorproccpuinfo|awk{field$NF};END{printfield1})#处理起数量CLIEN
#!/bin/bashCPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}') #处理起数量
CLIENT=$(whoami) #当前的用户ROOT_DIR=$(pwd) #当前路径
KERNEL_DIR=./kernel#SEC_PRODUCT='generic' #Enable for generic build
SEC_PRODUCT='smdkv210' #Enable for smdk build#Modify the below path suitably as per your requirementsOUT_DIR="$ROOT_DIR/out/target/product/$SEC_PRODUCT" #输出目录
OUT_HOSTBIN_DIR="$ROOT_DIR/out/host/linux-x86/bin" #用到的命令目录function check_exit()
{if [ $? != 0 ]thenexit $?fi
}function build_android()
{echoecho '[[[[[[[ Build android platform ]]]]]]]'echoSTART_TIME=`date +%s` #获取系统时间if [ $SEC_PRODUCT = "generic" ] #判断输出的目录,如果是默认的目录thenecho make -j$CPU_JOB_NUM #输出提示echomake -j$CPU_JOB_NUM #开始编译elseecho make -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-eng #输出提示echomake -j$CPU_JOB_NUM PRODUCT-full_$SEC_PRODUCT-eng #开始编译ficheck_exitEND_TIME=`date +%s` #结束时间 let "ELAPSED_TIME=$END_TIME-$START_TIME" #计算消耗时间echo "Total compile time is $ELAPSED_TIME seconds"
}function make_uboot_img() #编译u-boot文件
{cd $OUT_DIR #进入输出的文件目录echoecho '[[[[[[[ Make ramdisk image for u-boot ]]]]]]]'echo$OUT_HOSTBIN_DIR/mkyaffs2image root ramdisk-yaffs.img check_exitechocd ../../../..
}function make_fastboot_img()
{echoecho '[[[[[[[ Make additional images for fastboot ]]]]]]]'echoif [ ! -f $KERNEL_DIR/arch/arm/boot/zImage ]thenecho "No zImage is found at $KERNEL_DIR/arch/arm/boot"echo ' Please set KERNEL_DIR if you want to make additional images'echo " Ex.) export KERNEL_DIR=~ID/android_kernel_$SEC_PRODUCT"echoreturnfiecho 'boot.img ->' $OUT_DIRcp $KERNEL_DIR/arch/arm/boot/zImage $OUT_DIR/zImage$OUT_HOSTBIN_DIR/mkbootimg --kernel $OUT_DIR/zImage --ramdisk $OUT_DIR/ramdisk-uboot.img -o $OUT_DIR/boot.imgcheck_exitecho 'update.zip ->' $OUT_DIRzip -j $OUT_DIR/update.zip $OUT_DIR/android-info.txt $OUT_DIR/boot.img $OUT_DIR/system.imgcheck_exitecho
}echo
echo ' Build android for '$SEC_PRODUCT''
echocase "$SEC_PRODUCT" in #根据目录的不同,选择不同的编译过程smdkc110)build_androidmake_uboot_imgmake_fastboot_img;;smdkv210)build_androidmake_uboot_img#make_fastboot_img;;generic)build_androidmake_uboot_img;;*)echo "Please, set SEC_PRODUCT"echo " export SEC_PRODUCT=smdkc100 or SEC_PRODUCT=smdkc110 or SEC_PRODUCT=smdkv210 or SEC_PRODUCT=smdk6440"echo " or "echo " export SEC_PRODUCT=generic"exit 1;;
esacecho ok success !!!exit 0