-
Notifications
You must be signed in to change notification settings - Fork 0
/
cs_build.sh
executable file
·75 lines (66 loc) · 1.25 KB
/
cs_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
#!/bin/bash
do_clean=0
light_clean=0
USAGE="Usage: $0 [-c] [-l] [-h]
Options:
-c Clean build and all old CMake files.
-l Light clean build (but not clean CMake files).
-h Give help description."
while getopts "clh" opt; do
case "$opt" in
c) do_clean=1
light_clean=0
;;
l) light_clean=1
do_clean=0
;;
h) echo "$USAGE"
exit
;;
*) echo "Invalid Option!"
echo "$USAGE"
exit
;;
esac
done
# do clean
if test $do_clean -eq 1
then
if [ -e build -a -d build ]; then
rm -fr build
fi
if [ -e bin -a -d bin ]; then
rm -fr bin
fi
fi
# do light Clean
if test $light_clean -eq 1
then
if [ -e bin -a -d bin ]; then
rm -fr bin
fi
fi
# create build directory
if [ -e build -a -d build ]
then
cd build
else
mkdir build && cd build
fi
# compile source files and build executables
cmake ..
cmake --build .
# create binary library
if ( test $? -eq 0 ); then
cd ..
if [ -e bin -a -d bin ]; then
cd bin && rm -fr *
else
mkdir bin && cd bin
fi
cp ../build/ch2/src/cs-* ./
cp ../build/ch3/src/cs-* ./
cp ../build/ch4/src/cs-* ./
cp ../build/ch5/src/cs-* ./
cp ../build/ch6/src/cs-* ./
fi