xmake.lua 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.7.0", "66fa17a29270cb25ceaf189430ea38037c066652c2989b58d7ef6120b1a208d3")
  8. add_versions("2.6.0", "e6491c2fa3370e556ac41b8705dd7f8f0e772c8f78641c3878cabd45bd84d950")
  9. add_versions("2.2.0", "7e654bdd5d8b96f03240227ed09057377f06ebad08e1c37d0cfa2abe6ba0cee2")
  10. if is_plat("wasm") then
  11. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  12. end
  13. if is_plat("linux", "bsd") then
  14. add_syslinks("pthread")
  15. end
  16. if on_check then
  17. on_check(function (package)
  18. if package:is_plat("windows") and package:has_tool("cxx", "cl") then
  19. raise("package(libplist) unsupported msvc toolchain now, you can use clang toolchain\nadd_requires(\"libplist\", {configs = {toolchains = \"clang-cl\"}}))")
  20. end
  21. end)
  22. end
  23. on_load(function (package)
  24. if not (is_subhost("windows") or package:is_plat("windows", "android", "wasm")) then
  25. package:add("deps", "autotools")
  26. end
  27. if not package:config("shared") then
  28. package:add("defines", "LIBPLIST_STATIC")
  29. end
  30. end)
  31. on_install(function (package)
  32. local version = package:version()
  33. if is_subhost("windows") or package:is_plat("windows", "android", "wasm") then
  34. local configs = {}
  35. if version then
  36. configs.version = version
  37. end
  38. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  39. import("package.tools.xmake").install(package, configs)
  40. else
  41. if version and version:eq("2.2.0") then
  42. io.replace("src/plist.c", "void thread_once", "static void thread_once")
  43. end
  44. local configs = {
  45. "--disable-dependency-tracking",
  46. "--disable-silent-rules",
  47. "--without-cython",
  48. }
  49. table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
  50. table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
  51. if version then
  52. table.insert(configs, "PACKAGE_VERSION=" .. version)
  53. end
  54. import("package.tools.autoconf").install(package, configs)
  55. end
  56. end)
  57. on_test(function (package)
  58. assert(package:has_cfuncs("plist_new_dict", {includes = "plist/plist.h"}))
  59. end)