blob: c4d25e94f6da797de09ed2eb13f6276619d7aab8 [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
xiaobo guca516382019-06-25 11:04:54 +080019 folder_board="bl33/board/amlogic/defconfigs"
20 customer_folder="bl33/customer/board/defconfigs"
Xiaobo Gud935a952017-06-13 15:20:20 +080021
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`
xiaobo guca516382019-06-25 11:04:54 +080049 # del "_defconfig"
50 temp_file=${temp_file%_*}
Xiaobo Gud935a952017-06-13 15:20:20 +080051 #echo "$temp_file"
xiaobo guca516382019-06-25 11:04:54 +080052 ARRAY_CFG[$TOTAL_CFG]=$temp_file
53 TOTAL_CFG=$TOTAL_CFG+1
Xiaobo Gud935a952017-06-13 15:20:20 +080054 done
55 fi
56
57 # if filter==all || filter==cus, then include customer configs
58 # get all customer configs name from customer board folder
59 if [ "$1" == "cus" ] || [ "$1" == "all" ]
60 then
61 filter=""
62 if [ -e ${customer_folder} ];then
63 for file in ${customer_folder}/*; do
64 temp_file=`basename $file`
xiaobo guca516382019-06-25 11:04:54 +080065 temp_file=${temp_file%_*}
66 #echo $temp_file
67 ARRAY_CFG_C[$TOTAL_CFG_C]=$temp_file
68 TOTAL_CFG_C=$TOTAL_CFG_C+1
Xiaobo Gud935a952017-06-13 15:20:20 +080069 done
70 fi
71 fi
72
73 echo "************************ START *************************"
74
75 # compile check start
76 # RESULT store compile result
77 declare RESULT=""
78 declare -i LOOP_NUM=0
79 # counter variables
80 declare -i PASS_COUNTER=0
81 declare -i FAIL_COUNTER=0
82
83 # print bar and alignment
84 declare -i BAR_TOTAL=30
85 declare -i BAR_LOOP
86
87 RESULT=$RESULT"########### Compile Check Result ###########\n"
88
89 if [ "$1" != "cus" ]
90 then
91 RESULT=$RESULT"--------------------------------------------\n"
92 RESULT=$RESULT"############## Amlogic Boards ##############\n"
93 # loop all cfgs
94 for cfg in ${ARRAY_CFG[@]}
95 do
96 # find filter in config name
97 if [[ $(echo $cfg | grep "${filter}") == "" ]]
98 then
99 # skip !filter configs
100 continue
101 fi
102 LOOP_NUM=$LOOP_NUM+1
103 RESULT=$RESULT' '
104 # print '0' charactors for alignment
105 BAR_LOOP=3-`expr length $LOOP_NUM`
106 if [ "$BAR_LOOP" -gt "0" ]
107 then
108 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
109 fi
110 RESULT=$RESULT$LOOP_NUM' '
111 RESULT=$RESULT$cfg' '
112 # print '-' charactors for alignment
113 BAR_LOOP=BAR_TOTAL-`expr length $cfg`
114 if [ "$BAR_LOOP" -gt "0" ]
115 then
116 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
117 fi
xiaobo gu66f95292018-01-11 13:38:13 +0800118 BUILD_COUNTER=3
119 BUILD_RESULT=0
120 while [ "${BUILD_COUNTER}" -gt "0" ]; do
121 BUILD_COUNTER=$((BUILD_COUNTER - 1))
122 #make distclean
123 #make $cfg'_defconfig'
124 #make -j
125 fip/mk_script.sh $cfg
126 # check last 'make -j' result
127 if [ $? != 0 ]; then
128 BUILD_RESULT=$((BUILD_RESULT + 1))
129 else
130 BUILD_RESULT=0
131 BUILD_COUNTER=0
132 fi
133 done
134 # check compile result
135 if [ ${BUILD_RESULT} != 0 ]; then
Xiaobo Gud935a952017-06-13 15:20:20 +0800136 RESULT=$RESULT'- failed\n'
137 FAIL_COUNTER=$FAIL_COUNTER+1
138 else
139 RESULT=$RESULT'- pass\n'
140 PASS_COUNTER=$PASS_COUNTER+1
141 fi
142 # print result
143 echo -e $RESULT
144 #echo $cfg
145 done
146 fi
147
148 # check customer configs
149 if [ "$1" == "cus" ] || [ "$1" == "all" ]
150 then
151 RESULT=$RESULT"--------------------------------------------\n"
152 RESULT=$RESULT"############## Customer Boards #############\n"
153 for cfg in ${ARRAY_CFG_C[@]}
154 do
155 LOOP_NUM=$LOOP_NUM+1
156 RESULT=$RESULT' '
157 BAR_LOOP=3-`expr length $LOOP_NUM`
158 if [ "$BAR_LOOP" -gt "0" ]
159 then
160 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
161 fi
162 RESULT=$RESULT$LOOP_NUM' '
163 RESULT=$RESULT$cfg' '
164 BAR_LOOP=BAR_TOTAL-`expr length $cfg`
165 if [ "$BAR_LOOP" -gt "0" ]
166 then
167 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
168 fi
169 make distclean
170 make $cfg'_defconfig'
171 make -j
172 if [ $? != 0 ]
173 then
174 RESULT=$RESULT'- failed\n'
175 FAIL_COUNTER=$FAIL_COUNTER+1
176 else
177 RESULT=$RESULT'- pass\n'
178 PASS_COUNTER=$PASS_COUNTER+1
179 fi
180 echo -e $RESULT
181 done
182 fi
183
184 echo -e "#################### END ###################\n"
185}