blob: 7588227aa4ea61ad406a75b1744ad18f8536b1c7 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/bin/bash
2
3# usage: ./tools/backtrace/prj_crt.sh clone_prj new_prj"
4CLONE_PRJ=$1
5NEW_PRJ=$2
6# $3 is address list
7
8if [ "$#" -lt "2" ]; then
9 echo "Usage: $0 <clone project> <new project>"
10 exit
11fi
12
13RED_PAT="\033[37;41m"
14BLUE_PAT="\033[37;44m"
15YELLOW_PAT="\033[30;43m"
16RESET_PAT="\033[0m"
17
18# check firstly
19if [ ! -f "make/projects/${CLONE_PRJ}.prj" ] || [ ! -d "work/custom/${CLONE_PRJ}" ]; then
20 echo -e "${RED_PAT} Cannot find ${CLONE_PRJ} in project list!${RESET_PAT}"
21 exit
22fi
23
24# start to create project ...
25echo ""
26echo -e "Start to clone ${CLONE_PRJ} to ${NEW_PRJ}..."
27echo -e "Copy *.prj ..."
28rm -f make/projects/${NEW_PRJ}.prj
29cp -f make/projects/${CLONE_PRJ}.prj make/projects/${NEW_PRJ}.prj
30
31echo -e "Check rel mapping ..."
32relmap=`cat rel/mapping/prj_map | grep "${NEW_PRJ};"`
33if [ "$relmap" != "" ]; then
34 echo -e " ${BLUE_PAT}> Find in project mapping, no need to add new ... $result${RESET_PAT}"
35else
36 echo -e " ${RED_PAT}> Cannot find ${NEW_PRJ} in project mapping!${RESET_PAT}"
37 result=`cat rel/mapping/prj_map | grep "${CLONE_PRJ};"`
38 if [ "$result" != "" ]; then
39 echo -e " > try to clone one from ${CLONE_PRJ}"
40 relmap=`echo $result | sed "s/${CLONE_PRJ};/${NEW_PRJ};/g"`
41 echo -e " ${BLUE_PAT}> $relmap${RESET_PAT}"
42 echo $relmap >> rel/mapping/prj_map
43 else
44 echo -e " ${RED_PAT}> Still cannot find similar setting, please add manaually!${RESET_PAT}"
45 exit
46 fi
47fi
48
49echo -e "Clone rel folders ..."
50rm -fr rel/filter/${NEW_PRJ}
51cp -fr rel/filter/${CLONE_PRJ} rel/filter/${NEW_PRJ}
52
53echo -e "Check internal feature option ..."
54BUILD_FDR=`cat work/custom/${CLONE_PRJ}/build/customer_feature_option | grep "INTERNAL_FEATURE_OPTION.*=" | grep "INTERNAL_FEATURE_OPTION.*=" | sed 's/.*\/\(build\..*\)\/config.*/\1/'`
55if [ "$BUILD_FDR" != "" ]; then
56 echo -e " ${BLUE_PAT}> Find $BUILD_FDR in cloned project ${CLOSE_PRJ}${RESET_PAT}"
57else
58 echo -e " ${RED_PAT}> Cannot find build.xxxx in cloned project!${RESET_PAT}"
59 exit
60fi
61
62echo -e "Clone internal feature option ..."
63rm -fr work/${BUILD_FDR}/config/${NEW_PRJ}
64cp -fr work/${BUILD_FDR}/config/${CLONE_PRJ} work/${BUILD_FDR}/config/${NEW_PRJ}
65
66echo -e "Clone custom folder ..."
67rm -fr work/custom/${NEW_PRJ}
68cp -fr work/custom/${CLONE_PRJ} work/custom/${NEW_PRJ}
69# replace the INTERNAL_FEATURE_OPTION
70sed -i "s/\/${CLONE_PRJ}\//\/${NEW_PRJ}\//g" work/custom/${NEW_PRJ}/build/customer_feature_option
71# check GPIO
72GPIO_FDR=work/custom/${NEW_PRJ}/gpio
73if [ -f "${GPIO_FDR}/${CLONE_PRJ}.csv" ]; then
74 # find GPIO file
75 echo -e " ${BLUE_PAT}> rename ${GPIO_FDR}/${CLONE_PRJ}.csv to ${GPIO_FDR}/${NEW_PRJ}.csv${RESET_PAT}"
76 mv ${GPIO_FDR}/${CLONE_PRJ}.csv ${GPIO_FDR}/${NEW_PRJ}.csv
77fi
78
79CFG=`echo $relmap | awk -F ';' '{print $2}'`
80SDK=`echo $relmap | awk -F ';' '{print $3}'`
81echo ""
82echo "----------------------------------------------------------"
83echo -e "${BLUE_PAT}${NEW_PRJ}${RESET_PAT} is cloned from ${CLONE_PRJ} done!"
84echo "Please check/modify and upload following files/folders/configurations ..."
85echo -e " ${YELLOW_PAT}> Config: ${CFG}"
86echo -e " ${YELLOW_PAT}> SDK: ${SDK}"
87echo -e " ${YELLOW_PAT}> make/${RESET_PAT}"
88mtk_repo status make
89echo -e " ${YELLOW_PAT}> rel/${RESET_PAT}"
90mtk_repo status rel
91echo -e " ${YELLOW_PAT}> work/${BUILD_FDR}/${RESET_PAT}"
92mtk_repo status work/${BUILD_FDR}
93echo -e " ${YELLOW_PAT}> work/custom/${RESET_PAT}"
94mtk_repo status work/custom
95echo "----------------------------------------------------------"
96echo ""