This repository has been archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·95 lines (78 loc) · 2.68 KB
/
docker.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
88
89
90
91
92
93
94
95
#!/bin/sh -e
# Autogenerated by 'mkbuild'; DO NOT EDIT!
USAGE="Usage: $0 asan|clang|coverage|ubsan|vanilla"
if [ $# -eq 1 ]; then
INTERNAL=0
BUILD_TYPE="$1"
elif [ $# -eq 2 -a "$1" = "-internal" ]; then
INTERNAL=1
BUILD_TYPE="$2"
else
echo "$USAGE" 1>&2
exit 1
fi
if [ "$CODECOV_TOKEN" = "" ]; then
echo "WARNING: CODECOV_TOKEN is not set" 1>&2
fi
if [ "$TRAVIS_BRANCH" = "" ]; then
echo "WARNING: TRAVIS_BRANCH is not set" 1>&2
fi
set -x
if [ $INTERNAL -eq 0 ]; then
exec docker run --cap-add=NET_ADMIN \
--cap-add=SYS_PTRACE \
-e CODECOV_TOKEN=$CODECOV_TOKEN \
-e TRAVIS_BRANCH=$TRAVIS_BRANCH \
-v "$(pwd):/mk" \
--workdir /mk \
-t bassosimone/mk-debian \
./docker.sh -internal "$1"
fi
env | grep -v TOKEN | sort
# Select the proper build flags depending on the build type
if [ "$BUILD_TYPE" = "asan" ]; then
export CFLAGS="-fsanitize=address -O1 -fno-omit-frame-pointer"
export CXXFLAGS="-fsanitize=address -O1 -fno-omit-frame-pointer"
export LDFLAGS="-fsanitize=address -fno-omit-frame-pointer"
export CMAKE_BUILD_TYPE="Debug"
elif [ "$BUILD_TYPE" = "clang" ]; then
export CMAKE_BUILD_TYPE="Release"
export CXXFLAGS="-stdlib=libc++"
export CC=clang
export CXX=clang++
elif [ "$BUILD_TYPE" = "coverage" ]; then
export CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
export CMAKE_BUILD_TYPE="Debug"
export CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov"
elif [ "$BUILD_TYPE" = "ubsan" ]; then
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover"
export CXXFLAGS="-fsanitize=undefined -fno-sanitize-recover"
export LDFLAGS="-fsanitize=undefined"
export CMAKE_BUILD_TYPE="Debug"
elif [ "$BUILD_TYPE" = "vanilla" ]; then
export CMAKE_BUILD_TYPE="Release"
else
echo "$0: BUILD_TYPE not in: asan, clang, coverage, ubsan, vanilla" 1>&2
exit 1
fi
# Configure and make equivalent
mkdir -p build/$BUILD_TYPE
cd build/$BUILD_TYPE
cmake -GNinja -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE ../../
cmake --build . -- -v
# Make sure we don't consume too much resources by bumping latency. Not all
# repositories need this feature. For them the code is commented out.
#tc qdisc add dev eth0 root netem delay 200ms 10ms
# Make check equivalent
ctest --output-on-failure -a -j8
# Stop adding latency. Commented out if we don't need it.
#tc qdisc del dev eth0 root
# Measure and possibly report the test coverage
if [ "$BUILD_TYPE" = "coverage" ]; then
lcov --directory . --capture -o lcov.info
if [ "$CODECOV_TOKEN" != "" ]; then
curl -fsSL -o codecov.sh https://codecov.io/bash
bash codecov.sh -X gcov -Z -f lcov.info
fi
fi