blob: f66e22c43a6df2895af94b3957e4731718e06131 [file] [log] [blame]
Xiaobo Gud935a952017-06-13 15:20:20 +08001#!/bin/bash
2
3#------------IMPORTANT------------#
4#--RUN THIS SCRIPT BEFOR COMMIT---#
5#---------------------------------#
6
7# Author: xiaobo.gu@amlogic.com
8# Init version: 20160329
9# Update for bootloader.repo: 2017.01.01
10
11#usage:
12#
13#./check_compile.sh -check amlogic board configs
14#./check_compile.sh cus -check customer board configs
15#./check_compile.sh all -check both amlogic and customer boards
16
17function check_compile() {
18 # $1: filter
19 folder_board="bl33/board/amlogic"
20 customer_folder="bl33/customer/board"
21
22 echo "************** Amlogic Compile Check Tool **************"
23
24 # filters define:
25 # cus: all customer board
26 # all: all boards
27 # other:
28 # gxb: all gxbaby board
29 # gxtvbb: all gxtvbb board
30 # skt: all socket board
31 # p200: p200 board
32 # etc.....
33 declare filter="$1"
34
35 # ARRAY_CFG store config names
36 declare -a ARRAY_CFG
37 declare -a ARRAY_CFG_C
38 # TOTAL_CFG store config total num
39 declare -i TOTAL_CFG
40 declare -i TOTAL_CFG_C
41
42 # if filter!=cus, then include amlogic configs
43 # get all configs name from board folder
44 if [ "$1" != "cus" ]
45 then
46 filter=$1
47 for file in ${folder_board}/*; do
48 temp_file=`basename $file`
49 #echo "$temp_file"
50 if [ -d ${folder_board}/${temp_file} ] && [ "$temp_file" != "defconfigs" ] && [ "$temp_file" != "configs" ];then
51 #echo " \c"
52 #echo $temp_file
53 ARRAY_CFG[$TOTAL_CFG]=$temp_file
54 TOTAL_CFG=$TOTAL_CFG+1
55 fi
56 done
57 fi
58
59 # if filter==all || filter==cus, then include customer configs
60 # get all customer configs name from customer board folder
61 if [ "$1" == "cus" ] || [ "$1" == "all" ]
62 then
63 filter=""
64 if [ -e ${customer_folder} ];then
65 for file in ${customer_folder}/*; do
66 temp_file=`basename $file`
67 if [ -d ${customer_folder}/${temp_file} ] && [ "$temp_file" != "defconfigs" ] && [ "$temp_file" != "configs" ];then
68 #echo " \c"
69 #echo $temp_file
70 ARRAY_CFG_C[$TOTAL_CFG_C]=$temp_file
71 TOTAL_CFG_C=$TOTAL_CFG_C+1
72 fi
73 done
74 fi
75 fi
76
77 echo "************************ START *************************"
78
79 # compile check start
80 # RESULT store compile result
81 declare RESULT=""
82 declare -i LOOP_NUM=0
83 # counter variables
84 declare -i PASS_COUNTER=0
85 declare -i FAIL_COUNTER=0
86
87 # print bar and alignment
88 declare -i BAR_TOTAL=30
89 declare -i BAR_LOOP
90
91 RESULT=$RESULT"########### Compile Check Result ###########\n"
92
93 if [ "$1" != "cus" ]
94 then
95 RESULT=$RESULT"--------------------------------------------\n"
96 RESULT=$RESULT"############## Amlogic Boards ##############\n"
97 # loop all cfgs
98 for cfg in ${ARRAY_CFG[@]}
99 do
100 # find filter in config name
101 if [[ $(echo $cfg | grep "${filter}") == "" ]]
102 then
103 # skip !filter configs
104 continue
105 fi
106 LOOP_NUM=$LOOP_NUM+1
107 RESULT=$RESULT' '
108 # print '0' charactors for alignment
109 BAR_LOOP=3-`expr length $LOOP_NUM`
110 if [ "$BAR_LOOP" -gt "0" ]
111 then
112 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
113 fi
114 RESULT=$RESULT$LOOP_NUM' '
115 RESULT=$RESULT$cfg' '
116 # print '-' charactors for alignment
117 BAR_LOOP=BAR_TOTAL-`expr length $cfg`
118 if [ "$BAR_LOOP" -gt "0" ]
119 then
120 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
121 fi
xiaobo gu66f95292018-01-11 13:38:13 +0800122 BUILD_COUNTER=3
123 BUILD_RESULT=0
124 while [ "${BUILD_COUNTER}" -gt "0" ]; do
125 BUILD_COUNTER=$((BUILD_COUNTER - 1))
126 #make distclean
127 #make $cfg'_defconfig'
128 #make -j
129 fip/mk_script.sh $cfg
130 # check last 'make -j' result
131 if [ $? != 0 ]; then
132 BUILD_RESULT=$((BUILD_RESULT + 1))
133 else
134 BUILD_RESULT=0
135 BUILD_COUNTER=0
136 fi
137 done
138 # check compile result
139 if [ ${BUILD_RESULT} != 0 ]; then
Xiaobo Gud935a952017-06-13 15:20:20 +0800140 RESULT=$RESULT'- failed\n'
141 FAIL_COUNTER=$FAIL_COUNTER+1
142 else
143 RESULT=$RESULT'- pass\n'
144 PASS_COUNTER=$PASS_COUNTER+1
145 fi
146 # print result
147 echo -e $RESULT
148 #echo $cfg
149 done
150 fi
151
152 # check customer configs
153 if [ "$1" == "cus" ] || [ "$1" == "all" ]
154 then
155 RESULT=$RESULT"--------------------------------------------\n"
156 RESULT=$RESULT"############## Customer Boards #############\n"
157 for cfg in ${ARRAY_CFG_C[@]}
158 do
159 LOOP_NUM=$LOOP_NUM+1
160 RESULT=$RESULT' '
161 BAR_LOOP=3-`expr length $LOOP_NUM`
162 if [ "$BAR_LOOP" -gt "0" ]
163 then
164 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
165 fi
166 RESULT=$RESULT$LOOP_NUM' '
167 RESULT=$RESULT$cfg' '
168 BAR_LOOP=BAR_TOTAL-`expr length $cfg`
169 if [ "$BAR_LOOP" -gt "0" ]
170 then
171 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
172 fi
173 make distclean
174 make $cfg'_defconfig'
175 make -j
176 if [ $? != 0 ]
177 then
178 RESULT=$RESULT'- failed\n'
179 FAIL_COUNTER=$FAIL_COUNTER+1
180 else
181 RESULT=$RESULT'- pass\n'
182 PASS_COUNTER=$PASS_COUNTER+1
183 fi
184 echo -e $RESULT
185 done
186 fi
187
188 echo -e "#################### END ###################\n"
189}