-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·87 lines (68 loc) · 1.24 KB
/
build.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
84
85
86
87
#!/bin/bash
print_help(){
echo "Usage: "
echo " $0 clean --- clean all build"
echo " $0 version version_str Debug/Release--- build a version"
}
check_env(){
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script"
exit 1
fi
}
build(){
PROJECT=$1
cd $PROJECT
BUILDTYPE=Release
if [ "$2"x = "Debug"x ]; then
BUILDTYPE=Debug
fi
if [ ! -d $BUILDTYPE ]; then
mkdir $BUILDTYPE
fi
cd $BUILDTYPE
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -B. -H../
make
if [ $? -eq 0 ]; then
echo "make $PROJECT successed";
else
echo "make $PROJECT failed";
exit;
fi
cd ../../
if [ ! -d /usr/local/include/$PROJECT ]; then
mkdir /usr/local/include/$PROJECT
fi
cp -R $PROJECT/*.h /usr/local/include/$PROJECT
cp -R $PROJECT/*.a /usr/local/lib
}
clean() {
echo "begin clean $1 $2"
BUILDTYPE=Release
if [ "$2"x = "Debug"x ]; then
BUILDTYPE=Debug
fi
PROJECT=$1
cd $PROJECT/$BUILDTYPE
make clean
cd ../../
}
case $1 in
clean)
if [ $# -lt 2 ]; then
print_help
exit
fi
clean $2 $3
;;
base|dbproxy)
build $1 $2
;;
all)
build base $2
build dbproxy $2
;;
*)
print_help
;;
esac