xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package("snmalloc")
  2. set_homepage("https://github.com/microsoft/snmalloc")
  3. set_description("Message passing based allocator")
  4. set_license("MIT")
  5. add_urls("https://github.com/microsoft/snmalloc/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/microsoft/snmalloc.git")
  7. add_versions("0.7.0", "9e6bd04e58d981218bd5bd3a853d93bbcb1a82dd914f912670f798e011e86746")
  8. add_versions("0.6.2", "e0486ccf03eac5dd8acbb66ea8ad33bec289572a51614acdf7117397e4f1af8c")
  9. add_versions("0.6.0", "de1bfb86407d5aac9fdad88319efdd5593ca2f6c61fc13371c4f34aee0b6664f")
  10. add_configs("header_only", {description = "Use header only version.", default = false, type = "boolean"})
  11. add_configs("wait_on_address", {description = "Use wait on address backoff strategy if it is available", default = true, type = "boolean"})
  12. if is_plat("windows") then
  13. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  14. end
  15. add_deps("cmake")
  16. if is_plat("windows", "mingw") then
  17. add_syslinks("onecore")
  18. elseif is_plat("linux", "bsd") then
  19. add_syslinks("pthread")
  20. end
  21. on_load(function (package)
  22. if package:config("header_only") then
  23. package:set("kind", "library", {headeronly = true})
  24. end
  25. package:add("defines", "SNMALLOC_USE_WAIT_ON_ADDRESS=" .. (package:config("wait_on_address") and "1" or "0"))
  26. end)
  27. on_install("!wasm and !iphoneos", function (package)
  28. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  29. local configs = {"-DSNMALLOC_BUILD_TESTING=OFF"}
  30. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  31. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  32. table.insert(configs, "-DSNMALLOC_STATIC_LIBRARY=" .. (package:config("shared") and "OFF" or "ON"))
  33. table.insert(configs, "-DSNMALLOC_IPO=" .. (package:config("lto") and "ON" or "OFF"))
  34. table.insert(configs, "-DSNMALLOC_HEADER_ONLY_LIBRARY=" .. (package:config("header_only") and "ON" or "OFF"))
  35. table.insert(configs, "-DSNMALLOC_ENABLE_WAIT_ON_ADDRESS=" .. (package:config("wait_on_address") and "ON" or "OFF"))
  36. import("package.tools.cmake").install(package, configs)
  37. os.cp("src/snmalloc", package:installdir("include"))
  38. end)
  39. on_test(function (package)
  40. assert(package:has_cxxfuncs("snmalloc::DefaultPal::message(\"\")",
  41. {includes = "snmalloc/snmalloc.h", configs = {languages = "c++20", cxflags = "-mcx16"}}))
  42. end)