-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
executable file
·64 lines (51 loc) · 1.66 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
#!/usr/bin/env bash
# usage: ./build.sh [clean|clean --force|skiptest]
BUILD_DIR=cmake-build
# Choose: Debug, Release, RelWithDebInfo and MinSizeRel
BUILD_TYPE=Debug
BLUE="\033[0;34m"
NC="\033[0m"
if [[ "$1" == "clean" ]]; then
echo -e "${BLUE}==== clean ====${NC}"
rm -rf $BUILD_DIR
rm -f spectator-cpp-*.zip
rm -rf lib/spectator
if [[ "$2" == "--force" ]]; then
# remove all packages and binaries from the local cache, to allow swapping between Debug/Release builds
conan remove '*' --force
fi
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export CC=gcc-11
export CXX=g++-11
fi
if [[ ! -d $BUILD_DIR ]]; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo -e "${BLUE}==== configure default profile ====${NC}"
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
fi
echo -e "${BLUE}==== install required dependencies ====${NC}"
if [[ "$BUILD_TYPE" == "Debug" ]]; then
conan install . --build --install-folder $BUILD_DIR --profile ./sanitized
else
conan install . --build=missing --install-folder $BUILD_DIR
fi
echo -e "${BLUE}==== install source dependencies ====${NC}"
conan source .
fi
pushd $BUILD_DIR || exit 1
echo -e "${BLUE}==== generate build files ====${NC}"
if [[ "$TITUS_SYSTEM_SERVICE" == "ON" ]]; then
TITUS_SYSTEM_SERVICE="-DTITUS_SYSTEM_SERVICE=ON"
else
TITUS_SYSTEM_SERVICE="-DTITUS_SYSTEM_SERVICE=OFF"
fi
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $TITUS_SYSTEM_SERVICE .. || exit 1
echo -e "${BLUE}==== build ====${NC}"
cmake --build . || exit 1
if [[ "$1" != "skiptest" ]]; then
echo -e "${BLUE}==== test ====${NC}"
GTEST_COLOR=1 ctest --verbose
fi
popd || exit 1