xmake.lua 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package("libzippp")
  2. set_homepage("https://github.com/ctabin/libzippp")
  3. set_description("C++ wrapper for libzip")
  4. local libzip_version_map = {
  5. ["7.1"] = "1.10.1"
  6. }
  7. add_urls("https://github.com/ctabin/libzippp.git")
  8. add_urls("https://github.com/ctabin/libzippp/archive/refs/tags/$(version).tar.gz", {
  9. version = function (version)
  10. local v_str = tostring(version)
  11. return format("libzippp-v%s-%s", v_str, libzip_version_map[v_str])
  12. end
  13. })
  14. add_versions("7.1", "9ded3c4b5641e65d2b3a3dd0cbc4106209ee17c17df70e5187e7171420752546")
  15. add_configs("encryption", {description = "Build with encryption enabled", default = false, type = "boolean"})
  16. add_deps("cmake")
  17. if on_check then
  18. on_check("android", function (package)
  19. if package:is_arch("armeabi-v7a") then
  20. local ndkver = package:toolchain("ndk"):config("ndkver")
  21. assert(ndkver and tonumber(ndkver) > 22, "package(libzip) require ndk version > 22")
  22. end
  23. end)
  24. end
  25. on_load(function (package)
  26. package:add("deps", "libzip v" .. libzip_version_map[package:version_str()])
  27. if package:config("encryption") then
  28. package:add("defines", "LIBZIPPP_WITH_ENCRYPTION")
  29. end
  30. end)
  31. on_install("!cross", function (package)
  32. local configs = {
  33. "-DLIBZIPPP_BUILD_TESTS=OFF",
  34. "-DLIBZIPPP_CMAKE_CONFIG_MODE=ON",
  35. "-DLIBZIPPP_GNUINSTALLDIRS=ON",
  36. }
  37. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  38. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  39. table.insert(configs, "-DLIBZIPPP_ENABLE_ENCRYPTION=" .. (package:config("encryption") and "ON" or "OFF"))
  40. import("package.tools.cmake").install(package, configs)
  41. if package:is_plat("windows") and package:is_debug() then
  42. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  43. os.trycp(path.join(package:buildir(), "libzippp.pdb"), dir)
  44. end
  45. end)
  46. on_test(function (package)
  47. assert(package:check_cxxsnippets({test = [[
  48. using namespace libzippp;
  49. void test() {
  50. ZipArchive zf("archive.zip");
  51. zf.open(ZipArchive::ReadOnly);
  52. }
  53. ]]}, {configs = {languages = "c++11"}, includes = "libzippp/libzippp.h"}))
  54. end)