compile-on-windows.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/bash
  2. REPO_ROOT="$(dirname "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd -P)")")"
  3. CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}"
  4. # shellcheck source=./win-build-dir.sh
  5. . "${REPO_ROOT}/packaging/windows/win-build-dir.sh"
  6. set -eu -o pipefail
  7. if [ -d "${build}" ]; then
  8. rm -rf "${build}"
  9. fi
  10. generator="Unix Makefiles"
  11. build_args="-j $(nproc)"
  12. if command -v ninja >/dev/null 2>&1; then
  13. generator="Ninja"
  14. build_args="-k 1"
  15. fi
  16. COMMON_CFLAGS="-Wa,-mbig-obj -pipe -D_FILE_OFFSET_BITS=64 -D__USE_MINGW_ANSI_STDIO=1"
  17. if [ "${CMAKE_BUILD_TYPE}" = "Debug" ]; then
  18. BUILD_CFLAGS="-fstack-protector-all -O0 -ggdb -Wall -Wextra -Wno-char-subscripts -DNETDATA_INTERNAL_CHECKS=1 ${COMMON_CFLAGS} ${CFLAGS:-}"
  19. else
  20. BUILD_CFLAGS="-O2 ${COMMON_CFLAGS} ${CFLAGS:-}"
  21. fi
  22. ${GITHUB_ACTIONS+echo "::group::Configuring"}
  23. # shellcheck disable=SC2086
  24. CFLAGS="${BUILD_CFLAGS}" /usr/bin/cmake \
  25. -S "${REPO_ROOT}" \
  26. -B "${build}" \
  27. -G "${generator}" \
  28. -DCMAKE_INSTALL_PREFIX="/opt/netdata" \
  29. -DBUILD_FOR_PACKAGING=On \
  30. -DNETDATA_USER="${USER}" \
  31. -DENABLE_ACLK=On \
  32. -DENABLE_CLOUD=On \
  33. -DENABLE_H2O=Off \
  34. -DENABLE_ML=On \
  35. -DENABLE_PLUGIN_GO=On \
  36. -DENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE=Off \
  37. -DENABLE_BUNDLED_JSONC=On \
  38. -DENABLE_BUNDLED_PROTOBUF=Off \
  39. ${EXTRA_CMAKE_OPTIONS:-}
  40. ${GITHUB_ACTIONS+echo "::endgroup::"}
  41. ${GITHUB_ACTIONS+echo "::group::Building"}
  42. # shellcheck disable=SC2086
  43. cmake --build "${build}" -- ${build_args}
  44. ${GITHUB_ACTIONS+echo "::endgroup::"}
  45. if [ -t 1 ]; then
  46. echo
  47. echo "Compile with:"
  48. echo "cmake --build \"${build}\""
  49. fi