| #!/bin/bash |
| |
| # usage: ./tools/backtrace/prj_crt.sh clone_prj new_prj" |
| CLONE_PRJ=$1 |
| NEW_PRJ=$2 |
| # $3 is address list |
| |
| if [ "$#" -lt "2" ]; then |
| echo "Usage: $0 <clone project> <new project>" |
| exit |
| fi |
| |
| RED_PAT="\033[37;41m" |
| BLUE_PAT="\033[37;44m" |
| YELLOW_PAT="\033[30;43m" |
| RESET_PAT="\033[0m" |
| |
| # check firstly |
| if [ ! -f "make/projects/${CLONE_PRJ}.prj" ] || [ ! -d "work/custom/${CLONE_PRJ}" ]; then |
| echo -e "${RED_PAT} Cannot find ${CLONE_PRJ} in project list!${RESET_PAT}" |
| exit |
| fi |
| |
| # start to create project ... |
| echo "" |
| echo -e "Start to clone ${CLONE_PRJ} to ${NEW_PRJ}..." |
| echo -e "Copy *.prj ..." |
| rm -f make/projects/${NEW_PRJ}.prj |
| cp -f make/projects/${CLONE_PRJ}.prj make/projects/${NEW_PRJ}.prj |
| |
| echo -e "Check rel mapping ..." |
| relmap=`cat rel/mapping/prj_map | grep "${NEW_PRJ};"` |
| if [ "$relmap" != "" ]; then |
| echo -e " ${BLUE_PAT}> Find in project mapping, no need to add new ... $result${RESET_PAT}" |
| else |
| echo -e " ${RED_PAT}> Cannot find ${NEW_PRJ} in project mapping!${RESET_PAT}" |
| result=`cat rel/mapping/prj_map | grep "${CLONE_PRJ};"` |
| if [ "$result" != "" ]; then |
| echo -e " > try to clone one from ${CLONE_PRJ}" |
| relmap=`echo $result | sed "s/${CLONE_PRJ};/${NEW_PRJ};/g"` |
| echo -e " ${BLUE_PAT}> $relmap${RESET_PAT}" |
| echo $relmap >> rel/mapping/prj_map |
| else |
| echo -e " ${RED_PAT}> Still cannot find similar setting, please add manaually!${RESET_PAT}" |
| exit |
| fi |
| fi |
| |
| echo -e "Clone rel folders ..." |
| rm -fr rel/filter/${NEW_PRJ} |
| cp -fr rel/filter/${CLONE_PRJ} rel/filter/${NEW_PRJ} |
| |
| echo -e "Check internal feature option ..." |
| BUILD_FDR=`cat work/custom/${CLONE_PRJ}/build/customer_feature_option | grep "INTERNAL_FEATURE_OPTION.*=" | grep "INTERNAL_FEATURE_OPTION.*=" | sed 's/.*\/\(build\..*\)\/config.*/\1/'` |
| if [ "$BUILD_FDR" != "" ]; then |
| echo -e " ${BLUE_PAT}> Find $BUILD_FDR in cloned project ${CLOSE_PRJ}${RESET_PAT}" |
| else |
| echo -e " ${RED_PAT}> Cannot find build.xxxx in cloned project!${RESET_PAT}" |
| exit |
| fi |
| |
| echo -e "Clone internal feature option ..." |
| rm -fr work/${BUILD_FDR}/config/${NEW_PRJ} |
| cp -fr work/${BUILD_FDR}/config/${CLONE_PRJ} work/${BUILD_FDR}/config/${NEW_PRJ} |
| |
| echo -e "Clone custom folder ..." |
| rm -fr work/custom/${NEW_PRJ} |
| cp -fr work/custom/${CLONE_PRJ} work/custom/${NEW_PRJ} |
| # replace the INTERNAL_FEATURE_OPTION |
| sed -i "s/\/${CLONE_PRJ}\//\/${NEW_PRJ}\//g" work/custom/${NEW_PRJ}/build/customer_feature_option |
| # check GPIO |
| GPIO_FDR=work/custom/${NEW_PRJ}/gpio |
| if [ -f "${GPIO_FDR}/${CLONE_PRJ}.csv" ]; then |
| # find GPIO file |
| echo -e " ${BLUE_PAT}> rename ${GPIO_FDR}/${CLONE_PRJ}.csv to ${GPIO_FDR}/${NEW_PRJ}.csv${RESET_PAT}" |
| mv ${GPIO_FDR}/${CLONE_PRJ}.csv ${GPIO_FDR}/${NEW_PRJ}.csv |
| fi |
| |
| CFG=`echo $relmap | awk -F ';' '{print $2}'` |
| SDK=`echo $relmap | awk -F ';' '{print $3}'` |
| echo "" |
| echo "----------------------------------------------------------" |
| echo -e "${BLUE_PAT}${NEW_PRJ}${RESET_PAT} is cloned from ${CLONE_PRJ} done!" |
| echo "Please check/modify and upload following files/folders/configurations ..." |
| echo -e " ${YELLOW_PAT}> Config: ${CFG}" |
| echo -e " ${YELLOW_PAT}> SDK: ${SDK}" |
| echo -e " ${YELLOW_PAT}> make/${RESET_PAT}" |
| mtk_repo status make |
| echo -e " ${YELLOW_PAT}> rel/${RESET_PAT}" |
| mtk_repo status rel |
| echo -e " ${YELLOW_PAT}> work/${BUILD_FDR}/${RESET_PAT}" |
| mtk_repo status work/${BUILD_FDR} |
| echo -e " ${YELLOW_PAT}> work/custom/${RESET_PAT}" |
| mtk_repo status work/custom |
| echo "----------------------------------------------------------" |
| echo "" |