.travis-build.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. set -e
  3. set -x
  4. if grep -nr '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .travis* dist/*.desktop \
  5. dist/*.svg dist/*.xml; then
  6. echo Trailing whitespace found, aborting
  7. exit 1
  8. fi
  9. # Only run clang-format on Linux because we don't have 4.0 on OS X images
  10. if [ "$TRAVIS_OS_NAME" = "linux" ]; then
  11. # Default clang-format points to default 3.5 version one
  12. CLANG_FORMAT=clang-format-4.0
  13. $CLANG_FORMAT --version
  14. if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
  15. # Get list of every file modified in this pull request
  16. files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)"
  17. else
  18. # Check everything for branch pushes
  19. files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
  20. fi
  21. # Turn off tracing for this because it's too verbose
  22. set +x
  23. for f in $files_to_lint; do
  24. d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
  25. if ! [ -z "$d" ]; then
  26. echo "!!! $f not compliant to coding style, here is the fix:"
  27. echo "$d"
  28. fail=1
  29. fi
  30. done
  31. set -x
  32. if [ "$fail" = 1 ]; then
  33. exit 1
  34. fi
  35. fi
  36. #if OS is linux or is not set
  37. if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then
  38. export CC=gcc-6
  39. export CXX=g++-6
  40. export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH
  41. mkdir build && cd build
  42. cmake ..
  43. make -j4
  44. ctest -VV -C Release
  45. elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
  46. set -o pipefail
  47. export MACOSX_DEPLOYMENT_TARGET=10.9
  48. export Qt5_DIR=$(brew --prefix)/opt/qt5
  49. mkdir build && cd build
  50. cmake .. -GXcode
  51. xcodebuild -configuration Release
  52. ctest -VV -C Release
  53. fi