xmake.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package("breakpad")
  2. set_homepage("https://chromium.googlesource.com/breakpad/breakpad")
  3. set_description("Mirror of Google Breakpad project")
  4. add_urls("https://github.com/google/breakpad/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/google/breakpad.git",
  6. "https://chromium.googlesource.com/breakpad/breakpad.git")
  7. add_versions("v2023.06.01", "81555be3595e25e8be0fe6dd34e9490beba224296e0a8a858341e7bced67674d")
  8. add_versions("v2023.01.27", "f187e8c203bd506689ce4b32596ba821e1e2f034a83b8e07c2c635db4de3cc0b")
  9. if is_plat("windows") then
  10. add_configs("shared", {description = "Build shared binaries.", default = false, type = "boolean", readonly = true})
  11. end
  12. if is_plat("mingw") and is_subhost("msys") then
  13. add_extsources("pacman::breakpad")
  14. end
  15. if is_plat("windows") then
  16. add_syslinks("wininet", "dbghelp", "imagehlp")
  17. elseif is_plat("linux") then
  18. add_deps("autoconf", "automake", "m4", "libtool", "linux-syscall-support")
  19. add_includedirs("include", "include/breakpad")
  20. add_syslinks("pthread")
  21. add_patches("v2023.06.01", path.join(os.scriptdir(), "patches", "v2023.06.01", "linux_syscall_support.patch"), "7e4c3b3e643d861155c956548a592f2a6bb54e13107cadb7cc0b0700dc1b2ae4")
  22. elseif is_plat("macosx") then
  23. add_deps("autoconf", "automake", "m4", "libtool")
  24. add_frameworks("CoreFoundation")
  25. end
  26. add_deps("libdisasm")
  27. on_install("windows|x64", "windows|x86", function (package)
  28. io.replace("src/processor/disassembler_x86.h", "third_party/", "", {plain = true})
  29. io.replace("src/processor/exploitability_win.cc", "third_party/", "", {plain = true})
  30. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  31. import("package.tools.xmake").install(package, configs)
  32. end)
  33. on_install("linux", function (package)
  34. io.replace("configure", "WARN_CXXFLAGS \" -Werror\"", "WARN_CXXFLAGS ", {plain = true})
  35. local configs = {"--disable-dependency-tracking", "CXXFLAGS=-std=gnu++17"}
  36. if package:is_debug() then
  37. table.insert(configs, "CXXFLAGS=-g")
  38. end
  39. import("package.tools.autoconf").install(package, configs, {packagedeps = "linux-syscall-support"})
  40. end)
  41. on_test(function (package)
  42. local plat
  43. local snippets
  44. if package:is_plat("windows") then
  45. plat = "windows"
  46. snippets = [[
  47. void test() {
  48. std::wstring dump_path;
  49. google_breakpad::ExceptionHandler handler(dump_path, nullptr, nullptr, nullptr, 0);
  50. }
  51. ]]
  52. elseif package:is_plat("macosx") then
  53. plat = "mac"
  54. snippets = [[
  55. void test() {
  56. std::string dump_path;
  57. google_breakpad::ExceptionHandler handler(
  58. dump_path, nullptr, nullptr, nullptr, false, nullptr);
  59. }
  60. ]]
  61. else
  62. plat = "linux"
  63. snippets = [[
  64. void test() {
  65. google_breakpad::MinidumpDescriptor descriptor("/tmp");
  66. }
  67. ]]
  68. end
  69. local header = "client/" .. plat .. "/handler/exception_handler.h"
  70. assert(package:check_cxxsnippets({test = snippets}, {configs = {languages = "c++17"}, includes = header}))
  71. end)