compile-and-run-windows.sh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  2. # On MSYS2, install these dependencies to build netdata:
  3. install_dependencies() {
  4. pacman -S \
  5. git cmake ninja clang base-devel msys2-devel \
  6. libyaml-devel libzstd-devel libutil-linux libutil-linux-devel \
  7. mingw-w64-x86_64-toolchain mingw-w64-ucrt-x86_64-toolchain \
  8. mingw64/mingw-w64-x86_64-mold ucrt64/mingw-w64-ucrt-x86_64-mold \
  9. msys/gdb ucrt64/mingw-w64-ucrt-x86_64-gdb mingw64/mingw-w64-x86_64-gdb \
  10. msys/zlib-devel mingw64/mingw-w64-x86_64-zlib ucrt64/mingw-w64-ucrt-x86_64-zlib \
  11. msys/libuv-devel ucrt64/mingw-w64-ucrt-x86_64-libuv mingw64/mingw-w64-x86_64-libuv \
  12. liblz4-devel mingw64/mingw-w64-x86_64-lz4 ucrt64/mingw-w64-ucrt-x86_64-lz4 \
  13. openssl-devel mingw64/mingw-w64-x86_64-openssl ucrt64/mingw-w64-ucrt-x86_64-openssl \
  14. protobuf-devel mingw64/mingw-w64-x86_64-protobuf ucrt64/mingw-w64-ucrt-x86_64-protobuf \
  15. msys/pcre2-devel mingw64/mingw-w64-x86_64-pcre2 ucrt64/mingw-w64-ucrt-x86_64-pcre2 \
  16. msys/brotli-devel mingw64/mingw-w64-x86_64-brotli ucrt64/mingw-w64-ucrt-x86_64-brotli \
  17. msys/ccache ucrt64/mingw-w64-ucrt-x86_64-ccache mingw64/mingw-w64-x86_64-ccache \
  18. mingw64/mingw-w64-x86_64-go ucrt64/mingw-w64-ucrt-x86_64-go \
  19. mingw64/mingw-w64-x86_64-nsis \
  20. msys/libcurl msys/libcurl-devel
  21. }
  22. if [ "${1}" = "install" ]
  23. then
  24. install_dependencies || exit 1
  25. exit 0
  26. fi
  27. BUILD_FOR_PACKAGING="Off"
  28. if [ "${1}" = "package" ]
  29. then
  30. BUILD_FOR_PACKAGING="On"
  31. fi
  32. export PATH="/usr/local/bin:${PATH}"
  33. WT_ROOT="$(pwd)"
  34. BUILD_TYPE="Debug"
  35. NULL=""
  36. if [ -z "${MSYSTEM}" ]; then
  37. build="${WT_ROOT}/build-${OSTYPE}"
  38. else
  39. build="${WT_ROOT}/build-${OSTYPE}-${MSYSTEM}"
  40. fi
  41. if [ "$USER" = "vk" ]; then
  42. build="${WT_ROOT}/build"
  43. fi
  44. set -exu -o pipefail
  45. if [ ! -d "${build}" ]
  46. then
  47. /usr/bin/cmake -S "${WT_ROOT}" -B "${build}" \
  48. -G Ninja \
  49. -DCMAKE_INSTALL_PREFIX="/opt/netdata" \
  50. -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
  51. -DCMAKE_C_FLAGS="-fstack-protector-all -O0 -ggdb -Wall -Wextra -Wno-char-subscripts -Wa,-mbig-obj -pipe -DNETDATA_INTERNAL_CHECKS=1 -D_FILE_OFFSET_BITS=64 -D__USE_MINGW_ANSI_STDIO=1" \
  52. -DBUILD_FOR_PACKAGING=${BUILD_FOR_PACKAGING} \
  53. -DUSE_MOLD=Off \
  54. -DNETDATA_USER="${USER}" \
  55. -DDEFAULT_FEATURE_STATE=Off \
  56. -DENABLE_H2O=Off \
  57. -DENABLE_ML=On \
  58. -DENABLE_BUNDLED_JSONC=On \
  59. -DENABLE_BUNDLED_PROTOBUF=Off \
  60. -DENABLE_PLUGIN_APPS=On \
  61. ${NULL}
  62. fi
  63. ninja -v -C "${build}" || ninja -v -C "${build}" -j 1
  64. echo "Stopping service Netdata"
  65. sc stop "Netdata" || echo "Failed"
  66. ninja -v -C "${build}" install || ninja -v -C "${build}" -j 1
  67. # register the event log publisher
  68. cmd.exe //c "$(cygpath -w -a "/opt/netdata/usr/bin/wevt_netdata_install.bat")"
  69. #echo
  70. #echo "Compile with:"
  71. #echo "ninja -v -C \"${build}\" install || ninja -v -C \"${build}\" -j 1"
  72. echo "starting netdata..."
  73. # enable JIT debug with gdb
  74. export MSYS="error_start:$(cygpath -w /usr/bin/gdb)"
  75. rm -rf /opt/netdata/var/log/netdata/*.log || echo
  76. /opt/netdata/usr/bin/netdata -D