build.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. _stat() {
  2. if test "${CI_OS_NAME}" = osx ; then
  3. stat -f %Sm "${@}"
  4. else
  5. stat -c %y "${@}"
  6. fi
  7. }
  8. top_make() {
  9. printf '%78s\n' | tr ' ' '='
  10. # Travis has 1.5 virtual cores according to:
  11. # http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
  12. ninja "$@"
  13. }
  14. build_make() {
  15. top_make -C "${BUILD_DIR}" "$@"
  16. }
  17. build_deps() {
  18. if test "${FUNCTIONALTEST}" = "functionaltest-lua" \
  19. || test "${CLANG_SANITIZER}" = "ASAN_UBSAN" ; then
  20. DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS} -DUSE_BUNDLED_LUA=ON"
  21. fi
  22. mkdir -p "${DEPS_BUILD_DIR}"
  23. # Use cached dependencies if $CACHE_MARKER exists.
  24. if test "${CACHE_ENABLE}" = "false" ; then
  25. export CCACHE_RECACHE=1
  26. elif test -f "${CACHE_MARKER}" ; then
  27. echo "Using third-party dependencies from cache (last update: $(_stat "${CACHE_MARKER}"))."
  28. cp -a "${CACHE_NVIM_DEPS_DIR}"/. "${DEPS_BUILD_DIR}"
  29. fi
  30. # Even if we're using cached dependencies, run CMake and make to
  31. # update CMake configuration and update to newer deps versions.
  32. cd "${DEPS_BUILD_DIR}"
  33. echo "Configuring with '${DEPS_CMAKE_FLAGS}'."
  34. CC= cmake -G Ninja ${DEPS_CMAKE_FLAGS} "${CI_BUILD_DIR}/third-party/"
  35. if ! top_make; then
  36. exit 1
  37. fi
  38. cd "${CI_BUILD_DIR}"
  39. }
  40. prepare_build() {
  41. if test -n "${CLANG_SANITIZER}" ; then
  42. CMAKE_FLAGS="${CMAKE_FLAGS} -DCLANG_${CLANG_SANITIZER}=ON"
  43. fi
  44. mkdir -p "${BUILD_DIR}"
  45. cd "${BUILD_DIR}"
  46. echo "Configuring with '${CMAKE_FLAGS} $@'."
  47. cmake -G Ninja ${CMAKE_FLAGS} "$@" "${CI_BUILD_DIR}"
  48. }
  49. build_nvim() {
  50. echo "Building nvim."
  51. if ! top_make nvim ; then
  52. exit 1
  53. fi
  54. if test "$CLANG_SANITIZER" != "TSAN" ; then
  55. echo "Building libnvim."
  56. if ! top_make libnvim ; then
  57. exit 1
  58. fi
  59. if test "${FUNCTIONALTEST}" != "functionaltest-lua"; then
  60. echo "Building nvim-test."
  61. if ! top_make nvim-test ; then
  62. exit 1
  63. fi
  64. fi
  65. fi
  66. # Invoke nvim to trigger *San early.
  67. if ! (bin/nvim --version && bin/nvim -u NONE -e -cq | cat -vet) ; then
  68. check_sanitizer "${LOG_DIR}"
  69. exit 1
  70. fi
  71. check_sanitizer "${LOG_DIR}"
  72. cd "${CI_BUILD_DIR}"
  73. }