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.

124 lines
2.7 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 for distinguishing between different runs
  11. run() {
  12. case "$1" in
  13. Build*)
  14. if [[ "$1" == "Build1" ]]
  15. then
  16. # CMake
  17. travis_fold start cmake
  18. mkdir build
  19. cd build
  20. cmake .. "${CMAKE_ARGS[@]}"
  21. echo
  22. if [ -f "CMakeFiles/CMakeError.log" ]
  23. then
  24. echo "Content of CMakeFiles/CMakeError.log:"
  25. cat CMakeFiles/CMakeError.log
  26. fi
  27. echo
  28. cd ..
  29. travis_fold end cmake
  30. fi
  31. # Make
  32. travis_fold start make
  33. cd build
  34. make -j$N_JOBS
  35. travis_fold end make
  36. # Set skip-file
  37. if [[ "$1" != "BuildLast" ]]
  38. then
  39. touch skip.txt
  40. else
  41. rm -rf skip.txt
  42. fi
  43. ;;
  44. TestAll)
  45. # Test all
  46. travis_fold start test_all
  47. cd build
  48. ctest test --output-on-failure
  49. travis_fold end test_all
  50. ;;
  51. *)
  52. echo "Unrecognized value of run: $1"
  53. exit 1
  54. esac
  55. }
  56. # This only exists in OS X, but it doesn't cause issues in Linux (the dir doesn't exist, so it's
  57. # ignored).
  58. export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
  59. case $COMPILER in
  60. gcc-6)
  61. export CC=gcc-6
  62. export CXX=g++-6
  63. ;;
  64. gcc)
  65. export CC=gcc
  66. export CXX=g++
  67. ;;
  68. clang-4)
  69. case "$OS" in
  70. linux)
  71. export CC=clang-4.0
  72. export CXX=clang++-4.0
  73. ;;
  74. osx)
  75. export CC=/usr/local/opt/llvm/bin/clang-4.0
  76. export CXX=/usr/local/opt/llvm/bin/clang++
  77. ;;
  78. *) echo "Error: unexpected OS: $OS"; exit 1 ;;
  79. esac
  80. ;;
  81. clang)
  82. export CC=clang
  83. export CXX=clang++
  84. ;;
  85. *)
  86. echo "Unrecognized value of COMPILER: $COMPILER"
  87. exit 1
  88. esac
  89. # Build
  90. echo CXX version: $($CXX --version)
  91. 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)
  92. 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))
  93. case "$CONFIG" in
  94. DefaultDebug) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG") ;;
  95. DefaultRelease) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG") ;;
  96. *) echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 ;;
  97. esac
  98. # Restore timestamps of files
  99. travis_fold start mtime
  100. if [[ "$1" == "Build1" ]]
  101. then
  102. # Remove old mtime cache
  103. rm -rf travis/mtime_cache/cache.json
  104. fi
  105. ruby travis/mtime_cache/mtime_cache.rb -g travis/mtime_cache/globs.txt -c travis/mtime_cache/cache.json
  106. travis_fold end mtime
  107. run "$1"