-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.sh
More file actions
65 lines (53 loc) · 1.17 KB
/
build.sh
File metadata and controls
65 lines (53 loc) · 1.17 KB
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
#!/bin/bash
set -o errexit -o pipefail -o noclobber -o nounset
getopt --test > /dev/null && true
if [[ $? -ne 4 ]]; then
echo 'I’m sorry, `getopt --test` failed in this environment.'
exit 1
fi
LONGOPTS=release,test
OPTIONS=rt
PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") || exit 2
eval set -- "$PARSED"
d=y r=n t=n outFile=-
while true; do
case "$1" in
-r|--release)
r=y
shift
;;
-t|--test)
t=y
shift
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
# handle non-option arguments
if [[ $# -ne 0 ]]; then
echo "Build takes no arguments"
exit 4
fi
FLAGS=""
if [[ "$r" == y ]]; then
mkdir -p cmake-build-release
cd cmake-build-release
FLAGS="-O2 -DNDEBUG -Wall -Wextra -pedantic -Werror"
else
mkdir -p cmake-build-debug
cd cmake-build-debug
FLAGS="-Og -g -Wall -Wextra -pedantic"
fi
if [[ "$t" == y ]]; then
cmake -DCMAKE_C_FLAGS="$FLAGS" -DINI_TEST=ON ..
else
cmake -DCMAKE_C_FLAGS="$FLAGS" ..
fi
make