xmake.lua 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package("libunwind")
  2. set_homepage("https://www.nongnu.org/libunwind/")
  3. set_description("A portable and efficient C programming interface (API) to determine the call-chain of a program.")
  4. set_license("MIT")
  5. add_urls("https://github.com/libunwind/libunwind/releases/download/$(version).tar.gz", {version = function (version)
  6. if version:eq("v1.5") then
  7. return "v1.5/libunwind-1.5.0"
  8. else
  9. return version .. "/libunwind-" .. (version:gsub("v", ""))
  10. end
  11. end})
  12. add_urls("http://download.savannah.nongnu.org/releases/libunwind/libunwind-$(version).tar.gz", {version = function (version)
  13. return version:gsub("v", "")
  14. end})
  15. add_urls("https://github.com/libunwind/libunwind.git")
  16. add_versions("v1.8.0", "b6b3df40a0970c8f2865fb39aa2af7b5d6f12ad6c5774e266ccca4d6b8b72268")
  17. add_versions("v1.7.2", "a18a6a24307443a8ace7a8acc2ce79fbbe6826cd0edf98d6326d0225d6a5d6e6")
  18. add_versions("v1.6.2", "4a6aec666991fb45d0889c44aede8ad6eb108071c3554fcdff671f9c94794976")
  19. add_versions("v1.5", "90337653d92d4a13de590781371c604f9031cdb50520366aa1e3a91e1efb1017")
  20. add_patches("1.8.0", path.join(os.scriptdir(), "patches", "1.8.0", "fix-arm64.patch"), "5f679af80859b6a50504ec830a4d328c3cf25bef9f2107baed866b438f3818d3")
  21. add_configs("minidebuginfo", {description = "Enables support for LZMA-compressed symbol tables", default = false, type = "boolean"})
  22. add_configs("zlibdebuginfo", {description = "Enables support for ZLIB-compressed symbol tables", default = false, type = "boolean"})
  23. add_deps("autoconf")
  24. add_defines("_GNU_SOURCE=1")
  25. on_load("android", "linux", "bsd", "cross", function (package)
  26. if package:config("minidebuginfo") then
  27. package:add("deps", "lzma")
  28. end
  29. if package:config("zlibdebuginfo") then
  30. package:add("deps", "zlib")
  31. end
  32. end)
  33. on_install("android|arm64@linux,macosx", "linux", "bsd", "cross", function (package)
  34. if package:is_plat("bsd") then
  35. io.replace("src/setjmp/siglongjmp.c", "&wp[JB_MASK]", "(unw_word_t)&wp[JB_MASK]", {plain = true})
  36. end
  37. local configs = {"--enable-coredump=no", "--disable-tests"}
  38. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  39. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  40. if package:debug() then
  41. table.insert(configs, "--enable-debug")
  42. end
  43. if package:config("pic") ~= false then
  44. table.insert(configs, "--with-pic")
  45. end
  46. table.insert(configs, (package:config("minidebuginfo") and "--enable" or "--disable") .. "-minidebuginfo")
  47. table.insert(configs, (package:config("zlibdebuginfo") and "--enable" or "--disable") .. "-zlibdebuginfo")
  48. import("package.tools.autoconf").install(package, configs)
  49. end)
  50. on_test(function (package)
  51. assert(package:has_cfuncs("_Unwind_Backtrace(0, 0)", {includes = "unwind.h"}))
  52. end)