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.

155 lines
3.1 KiB

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