forked from temp-dong/bd-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
68 lines (55 loc) · 1.42 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
#!/bin/bash
SOURCE_DIR=`pwd`
BUILD_DIR=$SOURCE_DIR/build
CLEAN_UP_OPTION=false
BUILD_LAB_1_UT=false
BUILD_LAB_2_UT=false
CMAKE_OPTIONS=""
if [ $# == 0 ] ; then
echo "Only building src...."
fi
# check args
TEMP=`getopt -o sertfm --long clean,lab1,lab2 \
-n 'example.bash' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
--clean) echo "Clean up env."; CLEAN_UP_OPTION=true; shift ;;
--lab1) echo "Build unit tests for lab1."; BUILD_LAB_1_UT=true; shift ;;
--lab2) echo "Build unit tests for lab2."; BUILD_LAB_2_UT=true; shift ;;
--) shift ; break ;;
*) echo "Invalid argument!" ; exit 1 ;;
esac
done
# set up build dir
if [ "$CLEAN_UP_OPTION" = "true" ]
then
rm -rf ${BUILD_DIR}
fi
if [ "$BUILD_LAB_1_UT" = "true" ]
then
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBUILD_LAB_1_UT=true"
fi
if [ "$BUILD_LAB_2_UT" = "true" ]
then
CMAKE_OPTIONS="${CMAKE_OPTIONS} -DBUILD_LAB_2_UT=true"
fi
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR} && cmake ${SOURCE_DIR} ${CMAKE_OPTIONS} && make -j
if [ $? != 0 ]
then
echo "Fail to build!"
exit 1
fi
if [ "$BUILD_LAB_1_UT" = "true" ]
then
# copy test resources to the build dir
cp $SOURCE_DIR/test/resources/*.csv $BUILD_DIR/test/lab1/
fi
if [ "$BUILD_LAB_2_UT" = "true" ]
then
# copy test resources to the build dir
cp $SOURCE_DIR/test/resources/*.csv $BUILD_DIR/test/lab2/
fi
echo "Success."
exit 0