button.sh
1.64 KB
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
84
85
86
87
88
#!/bin/bash
BUILDDIR=qtcreator-build
PROJECTS="corpus2 toki maca"
BASEDIR=../..
CURDIR=`pwd`
FILTER="grep -i -C 4 error"
#FILTER=cat
function fail() {
echo "!!! $1 in $i !!!"
cd $CURDIR
exit 1
}
usage()
{
cat << EOF
usage: $0 options
OPTIONS:
-h Show this message
-c make clean before building
-e rm CMakeCache before building
-n skip make install step
-p pull from git repo first
EOF
}
OPT_CLEAN=
OPT_CACHE=
OPT_INSTALL=1
OPT_PULL=
while getopts "hcenp" OPTION
do
case $OPTION in
h)
usage
exit 0
;;
c)
OPT_CLEAN=1
;;
e)
OPT_CACHE=1
;;
n)
OPT_INSTALL=
;;
p)
OPT_PULL=1
;;
esac
done
for i in $PROJECTS; do
cd $BASEDIR/$i || fail "cd error"
if [[ ! -d $BUILDDIR ]]; then
echo "Creating $BUILDDIR subdirectory in $i"
mkdir $BUILDDIR
fi
cd $BUILDDIR
pwd
if [[ ! -z $OPT_PULL ]]; then
echo "--- Pulling $i..."
git pull
fi
echo "--- Configuring $i..."
if [[ ! -z $OPT_CACHE ]]; then
echo "--- rm CMakeCache.txt in $i ..."
rm CMakeCache.txt
fi
cmake .. > /dev/null || fail "cmake error"
if [[ ! -z $OPT_CLEAN ]]; then
echo "--- Cleaning $i..."
make clean > /dev/null || fail "make clean error"
fi
echo "--- Building $i..."
make -j4 > /dev/null || fail "make error"
if [[ ! -z $OPT_INSTALL ]]; then
echo "--- Installing $i..."
sudo make install > /dev/null || fail "make install error"
fi
sudo ldconfig
echo "--- Testing $i..."
make test > /dev/null || fail "make test error in"
done
cd $CURDIR