build.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. ninja "$@"
  11. }
  12. build_make() {
  13. top_make -C "${BUILD_DIR}" "$@"
  14. }
  15. build_deps() {
  16. if test "${FUNCTIONALTEST}" = "functionaltest-lua" \
  17. || test "${CLANG_SANITIZER}" = "ASAN_UBSAN" ; then
  18. DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS} -DUSE_BUNDLED_LUA=ON"
  19. fi
  20. mkdir -p "${DEPS_BUILD_DIR}"
  21. # Use cached dependencies if $CACHE_MARKER exists.
  22. if test "${CACHE_ENABLE}" = "false" ; then
  23. export CCACHE_RECACHE=1
  24. elif test -f "${CACHE_MARKER}" ; then
  25. echo "Using third-party dependencies from cache (last update: $(_stat "${CACHE_MARKER}"))."
  26. cp -a "${CACHE_NVIM_DEPS_DIR}"/. "${DEPS_BUILD_DIR}"
  27. fi
  28. # Even if we're using cached dependencies, run CMake and make to
  29. # update CMake configuration and update to newer deps versions.
  30. cd "${DEPS_BUILD_DIR}"
  31. echo "Configuring with '${DEPS_CMAKE_FLAGS}'."
  32. CC= cmake -G Ninja ${DEPS_CMAKE_FLAGS} "${CI_BUILD_DIR}/third-party/"
  33. if ! top_make; then
  34. exit 1
  35. fi
  36. cd "${CI_BUILD_DIR}"
  37. }
  38. build_nvim() {
  39. check_core_dumps --delete quiet
  40. if test -n "${CLANG_SANITIZER}" ; then
  41. CMAKE_FLAGS="${CMAKE_FLAGS} -DCLANG_${CLANG_SANITIZER}=ON"
  42. fi
  43. mkdir -p "${BUILD_DIR}"
  44. cd "${BUILD_DIR}"
  45. echo "Configuring with '${CMAKE_FLAGS} $@'."
  46. cmake -G Ninja ${CMAKE_FLAGS} "$@" "${CI_BUILD_DIR}"
  47. echo "Building nvim."
  48. if ! top_make nvim ; then
  49. exit 1
  50. fi
  51. if test "$CLANG_SANITIZER" != "TSAN" ; then
  52. echo "Building libnvim."
  53. if ! top_make libnvim ; then
  54. exit 1
  55. fi
  56. if test "${FUNCTIONALTEST}" != "functionaltest-lua"; then
  57. echo "Building nvim-test."
  58. if ! top_make nvim-test ; then
  59. exit 1
  60. fi
  61. fi
  62. fi
  63. # Invoke nvim to trigger *San early.
  64. if ! (bin/nvim --version && bin/nvim -u NONE -e -cq | cat -vet) ; then
  65. check_sanitizer "${LOG_DIR}"
  66. exit 1
  67. fi
  68. check_sanitizer "${LOG_DIR}"
  69. cd "${CI_BUILD_DIR}"
  70. }