You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
2.9 KiB

8 years ago
8 years ago
  1. #!/bin/bash
  2. # Inspired by https://github.com/google/fruit
  3. set -e
  4. # Helper for travis folding
  5. travis_fold() {
  6. local action=$1
  7. local name=$2
  8. echo -en "travis_fold:${action}:${name}\r"
  9. }
  10. # Helper to write output every minute
  11. function bell() {
  12. while true; do
  13. echo "travis_wait for it..."
  14. sleep 60
  15. done
  16. }
  17. # Helper for distinguishing between different runs
  18. run() {
  19. case "$1" in
  20. Build*)
  21. if [[ "$1" == "Build1" ]]
  22. then
  23. # CMake
  24. travis_fold start cmake
  25. mkdir build
  26. cd build
  27. cmake .. "${CMAKE_ARGS[@]}"
  28. echo
  29. if [ -f "CMakeFiles/CMakeError.log" ]
  30. then
  31. echo "Content of CMakeFiles/CMakeError.log:"
  32. cat CMakeFiles/CMakeError.log
  33. fi
  34. echo
  35. cd ..
  36. travis_fold end cmake
  37. fi
  38. # Make
  39. travis_fold start make
  40. cd build
  41. make -j$N_JOBS
  42. travis_fold end make
  43. # Set skip-file
  44. if [[ "$1" != "BuildLast" ]]
  45. then
  46. touch skip.txt
  47. else
  48. rm -rf skip.txt
  49. fi
  50. ;;
  51. TestAll)
  52. # Test all
  53. travis_fold start test_all
  54. cd build
  55. ctest test --output-on-failure
  56. travis_fold end test_all
  57. ;;
  58. *)
  59. echo "Unrecognized value of run: $1"
  60. exit 1
  61. esac
  62. }
  63. # This only exists in OS X, but it doesn't cause issues in Linux (the dir doesn't exist, so it's
  64. # ignored).
  65. export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
  66. case $COMPILER in
  67. gcc-6)
  68. export CC=gcc-6
  69. export CXX=g++-6
  70. ;;
  71. gcc)
  72. export CC=gcc
  73. export CXX=g++
  74. ;;
  75. clang-4)
  76. case "$OS" in
  77. linux)
  78. export CC=clang-4.0
  79. export CXX=clang++-4.0
  80. ;;
  81. osx)
  82. export CC=/usr/local/opt/llvm/bin/clang-4.0
  83. export CXX=/usr/local/opt/llvm/bin/clang++
  84. ;;
  85. *) echo "Error: unexpected OS: $OS"; exit 1 ;;
  86. esac
  87. ;;
  88. clang)
  89. export CC=clang
  90. export CXX=clang++
  91. ;;
  92. *)
  93. echo "Unrecognized value of COMPILER: $COMPILER"
  94. exit 1
  95. esac
  96. # Build
  97. echo CXX version: $($CXX --version)
  98. echo C++ Standard library location: $(echo '#include <vector>' | $CXX -x c++ -E - | grep 'vector\"' | awk '{print $3}' | sed 's@/vector@@;s@\"@@g' | head -n 1)
  99. echo Normalized C++ Standard library location: $(readlink -f $(echo '#include <vector>' | $CXX -x c++ -E - | grep 'vector\"' | awk '{print $3}' | sed 's@/vector@@;s@\"@@g' | head -n 1))
  100. case "$CONFIG" in
  101. DefaultDebug) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG") ;;
  102. DefaultRelease) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG") ;;
  103. *) echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 ;;
  104. esac
  105. # Restore timestamps of files
  106. travis_fold start mtime
  107. if [[ "$1" == "Build1" ]]
  108. then
  109. # Remove old mtime cache
  110. rm -rf travis/mtime_cache/cache.json
  111. fi
  112. ruby travis/mtime_cache/mtime_cache.rb -g travis/mtime_cache/globs.txt -c travis/mtime_cache/cache.json
  113. travis_fold end mtime
  114. # Run and print output to avoid travis timeout
  115. bell &
  116. bellPID=$!
  117. run "$1"
  118. kill $bellPID