summaryrefslogtreecommitdiff
path: root/travis.sh
blob: 318b5e37780719a85dd38fc8db4fdd964be6b6f2 (plain)
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
#!/usr/bin/env bash

build_cmake() {
  mkdir $PWD/_build && cd $PWD/_build
  cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/../_install -DCMAKE_C_FLAGS="-Werror -Wno-implicit-fallthrough" \
    ${_CMAKE_OPENSSL_FLAG}
  cmake --build . --target install
  ctest -V .
}

build_format() {
  sudo apt-get install -y clang-format
  ./travis/run-clang-format/run-clang-format.py \
    --clang-format-executable="${PWD}/travis/clang-format.sh" \
    --recursive examples librabbitmq tests tools
}

build_coverage() {
  mkdir $PWD/_build && cd $PWD/_build
  cmake .. -DCMAKE_BUILD_TYPE=Coverage -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
    -DCMAKE_C_FLAGS="-Werror -fprofile-arcs -ftest-coverage" \
    ${_CMAKE_OPENSSL_FLAG}
  cmake --build . --target install
  ctest -V .
  
  pip install --user cpp-coveralls
  coveralls --exclude tests --build-root . --root .. --gcov-options '\-lp'
}

build_asan() {
  mkdir $PWD/_build && cd $PWD/_build
  cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
    -DCMAKE_C_FLAGS="-Werror -fsanitize=address,undefined -O1"
  cmake --build . --target install
  ctest -V .
}

build_tsan() {
  mkdir $PWD/_build && cd $PWD/_build
  cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
    -DCMAKE_C_FLAGS="-Werror -fsanitize=thread,undefined -O1"
  cmake --build . --target install
  ctest -V .
}

build_scan-build() {
  sudo apt-get install -y clang-tools
  mkdir $PWD/_build && cd $PWD/_build
  scan-build cmake .. -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
    -DCMAKE_C_FLAGS="-Werror"
  scan-build make install
}

if [ "$#" -ne 1 ]; then
  echo "Usage: $0 {cmake|asan|tsan|scan-build}"
  exit 1
fi

set -e  # exit on error.
set -x  # echo commands.

case $TRAVIS_OS_NAME in
osx)
  # This prints out a long list of updated packages, which isn't useful.
  brew update > /dev/null
  brew outdated openssl || brew install openssl
  export _CMAKE_OPENSSL_FLAG="-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
  ;;
esac

eval "build_$1"