forked from uwehermann/easybox-904-lte-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_project.sh
executable file
·135 lines (117 loc) · 3.1 KB
/
change_project.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
change_proj()
{
PWD=`pwd`
CLEAN_LEVEL=$2
if [ -f ./.project_root ] && [ "`cat ./.project_root`" != "$PWD" ] ; then
echo ".............................................................."
echo ".................... Cleaning old project ...................."
echo ".............................................................."
CLN=Y
if [ ${CLEAN_LEVEL} != "2" ] && [ -f ./.project_root ] ; then
echo "The toolchain was build at `cat ./.project_root`"
echo "But you are at $PWD"
echo "Do you want to clean all(including toolchain)"
echo
echo "N) Don't clean all"
echo
read -p "Please input your choice -> " CLN
fi
if [ N${CLN} != "NN" ] && [ N${CLN} != "Nn" ] ; then
CLEAN_LEVEL=2
fi
fi
if [ ${CLEAN_LEVEL} == "2" ]; then
echo "Clean all"
rm -rf build_dir/
rm -rf staging_dir/
rm -rf tmp/
fi
if [ ${CLEAN_LEVEL} == "1" ]; then
echo "Clean target"
rm -rf build_dir/linux*
rm -rf build_dir/mips*
rm -rf build_dir/target*
rm -rf staging_dir/target*
rm -rf tmp/
fi
echo ".............................................................."
echo " Installing Project Dependant Files for $1 "
echo ".............................................................."
if [ -e "./projects/common" ] ; then
cp -rf ./projects/common/. .
fi
if [ -e "./projects/$1" ] ; then
cp -rf ./projects/$1/. .
fi
echo -n "$PWD" > "./.project_root"
echo -n "${PRJ_NAME}" > "./.project_name"
echo `date` $1 >> "./.project_history"
}
proj_help()
{
echo "syntax: $1 [Project Name] [Clean Level]"
echo " [Project Name] - The project name that need to have the folder with the same name in project directory"
echo " [Clean Level] - available value as below"
echo " 0) Don't clean everything, just copy update files"
echo " 1) Clean all but Keep host util and tooolchains"
echo " 2) Remove all host utilities and compiler toolchain"
}
#
# Main
#
if [ $# == 2 ]; then
if [ -e "./projects/$1" ] ; then
echo "change_proj $1 $2"
change_proj $1 $2
else
proj_help $0
exit
fi
elif [ $# == 1 ]; then
proj_help $0
exit
else
USER_CHOICE=0
CLEAN_LEVEL=0
# prompt
echo
echo "****************************************************"
echo "9) 904 LTE"
echo
echo "0) exit"
echo
read -p "Please input your choice -> " USER_CHOICE
# check choice
case ${USER_CHOICE} in
0)
exit
;;
9)
PRJ_NAME=904lte
;;
*)
echo "bad choice!"
;;
esac
# prompt
echo
echo "****************************************************"
echo "0) Don't clean everything, just copy update files"
echo "1) Clean all but Keep host util and tooolchains"
echo "2) Remove all host utilities and compiler toolchain"
echo
echo "e) exit"
echo
read -p "Please input your choice -> " CLEAN_LEVEL
if [ e${CLEAN_LEVEL} == "ee" ]; then
exit
fi
if [ e${CLEAN_LEVEL} == "e" ]; then
CLEAN_LEVEL=0
fi
echo
echo "Change to ${PRJ_NAME}, and do clean level ${CLEAN_LEVEL}"
echo
change_proj ${PRJ_NAME} ${CLEAN_LEVEL}
fi