travis.sh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env bash
  2. # Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors.
  3. # SPDX-License-Identifier: mit
  4. build_cmake() {
  5. sudo apt install -y xmlto
  6. mkdir $PWD/_build && cd $PWD/_build
  7. cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DBUILD_TOOLS_DOCS=ON -DCMAKE_INSTALL_PREFIX=$PWD/../_install -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Wno-implicit-fallthrough -Werror"
  8. cmake --build . --target install
  9. ctest -V .
  10. }
  11. build_framing() {
  12. sudo apt install -y clang-format
  13. ./regenerate_framing.sh
  14. mkdir $PWD/_build && cd $PWD/_build
  15. cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_INSTALL_PREFIX=$PWD/../_install -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Wno-implicit-fallthrough -Werror"
  16. cmake --build . --target install
  17. ctest -V .
  18. }
  19. build_macos() {
  20. mkdir $PWD/_build && cd $PWD/_build
  21. cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_INSTALL_PREFIX=$PWD/../_install -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Werror" \
  22. -DOPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1"
  23. cmake --build . --target install
  24. ctest -V .
  25. }
  26. build_format() {
  27. sudo apt-get install -y clang-format
  28. ./travis/run-clang-format/run-clang-format.py \
  29. --clang-format-executable="${PWD}/travis/clang-format.sh" \
  30. --recursive examples librabbitmq tests tools
  31. }
  32. build_coverage() {
  33. mkdir $PWD/_build && cd $PWD/_build
  34. cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Coverage -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
  35. -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Werror -fprofile-arcs -ftest-coverage"
  36. cmake --build . --target install
  37. ctest -V .
  38. pip install --user cpp-coveralls
  39. coveralls --exclude tests --build-root . --root .. --gcov-options '\-lp'
  40. }
  41. build_asan() {
  42. mkdir $PWD/_build && cd $PWD/_build
  43. cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
  44. -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Werror -fsanitize=address,undefined -O1"
  45. cmake --build . --target install
  46. ctest -V .
  47. }
  48. build_tsan() {
  49. mkdir $PWD/_build && cd $PWD/_build
  50. cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
  51. -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Werror -fsanitize=thread,undefined -O1"
  52. cmake --build . --target install
  53. ctest -V .
  54. }
  55. build_scan-build() {
  56. sudo apt install -y clang-tools
  57. mkdir $PWD/_build && cd $PWD/_build
  58. scan-build cmake .. -GNinja -DBUILD_EXAMPLES=ON -DBUILD_TOOLS=ON -DCMAKE_BUILD_TYPE=Debug \
  59. -DCMAKE_C_COMPILER=clang \
  60. -DCMAKE_INSTALL_PREFIX=$PWD/../_install \
  61. -DCMAKE_C_FLAGS="-Wall -Wextra -Wstrict-prototypes -Wno-unused-function -Werror"
  62. scan-build ninja install
  63. }
  64. if [ "$#" -ne 1 ]; then
  65. echo "Usage: $0 {cmake|framing|macos|format|coverage|asan|tsan|scan-build}"
  66. exit 1
  67. fi
  68. set -e # exit on error.
  69. set -x # echo commands.
  70. eval "build_$1"