-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·93 lines (89 loc) · 2.68 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
88
89
90
91
92
93
#!/bin/bash
#
# Syntax: build.sh -build.sh [Options] -m <build-mode>
# Options:
# -m Specify build mode. Accepted values are 'debug', 'debug-test', 'release', and 'release-test'
# -c (Optional) Clean built files. Use in conjunction with '-m'
# -h (Optional) Display help and exit.
#
clean=0
while getopts m:hc flag; do
case "$flag" in
m) mode=${OPTARG} ;;
h)
echo "Syntax: build.sh [Options] -m <build-mode>"
echo "Options:"
echo " -m Specify build mode. Accepted values are 'debug', 'debug-tests', 'release', and 'release-tests'"
echo " -c (Optional) Clean built files. Use in conjunction with '-m'"
echo " -h (Optional) Display this help and exit."
exit 0
;;
c) clean=1 ;;
*)
echo "Try 'build.sh -h' for more information."
exit 1
;;
esac
done
if [ "" = "${mode}" ]; then
echo "Error: No build mode specified. Try 'build.sh -h' for more information."
exit 1
fi
case "$mode" in
"debug")
if [ "${clean}" -eq 1 ]; then
echo "[ Clean | Debug ]"
echo "cmake --build ./cmake-build-debug --target clean -j 9"
cmake --build ./cmake-build-debug --target clean -j 9
echo "[ Clean finished ]"
else
echo "[ Build | Debug ]"
echo "cmake --build ./cmake-build-debug --target dsvcol -j 9"
cmake --build ./cmake-build-debug --target dsvcol -j 9
echo "[ Build finished ]"
fi
;;
"debug-tests")
if [ $clean -eq 1 ]; then
echo "[ Clean | Debug ]"
echo "cmake --build ./cmake-build-debug --target clean -j 9"
cmake --build ./cmake-build-debug --target clean -j 9
echo "[ Clean finished ]"
else
echo "[ Build | Debug ]"
echo "cmake --build ./cmake-build-debug --target all-tests -j 9"
cmake --build ./cmake-build-debug --target all-tests -j 9
echo "[ Build finished ]"
fi
;;
"release")
if [ $clean -eq 1 ]; then
echo "[ Clean | Release ]"
echo "cmake --build ./cmake-build-release --target clean -j 9"
cmake --build ./cmake-build-release --target clean -j 9
echo "[ Clean finished ]"
else
echo "[ Build | Release ]"
echo "cmake --build ./cmake-build-release --target dsvcol -j 9"
cmake --build ./cmake-build-release --target dsvcol -j 9
echo "[ Build finished ]"
fi
;;
"release-tests")
if [ $clean -eq 1 ]; then
echo "[ Clean | Release ]"
echo "cmake --build ./cmake-build-release --target clean -j 9"
cmake --build ./cmake-build-release --target clean -j 9
echo "[ Clean finished ]"
else
echo "[ Build | Release ]"
echo "cmake --build ./cmake-build-release --target all-tests -j 9"
cmake --build ./cmake-build-release --target all-tests -j 9
echo "[ Build finished ]"
fi
;;
*)
echo "Invalid build mode '$mode'"
exit 1
;;
esac