-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_compile.sh
210 lines (188 loc) · 4.93 KB
/
check_compile.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/bash
#------------IMPORTANT------------#
#--RUN THIS SCRIPT BEFOR COMMIT---#
#---------------------------------#
# Author: xiaobo.gu@amlogic.com
# Init version: 20160329
#usage:
#
#./check_compile.sh -check amlogic board configs
#./check_compile.sh cus -check customer board configs
#./check_compile.sh all -check both amlogic and customer boards
folder_board="board/khadas/defconfigs"
customer_folder="customer/board/defconfigs"
echo "************** Amlogic Compile Check Tool **************"
# filters define:
# cus: all customer board
# all: all boards
# other:
# gxb: all gxbaby board
# gxtvbb: all gxtvbb board
# skt: all socket board
# p200: p200 board
# etc.....
declare filter="$1"
# ARRAY_CFG store config names
declare -a ARRAY_CFG
declare -a ARRAY_CFG_C
# TOTAL_CFG store config total num
declare -i TOTAL_CFG
declare -i TOTAL_CFG_C
# if filter!=cus, then include amlogic configs
# get all configs name from board folder
if [ "$2" != "" -a "$3" == "" ]
then
ARRAY_CFG[$TOTAL_CFG]=$2
TOTAL_CFG=$TOTAL_CFG+1
fi
if [ "$2" != "" -a "$3" != "" ]
then
ARRAY_CFG[$TOTAL_CFG]=$3
TOTAL_CFG=$TOTAL_CFG+1
fi
if [ "$1" != "cus" -a "$2" == "" -a "$3" == "" ]
then
filter=$1
for file in ${folder_board}/*; do
temp_file=`basename $file`
# del "_defconfig"
temp_file=${temp_file%_*}
echo "$temp_file"
ARRAY_CFG[$TOTAL_CFG]=$temp_file
TOTAL_CFG=$TOTAL_CFG+1
done
fi
# if filter==all || filter==cus, then include customer configs
# get all customer configs name from customer board folder
if [ "$1" == "cus" ] || [ "$1" == "all" ]
then
filter=""
if [ -e ${customer_folder} ];then
for file in ${customer_folder}/*; do
temp_file=`basename $file`
temp_file=${temp_file%_*}
#echo $temp_file
ARRAY_CFG_C[$TOTAL_CFG_C]=$temp_file
TOTAL_CFG_C=$TOTAL_CFG_C+1
done
fi
fi
echo "************************ START *************************"
echo "TOTAL_CFG=$TOTAL_CFG, argv1 = $1"
# compile check start
# RESULT store compile result
declare RESULT=""
declare -i LOOP_NUM=0
# counter variables
declare -i PASS_COUNTER=0
declare -i FAIL_COUNTER=0
# print bar and alignment
declare -i BAR_TOTAL=30
declare -i BAR_LOOP
# trying fix scp task compile failure misreport issue
declare -i BUILD_COUNTER=3
declare -i BUILD_RESULT=0
RESULT=$RESULT"########### Compile Check Result ###########\n"
if [ "$1" != "cus" ]
then
RESULT=$RESULT"--------------------------------------------\n"
RESULT=$RESULT"############## Amlogic Boards ##############\n"
# loop all cfgs
for cfg in ${ARRAY_CFG[@]}
do
# find filter in config name
if [[ $(echo $cfg | grep "${filter}") == "" ]]
then
# skip !filter configs
continue
fi
LOOP_NUM=$LOOP_NUM+1
RESULT=$RESULT' '
# print '0' charactors for alignment
BAR_LOOP=3-`expr length $LOOP_NUM`
if [ "$BAR_LOOP" -gt "0" ]
then
for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
fi
RESULT=$RESULT$LOOP_NUM' '
RESULT=$RESULT$cfg' '
# print '-' charactors for alignment
BAR_LOOP=BAR_TOTAL-`expr length $cfg`
if [ "$BAR_LOOP" -gt "0" ]
then
for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
fi
# compile
BUILD_COUNTER=3
BUILD_RESULT=0
while [ "${BUILD_COUNTER}" -gt "0" ]; do
BUILD_COUNTER=$((BUILD_COUNTER - 1))
set -e
make distclean
make $cfg'_defconfig'
make -j
# check last 'make -j' result
if [ $? != 0 ]; then
BUILD_RESULT=$((BUILD_RESULT + 1))
else
BUILD_RESULT=0
BUILD_COUNTER=0
fi
done
# check compile result
if [ ${BUILD_RESULT} != 0 ]; then
RESULT=$RESULT'- failed\n'
FAIL_COUNTER=$FAIL_COUNTER+1
else
RESULT=$RESULT'- pass\n'
PASS_COUNTER=$PASS_COUNTER+1
fi
# print result
echo -e $RESULT
#echo $cfg
done
fi
# check customer configs
if [ "$1" == "cus" ] || [ "$1" == "all" ]
then
RESULT=$RESULT"--------------------------------------------\n"
RESULT=$RESULT"############## Customer Boards #############\n"
for cfg in ${ARRAY_CFG_C[@]}
do
LOOP_NUM=$LOOP_NUM+1
RESULT=$RESULT' '
BAR_LOOP=3-`expr length $LOOP_NUM`
if [ "$BAR_LOOP" -gt "0" ]
then
for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
fi
RESULT=$RESULT$LOOP_NUM' '
RESULT=$RESULT$cfg' '
BAR_LOOP=BAR_TOTAL-`expr length $cfg`
if [ "$BAR_LOOP" -gt "0" ]
then
for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
fi
set -e
make distclean
make $cfg'_defconfig'
make -j
if [ $? != 0 ]
then
RESULT=$RESULT'- failed\n'
FAIL_COUNTER=$FAIL_COUNTER+1
else
RESULT=$RESULT'- pass\n'
PASS_COUNTER=$PASS_COUNTER+1
fi
echo -e $RESULT
done
fi
# check bl33z for kernel ramdump
if [ -d "./bl33z" ]; then
cd ./bl33z
./check.sh $filter
cd -
fi
echo -e "#################### END ###################\n"
exit $FAIL_COUNTER