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.

171 lines
3.4 KiB

8 years ago
8 years ago
8 years ago
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)
  14. travis_fold start cmake
  15. # Remove old build folder
  16. rm -rf build
  17. # 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. travis_fold end cmake
  29. # Make
  30. travis_fold start make
  31. make -j$N_JOBS
  32. travis_fold end make
  33. touch skip.txt
  34. ;;
  35. Build2 | Build3)
  36. # Make (run 2-3)
  37. travis_fold start make
  38. cd build
  39. make -j$N_JOBS
  40. travis_fold end make
  41. touch skip.txt
  42. ;;
  43. Build4)
  44. # Make (run 2-4)
  45. travis_fold start make
  46. cd build
  47. make -j$N_JOBS
  48. travis_fold end make
  49. ;;
  50. TestAll)
  51. # Test all
  52. travis_fold start test_all
  53. cd build
  54. ctest test --output-on-failure
  55. travis_fold end test_all
  56. ;;
  57. *)
  58. echo "Unrecognized value of run: $1"
  59. exit 1
  60. esac
  61. }
  62. # This only exists in OS X, but it doesn't cause issues in Linux (the dir doesn't exist, so it's
  63. # ignored).
  64. export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
  65. case $COMPILER in
  66. gcc-4.8)
  67. export CC=gcc-4.8
  68. export CXX=g++-4.8
  69. ;;
  70. gcc-4.9)
  71. export CC=gcc-4.9
  72. export CXX=g++-4.9
  73. ;;
  74. gcc-5)
  75. export CC=gcc-5
  76. export CXX=g++-5
  77. ;;
  78. gcc-6)
  79. export CC=gcc-6
  80. export CXX=g++-6
  81. ;;
  82. gcc-default)
  83. export CC=gcc
  84. export CXX=g++
  85. ;;
  86. clang-3.5)
  87. export CC=clang-3.5
  88. export CXX=clang++-3.5
  89. ;;
  90. clang-3.6)
  91. export CC=clang-3.6
  92. export CXX=clang++-3.6
  93. ;;
  94. clang-3.7)
  95. export CC=clang-3.7
  96. export CXX=clang++-3.7
  97. ;;
  98. clang-3.8)
  99. export CC=clang-3.8
  100. export CXX=clang++-3.8
  101. ;;
  102. clang-3.9)
  103. export CC=clang-3.9
  104. export CXX=clang++-3.9
  105. ;;
  106. clang-4.0)
  107. case "$OS" in
  108. linux)
  109. export CC=clang-4.0
  110. export CXX=clang++-4.0
  111. ;;
  112. osx)
  113. export CC=/usr/local/opt/llvm/bin/clang-4.0
  114. export CXX=/usr/local/opt/llvm/bin/clang++
  115. ;;
  116. *) echo "Error: unexpected OS: $OS"; exit 1 ;;
  117. esac
  118. ;;
  119. clang-default)
  120. export CC=clang
  121. export CXX=clang++
  122. ;;
  123. *)
  124. echo "Unrecognized value of COMPILER: $COMPILER"
  125. exit 1
  126. esac
  127. # Build
  128. echo CXX version: $($CXX --version)
  129. 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)
  130. 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))
  131. case "$CONFIG" in
  132. DefaultDebug) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG") ;;
  133. DefaultRelease) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG") ;;
  134. *) echo "Unrecognized value of CONFIG: $CONFIG"; exit 1 ;;
  135. esac
  136. # Restore timestamps of files
  137. travis_fold start mtime
  138. if [[ "$1" == "Build1" ]]
  139. then
  140. # Remove old mtime cache
  141. rm -rf travis/mtime_cache/cache.json
  142. fi
  143. ruby travis/mtime_cache/mtime_cache.rb -g travis/mtime_cache/globs.txt -c travis/mtime_cache/cache.json
  144. travis_fold end mtime
  145. run "$1"