-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.lint.sh
59 lines (53 loc) · 1.14 KB
/
.lint.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
#!/usr/bin/env bash
set -e
# build libmill
rm -rf libmill
curl -s -L https://github.com/sustrik/libmill/archive/master.tar.gz | tar -zxf -
mv libmill-master libmill
cd libmill
./autogen.sh
./configure --enable-shared=false
make libmill.la
cd ../
# build with clang analyzer
if [ -f Makefile ]; then
make distclean
fi
autoreconf -if
export CC=/usr/lib/clang/ccc-analyzer
export CPPFLAGS
CPPFLAGS=-I$(pwd)/libmill
export LDFLAGS
LDFLAGS=-L$(pwd)/libmill/.libs
./configure --enable-debug
# process clang analysis result
rm -rf .lint
scan-build -o .lint -analyze-headers --use-cc=clang make
cd .lint/
DIR=$(ls)
if [[ ${DIR} ]]; then
mv ${DIR}/* ./
rmdir ${DIR}
fi
cd ../
if [ -f .lint/index.html ]; then
BUG=$(cat .lint/index.html | grep 'All Bugs' | tr '><' '\n' | grep '[0-9]')
else
echo 'No warning found.' > .lint/index.html
BUG=0
fi
if [ ${BUG} -lt 3 ]; then
COLOR=brightgreen
elif [ ${BUG} -lt 6 ]; then
COLOR=yellow
else
COLOR=red
fi
if [ ${BUG} -lt 1 ]; then
BUG="${BUG}%20warning"
else
BUG="${BUG}%20warnings"
fi
curl -s -o .lint.svg "https://api.pxx.io/badge/badge/lint-${BUG}-${COLOR}.svg"
# cleanup
make distclean