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.

158 lines
3.2 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. echo "Content of CMakeFiles/CMakeError.log:"
  23. if [ -f "CMakeFiles/CMakeError.log" ]
  24. then
  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 | Build4)
  36. # Make (run 2-4)
  37. travis_fold start make
  38. cd build
  39. make -j$N_JOBS
  40. travis_fold end make
  41. touch skip.txt
  42. ;;
  43. TestAll)
  44. # Test all
  45. travis_fold start test_all
  46. cd build
  47. ctest test --output-on-failure
  48. travis_fold end test_all
  49. ;;
  50. *)
  51. echo "Unrecognized value of run: $1"
  52. exit 1
  53. esac
  54. }
  55. # This only exists in OS X, but it doesn't cause issues in Linux (the dir doesn't exist, so it's
  56. # ignored).
  57. export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
  58. case $COMPILER in
  59. gcc-4.8)
  60. export CC=gcc-4.8
  61. export CXX=g++-4.8
  62. ;;
  63. gcc-4.9)
  64. export CC=gcc-4.9
  65. export CXX=g++-4.9
  66. ;;
  67. gcc-5)
  68. export CC=gcc-5
  69. export CXX=g++-5
  70. ;;
  71. gcc-6)
  72. export CC=gcc-6
  73. export CXX=g++-6
  74. ;;
  75. gcc-default)
  76. export CC=gcc
  77. export CXX=g++
  78. ;;
  79. clang-3.5)
  80. export CC=clang-3.5
  81. export CXX=clang++-3.5
  82. ;;
  83. clang-3.6)
  84. export CC=clang-3.6
  85. export CXX=clang++-3.6
  86. ;;
  87. clang-3.7)
  88. export CC=clang-3.7
  89. export CXX=clang++-3.7
  90. ;;
  91. clang-3.8)
  92. export CC=clang-3.8
  93. export CXX=clang++-3.8
  94. ;;
  95. clang-3.9)
  96. export CC=clang-3.9
  97. export CXX=clang++-3.9
  98. ;;
  99. clang-4.0)
  100. case "$OS" in
  101. linux)
  102. export CC=clang-4.0
  103. export CXX=clang++-4.0
  104. ;;
  105. osx)
  106. export CC=/usr/local/opt/llvm/bin/clang-4.0
  107. export CXX=/usr/local/opt/llvm/bin/clang++
  108. ;;
  109. *) echo "Error: unexpected OS: $OS"; exit 1 ;;
  110. esac
  111. ;;
  112. clang-default)
  113. export CC=clang
  114. export CXX=clang++
  115. ;;
  116. *)
  117. echo "Unrecognized value of COMPILER: $COMPILER"
  118. exit 1
  119. esac
  120. # Build
  121. echo CXX version: $($CXX --version)
  122. 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)
  123. 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))
  124. case "$1" in
  125. DefaultDebug) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG") ;;
  126. DefaultRelease) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG") ;;
  127. *) echo "Error: you need to specify one of the supported postsubmit modes (see postsubmit.sh)."; exit 1 ;;
  128. esac
  129. # Restore timestamps of files
  130. travis_fold start mtime
  131. ruby travis/mtime_cache/mtime_cache.rb -g travis/mtime_cache/globs.txt -c travis/mtime_cache/cache.json
  132. travis_fold end mtime
  133. run "$2"