generated from amoldhamale1105/CppProjectTemplate
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·60 lines (53 loc) · 1.26 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
#!/bin/bash
usage() { echo "usage: $0 [-a|c {a} (all|clean)] [-r|d {d} (release|debug)] [-g <cmake-generator> {Ninja}]" 2>&1; exit 0; }
BUILD_TYPE="Debug"
GENERATOR="Ninja"
TARGET="all"
ACTION="Build"
while getopts ":acrdg:h" arg; do
case "${arg}" in
a)
TARGET="all"
ACTION="Build"
;;
c)
TARGET="clean"
ACTION="Clean"
;;
r)
BUILD_TYPE="Release"
;;
d)
BUILD_TYPE="Debug"
;;
g)
GENERATOR=${OPTARG}
;;
h|*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ -z "${GENERATOR}" ]; then
usage
fi
if [ ${TARGET} = "all" ]; then
if [ -d ${PWD}/build ]; then
rm -rf build/{.[!.]*,*}
fi
echo "Configuring Event Loop in ${BUILD_TYPE} mode..."
cmake -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} -S . -B ${PWD}/build -G "${GENERATOR}"
fi
echo "${ACTION}ing Event Loop..."
if [ ! -z "$(ls -A ${PWD}/build)" ]; then
cmake --build ${PWD}/build --config ${BUILD_TYPE} --target ${TARGET}
fi
if [ ${TARGET} = "clean" ]; then
if [ -d ${PWD}/build ]; then
rm -rf build/{.[!.]*,*}
fi
if [ -d ${PWD}/lib ]; then
rm -rf lib/*
fi
fi