forked from silverweed/lifish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
covbuild.sh
executable file
·83 lines (74 loc) · 1.75 KB
/
covbuild.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
getversion() {
paste -d. <(grep -m1 MAJOR CMakeLists.txt|cut -f2 -d' '|cut -f1 -d\)) \
<(grep -m1 MINOR CMakeLists.txt|cut -f2 -d' '|cut -f1 -d\))
}
# Settings
PROJECT_NAME=lifish
EMAIL=silverweed1991@gmail.com
[[ `uname` == "FreeBSD" ]] \
&& COVERITY_PATH=$HOME/cov-analysis-freebsd64-8.5.0.1/bin \
|| COVERITY_PATH=$HOME/Public/cov-analysis-linux64-8.5.0.1/bin
VERSION=$(getversion)
###########
while [[ $# > 0 ]]; do
case $1 in
-s|--skip-build)
SKIP_BUILD=1
shift
;;
-c|--skip-clean)
SKIP_CLEAN=1
shift
;;
*)
echo "Usage: $0 [-s, --skip-build] [-c, --skip-clean]" >&2
exit 1
;;
esac
done
getbuild() {
git describe --always --long --dirty
}
getreadiness() {
tail cov-int/build-log.txt | grep compilation | cut -f2 -d\( | cut -f1 -d% | tail -1
}
PATH=$PATH:$COVERITY_PATH
if [[ $SKIP_BUILD != 1 ]]; then
[[ $SKIP_CLEAN != 1 ]] && make clean
rm -f ${PROJECT_NAME}.tgz
if (cov-build --dir cov-int make -j 4); then
tar cvfz ${PROJECT_NAME}.tgz cov-int
fi
fi
if [[ $? == 0 ]]; then
R=$(getreadiness)
if ((R < 85)); then
echo "[ ERROR ] only ${R}% compilation units are ready: build will fail."
exit 2
else
echo "[ OK ] ${R}% of the compilation units are ready."
fi
echo "Submit new build? ($(du -sh ${PROJECT_NAME}.tgz | cut -f1))"
select ANS in "Submit" "Abort"; do
case $ANS in
Submit)
echo Submitting... >&2
set -x
curl --form token=$(< ./cov-token) \
--form email=$EMAIL \
--form file=@./${PROJECT_NAME}.tgz \
--form version="${VERSION}" \
--form description="${PROJECT_NAME} build rev.$(getbuild)" \
https://scan.coverity.com/builds?project=${PROJECT_NAME}
set +x
echo Done. >&2
exit 0
;;
*)
echo Aborted. >&2
exit 1
;;
esac
done
fi