-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure.sh
executable file
·68 lines (60 loc) · 1.62 KB
/
configure.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
set -o errexit # set -e: exit the script if any statement returns a non-true value
# Program constants
ROOT_DIR="$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd -P
)"
BUILD_DIR="$ROOT_DIR/build"
# Program options
CXX=${CXX:-"g++"}
function usage() {
echo -e "Usage:\n$0 [options]"
echo -e "\nConfigure a build directory using the provided options."
echo -e "\nGeneral options:"
echo -e " -h,--help Display this help message"
echo -e " -c,--clang Use clang as compiler"
echo -e " -t,--test Enable the testbed build target"
echo -e "\nClang-specific options:"
echo -e " -y,--tidy Enable clang-tidy static analysis target"
echo
exit "${1:-1}"
}
function configure() {
cmake \
-DCMAKE_CXX_COMPILER="$CXX" \
-DBUILD_TYPE="$HITBOX_BUILDER_BUILD_TYPE" \
-DHITBOX_BUILDER_ENABLE_CLANGTIDY="$HITBOX_BUILDER_ENABLE_CLANGTIDY" \
-DHITBOX_BUILDER_BUILD_TESTBED="$HITBOX_BUILDER_BUILD_TESTBED" \
"$ROOT_DIR"
}
# Process arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --help)
usage 0
;;
-c | --clang)
CXX="clang++"
shift
;;
-t | --test)
HITBOX_BUILDER_BUILD_TESTBED="ON"
shift
;;
-y | --tidy)
HITBOX_BUILDER_ENABLE_CLANGTIDY="ON"
shift
;;
-*)
echo -e "unknown option '$1'"
usage
;;
esac
done
# Prevent use of clang-only options with other compilers
if [[ "$HITBOX_BUILDER_ENABLE_CLANGTIDY" == "ON" && "$CXX" != "clang++" ]]; then
echo -e "cannot use clang-tidy if compiler is not clang"
usage
fi
mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR" && configure