-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·87 lines (70 loc) · 2.26 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
#!/usr/bin/env bash
set -e
# usage: ./build.sh [clean|clean --confirm|skipsource|skiptest]
if [[ -z "$BUILD_DIR" ]]; then
BUILD_DIR="cmake-build"
fi
if [[ -z "$BUILD_TYPE" ]]; then
# Choose: Debug, Release, RelWithDebInfo and MinSizeRel. Use Debug for asan checking locally.
BUILD_TYPE="Debug"
fi
BLUE="\033[0;34m"
NC="\033[0m"
if [[ "$1" == "clean" ]]; then
echo -e "${BLUE}==== clean ====${NC}"
rm -rf "$BUILD_DIR"
# extracted and generated files
rm -f metatron/auth_context.pb.cc
rm -f metatron/auth_context.pb.h
rm -f metatron/auth_context.proto
rm -f metatron/metatron_config.cc
rm -rf ska
rm -f spectator/*.inc
rm -f spectator/netflix_config.cc
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
source /etc/os-release
if [[ "$NAME" == "Ubuntu" ]]; then
if [[ -z "$CC" ]]; then export CC=gcc-13; fi
if [[ -z "$CXX" ]]; then export CXX=g++-13; fi
fi
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
# this switch is necessary for internal centos builds
if [[ "$1" != "skipsource" ]]; then
echo -e "${BLUE}==== install source dependencies ====${NC}"
conan source .
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}"
if [[ "$NFLX_INTERNAL" != "ON" ]]; then
NFLX_INTERNAL=OFF
fi
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DNFLX_INTERNAL="$NFLX_INTERNAL"
echo -e "${BLUE}==== build ====${NC}"
cmake --build .
if [[ "$1" != "skiptest" ]]; then
echo -e "${BLUE}==== test ====${NC}"
GTEST_COLOR=1 ctest --verbose
fi
popd