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