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.

164 lines
3.3 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. Build1 | Build2 | Build3 | Build4)
  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" != "Build4" ]]
  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-4.8)
  61. export CC=gcc-4.8
  62. export CXX=g++-4.8
  63. ;;
  64. gcc-4.9)
  65. export CC=gcc-4.9
  66. export CXX=g++-4.9
  67. ;;
  68. gcc-5)
  69. export CC=gcc-5
  70. export CXX=g++-5
  71. ;;
  72. gcc-6)
  73. export CC=gcc-6
  74. export CXX=g++-6
  75. ;;
  76. gcc-default)
  77. export CC=gcc
  78. export CXX=g++
  79. ;;
  80. clang-3.5)
  81. export CC=clang-3.5
  82. export CXX=clang++-3.5
  83. ;;
  84. clang-3.6)
  85. export CC=clang-3.6
  86. export CXX=clang++-3.6
  87. ;;
  88. clang-3.7)
  89. export CC=clang-3.7
  90. export CXX=clang++-3.7
  91. ;;
  92. clang-3.8)
  93. export CC=clang-3.8
  94. export CXX=clang++-3.8
  95. ;;
  96. clang-3.9)
  97. export CC=clang-3.9
  98. export CXX=clang++-3.9
  99. ;;
  100. clang-4.0)
  101. case "$OS" in
  102. linux)
  103. export CC=clang-4.0
  104. export CXX=clang++-4.0
  105. ;;
  106. osx)
  107. export CC=/usr/local/opt/llvm/bin/clang-4.0
  108. export CXX=/usr/local/opt/llvm/bin/clang++
  109. ;;
  110. *) echo "Error: unexpected OS: $OS"; exit 1 ;;
  111. esac
  112. ;;
  113. clang-default)
  114. export CC=clang
  115. export CXX=clang++
  116. ;;
  117. *)
  118. echo "Unrecognized value of COMPILER: $COMPILER"
  119. exit 1
  120. esac
  121. # Build
  122. echo CXX version: $($CXX --version)
  123. 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)
  124. 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))
  125. case "$CONFIG" in
  126. DefaultDebug) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG") ;;
  127. DefaultRelease) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG") ;;
  128. *) echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 ;;
  129. esac
  130. # Restore timestamps of files
  131. travis_fold start mtime
  132. if [[ "$1" == "Build1" ]]
  133. then
  134. # Remove old mtime cache
  135. rm -rf travis/mtime_cache/cache.json
  136. fi
  137. ruby travis/mtime_cache/mtime_cache.rb -g travis/mtime_cache/globs.txt -c travis/mtime_cache/cache.json
  138. travis_fold end mtime
  139. run "$1"