xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package("libplist")
  2. set_homepage("https://www.libimobiledevice.org/")
  3. set_description("Library for Apple Binary- and XML-Property Lists")
  4. set_license("LGPL-2.1")
  5. set_urls("https://github.com/libimobiledevice/libplist/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libimobiledevice/libplist.git")
  7. add_versions("2.6.0", "e6491c2fa3370e556ac41b8705dd7f8f0e772c8f78641c3878cabd45bd84d950")
  8. add_versions("2.2.0", "7e654bdd5d8b96f03240227ed09057377f06ebad08e1c37d0cfa2abe6ba0cee2")
  9. if is_plat("wasm") then
  10. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  11. end
  12. if is_plat("linux", "bsd") then
  13. add_syslinks("pthread")
  14. end
  15. if on_check then
  16. on_check(function (package)
  17. if package:is_plat("windows") and package:has_tool("cxx", "cl") then
  18. raise("package(libplist) unsupported msvc toolchain now, you can use clang toolchain\nadd_requires(\"libplist\", {configs = {toolchains = \"clang-cl\"}}))")
  19. end
  20. end)
  21. end
  22. on_load(function (package)
  23. if not (is_subhost("windows") or package:is_plat("windows", "android", "wasm")) then
  24. package:add("deps", "autotools")
  25. end
  26. if not package:config("shared") then
  27. package:add("defines", "LIBPLIST_STATIC")
  28. end
  29. end)
  30. on_install(function (package)
  31. local version = package:version()
  32. if is_subhost("windows") or package:is_plat("windows", "android", "wasm") then
  33. local configs = {}
  34. if version then
  35. configs.version = version
  36. end
  37. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  38. import("package.tools.xmake").install(package, configs)
  39. else
  40. if version and version:eq("2.2.0") then
  41. io.replace("src/plist.c", "void thread_once", "static void thread_once")
  42. end
  43. local configs = {
  44. "--disable-dependency-tracking",
  45. "--disable-silent-rules",
  46. "--without-cython",
  47. }
  48. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  49. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  50. if version then
  51. table.insert(configs, "PACKAGE_VERSION=" .. version)
  52. end
  53. import("package.tools.autoconf").install(package, configs)
  54. end
  55. end)
  56. on_test(function (package)
  57. assert(package:has_cfuncs("plist_new_dict", {includes = "plist/plist.h"}))
  58. end)