setupbuild.sh

来源:互联网 发布:vs2017 windows.h 编辑:程序博客网 时间:2024/03/29 17:18
#! /bin/bash

THREADNUM=0
BUILDCFG="null"
ADBCFG="null"
VERID="null"
VERIDCFG="null"
clear
COMUSER=`who -m | awk '{print $1}'`
BUILD_DATA=`date +'%Y%m%d%H%M%S'`
# Print Color Strings
RED='\e[1;31m'
NC='\e[0m'
RED='\e[1;31m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
BLUE='\e[1;34m'
# 紫色
PURPLE='\e[1;35m'
# 蓝绿色
CYAN='\e[1;36m'
# 白色
WHITE='\e[1;37m'
# 没有颜色
NC='\e[0m'
ulimit -n 4096

#build android.
function build_android()
{
    echo -e "${BLUE}<<=============building android===============>>${NC}"
    make -j$THREADNUM $BUILDCFG $ADBCFG
    #make -j16 $BUILDCFG
}

#build kernel.
function build_kernel()
{
        echo -e "${BLUE}<<=============build for uImage===============>>${NC}"
    sleep 1
    cd kernel/
#   . env.sh
    make meson_reff20_iptv_defconfig

    make uImage -j$THREADNUM
    if [[ $? -ne 0 ]]; then
        echo -e "${RED}THERE IS ERROR! PLEASE CHECK AND REBUILD!!!!!!${NC}"
        exit 1
    fi
    
    cp ./arch/arm/boot/uImage ../out/target/product/f20ref/
    make meson_reff20_iptv_recovery_defconfig
    make uImage -j$THREADNUM
    if [[ $? -ne 0 ]]; then
        echo -e "${RED}THERE IS ERROR! PLEASE CHECK AND REBUILD!!!!!!${NC}"
        exit 1
    fi
    cp ./arch/arm/boot/uImage ../out/target/product/f20ref/uImage_recovery
    
    cd ..
}

#build ota package.
function build_package()
{
      echo -e "${BLUE}<<=============building otapackage!===============>>${NC}"
    make otapackage -j$THREADNUM $BUILDCFG $ADBCFG
}

echo -e "${YELLOW}____________________________________________________________${NC}"
echo -e "${BLUE}=============User: $COMUSER,Time: $BUILD_DATA==============${NC}"
echo -e "${BLUE}Build env setup ...${NC}"
#build_setup
  echo -e "${YELLOW}Choose your prj config:${NC}"
    echo 1: Jiangsu
    echo 2: Jiangxi
    echo 3: Zhejiang
    echo 4: Iptvjichai
    read -p "Enter your prj num:" prjname
    if [[ $prjname = 1 ]]; then
       echo -e "${BLUE}--> choose jiangu${NC}"
       BUILDCFG="JIANGSU_CTC_ENABLE=true"
    elif [[ $prjname = 2 ]]; then
       echo -e "${BLUE}--> choose jiangxi${NC}"
       BUILDCFG="JIANGXI_CTC_ENABLE=true"
    elif [[ $prjname = 3 ]]; then
         echo -e "${BLUE}--> choose zhejiang${NC}"
         BUILDCFG="ZHEJIANG_CTC_ENABLE=true"
    elif [[ $prjname = 4 ]]; then
         echo -e "${BLUE}--> choose iptv jicai${NC}"
         BUILDCFG="IPTV_JICAI_PROJECT_ENABLE=true"
    else
       echo -e "${RED}Choose none!${NC}"
       exit 1
    fi
    
    myFile="device/amlogic/f20ref/cuscfg.mk"
    if [ -f "$myFile" ]; then  
            rm "$myFile"  
    fi  
    
    echo -e "${YELLOW}______________Version num/Adb/Build thread cfg______________${NC}"
    read -p "Need open ADB?[y/n]" adbopen
    if [[ $adbopen = "y" ]]; then
        echo "open adb!"
        ADBCFG="DEVICE_OPEN_ADB=true"
    else
        echo "close adb!"
        ADBCFG="DEVICE_OPEN_ADB=false"
    fi   
    
    read -p "Need set version num?[y/n]" needver
    if [[ $needver = "y" ]]; then
        read -p "Enter as: BesTV_JS_1.9.4.0:" setVERID
        VERIDCFG="VERID=$setVERID"
        echo $VERIDCFG
    else
        echo "Default BesTV_JS_1.9.4.0!"
        VERIDCFG="VERID=null"
    fi   
    
    touch device/amlogic/f20ref/cuscfg.mk
    echo $BUILDCFG > device/amlogic/f20ref/cuscfg.mk
    echo $VERIDCFG >> device/amlogic/f20ref/cuscfg.mk
    
    read -p "Enter your build thread num (1~32):" THREADNUM
    
    if [[ $THREADNUM < 1 ]]; then
            THREADNUM=4
    elif [[ $prjname > 32 ]]; then
            THREADNUM=32
    fi
    echo "THREAD NUM: $THREADNUM"

    sleep 1
    echo -e "${BLUE}<<. build/envsetup.sh>>${NC}"
  . build/envsetup.sh
    echo -e "${BLUE}<<lunch 21>>${NC}"
    lunch 21
    echo $BUILD_ID
    echo $BUILD_NUMBER
#end build setup

while true
do
echo -e "${YELLOW}_____________________Choose build intention_________________${NC}"
echo -e "${GREEN}1: Rebuild android, kernel, gen package${NC}"
echo -e "${GREEN}2: Build android (make -j#)${NC}"
echo -e "${GREEN}3: Build kernel${NC}"
echo -e "${GREEN}4: Gen package(make otapackage -j#)${NC}"
echo -e "${GREEN}5: Make clean only${NC}"
echo -e "${GREEN}6: Exit!${NC}"
read -p "Enter your choise num:"


if [[ $REPLY = 1 ]]; then
    echo -e "${BLUE}---->build all and gen otapackage!<----${NC}"
    read -p "Do you want to clean[y/n]" needclean
     if [[ $needclean = "y" ]]; then
        echo "make clean now ......"
        make clean
    elif [[ $needclean = "n" ]]; then
        echo "do not need clean"
    else
        echo -e "${RED}Input err! Only accept 'y' or 'n' !${NC}"
    fi
    
     build_android
     build_kernel
     build_package
elif [[ $REPLY = 2 ]]; then
     echo -e "${BLUE}---->build android!<----${NC}"
     read -p "Do you want to clean[y/n]" needclean2
     if [[ $needclean2 = "y" ]]; then
        echo "make clean now ......"
        make clean
    elif [[ $needclean2 = "n" ]]; then
        echo "do not need clean"
    else
        echo -e "${RED}Only accept 'y' or 'n' !${NC}"
        exit 1
    fi
     build_android
elif [[ $REPLY = 3 ]]; then
      echo -e "${BLUE}---->build kernel!<----${NC}"
      build_kernel
elif [[ $REPLY = 4 ]]; then
      echo -e "${BLUE}---->gen otapackage!<----${NC}"
      build_package
elif [[ $REPLY = 5 ]]; then
      echo -e "${BLUE}---->make clean!<----${NC}"
      make clean
elif [[ $REPLY = 6 ]]; then
      echo -e "${BLUE}---->give up!<----${NC}"
      exit 1
else
        echo -e "${RED}---->give up!<----${NC}"
    exit 1
fi
done
0 0
原创粉丝点击