-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildAll.sh
executable file
·52 lines (47 loc) · 1.33 KB
/
buildAll.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
#!/bin/bash
# This script build or clean all the Esp_mad project
# Print usage function
printUsage() {
echo "Usage:"
echo " -b|--build \"build all project\""
echo " -c|--clean \"clean all project\""
}
# Delete build File if exist function
delFileIfExist() {
if [ -e resultBuild.txt ]; then
rm resultBuild.txt
fi
}
# Execute idf.py function
executeCmd() {
echo "$1 Esp_Mad_Server and Esp_mad_Client, please wait ..."
echo "Result is stored in resultBuild.txt"
delFileIfExist
dateStart=$(date +%s)
cd ./Esp_mad_Server
idf.py $1 $2 >> ../resultBuild.txt
cd ../Esp_mad_Client
idf.py $1 $2 >> ../resultBuild.txt
cd ..
echo >> ./resultBuild.txt
echo "<---------------- Elapse Time for the $1 ---------------->" >> ./resultBuild.txt
echo >> ./resultBuild.txt
dateEnd=$(date +%s)
elapseTime=$(( $dateEnd - $dateStart ))
echo "$1 duration is equal to $elapseTime s" >> ./resultBuild.txt
tail -n 4 ./resultBuild.txt
}
# Check the number of parameters
if [ $# -gt 1 ] || [ $# -eq 0 ]; then
printUsage
exit 1
fi
# Execute regarding the parameter
if [ $1 = "-b" ] || [ $1 = "--build" ]; then
executeCmd "build" "size"
grep "Total image size" ./resultBuild.txt
elif [ $1 = "-c" ] || [ "$1" = "--clean" ]; then
executeCmd "clean"
else
printUsage
fi