xmake.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("blend2d")
  2. set_homepage("https://blend2d.com")
  3. set_description("2D Vector Graphics Engine Powered by a JIT Compiler")
  4. set_license("zlib")
  5. set_urls("https://blend2d.com/download/blend2d-$(version).tar.gz",
  6. "https://github.com/blend2d/blend2d.git")
  7. add_versions("0.11.1", "f46d61b6aa477fea1a353a41f5906d4e861817ae059ed22fc6ecdd50ff859dd2")
  8. add_configs("jit", {description = "Enable JIT compiler support", default = true, type = "boolean"})
  9. add_deps("cmake")
  10. if is_plat("linux", "bsd") then
  11. add_syslinks("pthread")
  12. end
  13. on_check("windows", function (package)
  14. import("core.tool.toolchain")
  15. local msvc = toolchain.load("msvc", {plat = package:plat(), arch = package:arch()})
  16. if msvc and package:is_arch("arm.*") then
  17. local vs = msvc:config("vs")
  18. assert(vs and tonumber(vs) >= 2022, "package(blend2d/arm): need vs >= 2022")
  19. end
  20. end)
  21. on_load(function (package)
  22. if package:config("jit") then
  23. package:add("deps", "asmjit")
  24. end
  25. if not package:config("shared") then
  26. package:add("defines", "BL_STATIC")
  27. end
  28. end)
  29. on_install("!iphoneos", function (package)
  30. local configs = {}
  31. if package:config("jit") then
  32. table.insert(configs, "-DBLEND2D_EXTERNAL_ASMJIT=TRUE")
  33. table.insert(configs, "-DBLEND2D_NO_JIT=OFF")
  34. else
  35. table.insert(configs, "-DBLEND2D_NO_JIT=ON")
  36. end
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  38. table.insert(configs, "-DBLEND2D_STATIC=" .. (package:config("shared") and "FALSE" or "TRUE"))
  39. local cxflags
  40. if package:is_plat("windows") and package:is_arch("arm.*") then
  41. cxflags = "-D__ARM_NEON"
  42. end
  43. import("package.tools.cmake").install(package, configs, {cxflags = cxflags})
  44. end)
  45. on_test(function (package)
  46. assert(package:check_cxxsnippets({test = [[
  47. void test() {
  48. BLImage img(480, 480, BL_FORMAT_PRGB32);
  49. BLContext ctx(img);
  50. ctx.setCompOp(BL_COMP_OP_SRC_COPY);
  51. ctx.fillAll();
  52. }
  53. ]]}, {configs = {languages = "c++11"}, includes = "blend2d.h"}))
  54. end)