blob: 06b8f4334bea39280f053419d786b6fad48dca7d [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
Honglin Zhang4a5037f2020-01-14 14:24:34 +080019 folder_board_v2015="bl33/v2015/board/amlogic/defconfigs"
20 customer_folder_v2015="bl33/v2015/customer/board/defconfigs"
21
22 folder_board_v2019="bl33/v2019/board/amlogic/defconfigs"
23 customer_folder_v2019="bl33/v2019/customer/board/defconfigs"
Xiaobo Gud935a952017-06-13 15:20:20 +080024
25 echo "************** Amlogic Compile Check Tool **************"
26
27 # filters define:
28 # cus: all customer board
29 # all: all boards
30 # other:
31 # gxb: all gxbaby board
32 # gxtvbb: all gxtvbb board
33 # skt: all socket board
34 # p200: p200 board
35 # etc.....
36 declare filter="$1"
37
38 # ARRAY_CFG store config names
39 declare -a ARRAY_CFG
40 declare -a ARRAY_CFG_C
41 # TOTAL_CFG store config total num
42 declare -i TOTAL_CFG
43 declare -i TOTAL_CFG_C
44
45 # if filter!=cus, then include amlogic configs
46 # get all configs name from board folder
47 if [ "$1" != "cus" ]
48 then
49 filter=$1
Honglin Zhang4a5037f2020-01-14 14:24:34 +080050 for file in ${folder_board_v2015}/* ${folder_board_v2019}/*; do
Xiaobo Gud935a952017-06-13 15:20:20 +080051 temp_file=`basename $file`
xiaobo guca516382019-06-25 11:04:54 +080052 # del "_defconfig"
Honglin Zhang4a5037f2020-01-14 14:24:34 +080053 # v2015 defconfig folder is not aligned with board folder !
xiaobo guca516382019-06-25 11:04:54 +080054 temp_file=${temp_file%_*}
Xiaobo Gud935a952017-06-13 15:20:20 +080055 #echo "$temp_file"
Honglin Zhang4a5037f2020-01-14 14:24:34 +080056 #if [[ -d ${folder_board_v2015}/${temp_file} || -d ${folder_board_v2019}/${temp_file} ]] && \
57 # [ "$temp_file" != "defconfigs" ] && [ "$temp_file" != "configs" ]; then
58 if [ -n "$temp_file" ] && [[ -e ${folder_board_v2015}/${temp_file}'_defconfig' || \
59 -e ${folder_board_v2019}/${temp_file}'_defconfig' ]]; then
60 ARRAY_CFG[$TOTAL_CFG]=$temp_file
61 TOTAL_CFG=$TOTAL_CFG+1
62 fi
Xiaobo Gud935a952017-06-13 15:20:20 +080063 done
64 fi
65
66 # if filter==all || filter==cus, then include customer configs
67 # get all customer configs name from customer board folder
68 if [ "$1" == "cus" ] || [ "$1" == "all" ]
69 then
70 filter=""
Honglin Zhang4a5037f2020-01-14 14:24:34 +080071 if [[ -e ${customer_folder_v2015} || -e ${customer_folder_v2019} ]]; then
72 for file in ${customer_folder_v2015}/* ${customer_folder_v2019}/*; do
Xiaobo Gud935a952017-06-13 15:20:20 +080073 temp_file=`basename $file`
xiaobo guca516382019-06-25 11:04:54 +080074 temp_file=${temp_file%_*}
75 #echo $temp_file
76 ARRAY_CFG_C[$TOTAL_CFG_C]=$temp_file
77 TOTAL_CFG_C=$TOTAL_CFG_C+1
Xiaobo Gud935a952017-06-13 15:20:20 +080078 done
79 fi
80 fi
81
82 echo "************************ START *************************"
83
84 # compile check start
85 # RESULT store compile result
86 declare RESULT=""
87 declare -i LOOP_NUM=0
88 # counter variables
89 declare -i PASS_COUNTER=0
90 declare -i FAIL_COUNTER=0
91
92 # print bar and alignment
93 declare -i BAR_TOTAL=30
94 declare -i BAR_LOOP
95
96 RESULT=$RESULT"########### Compile Check Result ###########\n"
97
98 if [ "$1" != "cus" ]
99 then
100 RESULT=$RESULT"--------------------------------------------\n"
101 RESULT=$RESULT"############## Amlogic Boards ##############\n"
102 # loop all cfgs
103 for cfg in ${ARRAY_CFG[@]}
104 do
105 # find filter in config name
106 if [[ $(echo $cfg | grep "${filter}") == "" ]]
107 then
108 # skip !filter configs
109 continue
110 fi
111 LOOP_NUM=$LOOP_NUM+1
112 RESULT=$RESULT' '
113 # print '0' charactors for alignment
114 BAR_LOOP=3-`expr length $LOOP_NUM`
115 if [ "$BAR_LOOP" -gt "0" ]
116 then
117 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
118 fi
119 RESULT=$RESULT$LOOP_NUM' '
120 RESULT=$RESULT$cfg' '
121 # print '-' charactors for alignment
122 BAR_LOOP=BAR_TOTAL-`expr length $cfg`
123 if [ "$BAR_LOOP" -gt "0" ]
124 then
125 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
126 fi
xiaobo gu66f95292018-01-11 13:38:13 +0800127 BUILD_COUNTER=3
128 BUILD_RESULT=0
129 while [ "${BUILD_COUNTER}" -gt "0" ]; do
130 BUILD_COUNTER=$((BUILD_COUNTER - 1))
131 #make distclean
132 #make $cfg'_defconfig'
133 #make -j
134 fip/mk_script.sh $cfg
135 # check last 'make -j' result
136 if [ $? != 0 ]; then
137 BUILD_RESULT=$((BUILD_RESULT + 1))
138 else
139 BUILD_RESULT=0
140 BUILD_COUNTER=0
141 fi
142 done
143 # check compile result
144 if [ ${BUILD_RESULT} != 0 ]; then
Xiaobo Gud935a952017-06-13 15:20:20 +0800145 RESULT=$RESULT'- failed\n'
146 FAIL_COUNTER=$FAIL_COUNTER+1
147 else
148 RESULT=$RESULT'- pass\n'
149 PASS_COUNTER=$PASS_COUNTER+1
150 fi
151 # print result
152 echo -e $RESULT
153 #echo $cfg
154 done
155 fi
156
157 # check customer configs
158 if [ "$1" == "cus" ] || [ "$1" == "all" ]
159 then
160 RESULT=$RESULT"--------------------------------------------\n"
161 RESULT=$RESULT"############## Customer Boards #############\n"
162 for cfg in ${ARRAY_CFG_C[@]}
163 do
164 LOOP_NUM=$LOOP_NUM+1
165 RESULT=$RESULT' '
166 BAR_LOOP=3-`expr length $LOOP_NUM`
167 if [ "$BAR_LOOP" -gt "0" ]
168 then
169 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'0';done
170 fi
171 RESULT=$RESULT$LOOP_NUM' '
172 RESULT=$RESULT$cfg' '
173 BAR_LOOP=BAR_TOTAL-`expr length $cfg`
174 if [ "$BAR_LOOP" -gt "0" ]
175 then
176 for tmp in `seq $BAR_LOOP`;do RESULT=$RESULT'-';done
177 fi
178 make distclean
179 make $cfg'_defconfig'
180 make -j
181 if [ $? != 0 ]
182 then
183 RESULT=$RESULT'- failed\n'
184 FAIL_COUNTER=$FAIL_COUNTER+1
185 else
186 RESULT=$RESULT'- pass\n'
187 PASS_COUNTER=$PASS_COUNTER+1
188 fi
189 echo -e $RESULT
190 done
191 fi
192
193 echo -e "#################### END ###################\n"
194}