xmake.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package("sentry-native")
  2. set_homepage("https://sentry.io")
  3. set_description("Sentry SDK for C, C++ and native applications.")
  4. set_urls("https://github.com/getsentry/sentry-native/releases/download/$(version)/sentry-native.zip",
  5. "https://github.com/getsentry/sentry-native.git")
  6. add_versions("0.4.15", "ae3ac4efa76d431d8734d7b0b1bf9bbedaf2cbdb18dfc5c95e2411a67808cf29")
  7. add_versions("0.4.4", "fe6c711d42861e66e53bfd7ee0b2b226027c64446857f0d1bbb239ca824a3d8d")
  8. add_patches("0.4.4", path.join(os.scriptdir(), "patches", "0.4.4", "zlib_fix.patch"), "1a6ac711b7824112a9062ec1716a316facce5055498d1f87090d2cad031b865b")
  9. add_deps("cmake")
  10. add_configs("backend", {description = "Set the backend of sentry to use", type = "string"})
  11. if is_plat("windows") then
  12. add_syslinks("dbghelp", "winhttp", "shlwapi", "advapi32", "version")
  13. elseif is_plat("linux") then
  14. add_deps("libcurl")
  15. add_syslinks("dl", "pthread", "rt")
  16. elseif is_plat("android") then
  17. add_syslinks("dl", "log")
  18. elseif is_plat("macosx") then
  19. add_deps("libcurl")
  20. add_frameworks("CoreText", "CoreGraphics", "SystemConfiguration", "CoreFoundation", "Foundation")
  21. add_syslinks("bsm")
  22. end
  23. on_load("windows", "linux", "macosx", function (package)
  24. if not package:config("shared") then
  25. package:add("defines", "SENTRY_BUILD_STATIC")
  26. end
  27. if package:config("backend") == "crashpad" then
  28. package:add("links", "sentry", "crashpad_client", "crashpad_util", "crashpad_minidump", "crashpad_handler_lib", "mini_chromium", "crashpad_tools", "crashpad_compat", "crashpad_snapshot")
  29. package:add("deps", "zlib")
  30. elseif package:config("backend") == "breakpad" then
  31. package:add("links", "sentry", "breakpad_client")
  32. elseif package:is_plat("linux") then -- linux defaults to breakpad
  33. package:add("links", "sentry", "breakpad_client")
  34. end
  35. end)
  36. on_install("windows", "linux", "macosx", function (package) -- TODO: to enable android you will need to figure out the order of libs
  37. local opt = {}
  38. local configs = {}
  39. table.insert(configs, "-DSENTRY_BUILD_EXAMPLES=OFF")
  40. table.insert(configs, "-DSENTRY_BUILD_TESTS=OFF")
  41. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  42. if package:config("shared") then
  43. table.insert(configs, "-DBUILD_SHARED_LIBS=ON")
  44. table.insert(configs, "-DSENTRY_BUILD_SHARED_LIBS=ON")
  45. else
  46. table.insert(configs, "-DBUILD_SHARED_LIBS=OFF")
  47. table.insert(configs, "-DSENTRY_BUILD_SHARED_LIBS=OFF")
  48. end
  49. if package:config("backend") then
  50. table.insert(configs, "-DSENTRY_BACKEND=" .. package:config("backend"))
  51. end
  52. if package:is_plat("windows") then
  53. opt.cxflags = { "/experimental:preprocessor-" } -- fixes <Windows SDK>\um\oaidl.h(487): error C2059: syntax error: '/'
  54. local vs_runtime = package:config("vs_runtime")
  55. table.insert(configs, "-DSENTRY_BUILD_RUNTIMESTATIC=" .. ((vs_runtime == "MT" or vs_runtime == "MTd") and "ON" or "OFF"))
  56. elseif package:is_plat("macosx") then
  57. opt.shflags = {"-framework", "SystemConfiguration"}
  58. end
  59. import("package.tools.cmake").install(package, configs, opt)
  60. end)
  61. on_test(function (package)
  62. assert(package:check_cxxsnippets({test = [[
  63. void test(int args, char** argv) {
  64. sentry_options_t* options = sentry_options_new();
  65. sentry_init(options);
  66. sentry_shutdown();
  67. }
  68. ]]}, {includes = {"sentry.h"}}))
  69. end)