-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sh
executable file
·63 lines (48 loc) · 1.54 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
#!/usr/bin/env bash
set -e
# usage: ./build.sh [clean|clean --confirm|skiptest]
BUILD_DIR=cmake-build
# Choose: Debug, Release, RelWithDebInfo and MinSizeRel. Use Debug for asan checking locally.
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/*.inc
if [[ "$2" == "--confirm" ]]; then
# remove all packages from the conan cache, to allow swapping between Release/Debug builds
conan remove "*" --confirm
fi
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export CC=gcc-13
export CXX=g++-13
fi
if [[ ! -f "$HOME/.conan2/profiles/default" ]]; then
echo -e "${BLUE}==== create default profile ====${NC}"
conan profile detect
fi
if [[ ! -d $BUILD_DIR ]]; then
echo -e "${BLUE}==== install required dependencies ====${NC}"
if [[ "$BUILD_TYPE" == "Debug" ]]; then
conan install . --output-folder=$BUILD_DIR --build="*" --settings=build_type=$BUILD_TYPE --profile=./sanitized
else
conan install . --output-folder=$BUILD_DIR --build=missing
fi
fi
pushd $BUILD_DIR
echo -e "${BLUE}==== configure conan environment to access tools ====${NC}"
source conanbuild.sh
if [[ $OSTYPE == "darwin"* ]]; then
export MallocNanoZone=0
fi
echo -e "${BLUE}==== generate build files ====${NC}"
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE
echo -e "${BLUE}==== build ====${NC}"
cmake --build .
if [[ "$1" != "skiptest" ]]; then
echo -e "${BLUE}==== test ====${NC}"
GTEST_COLOR=1 ctest --verbose
fi
popd