xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("libzchunk")
  2. set_homepage("https://github.com/zchunk/zchunk")
  3. set_description("A file format designed for highly efficient deltas while maintaining good compression.")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/zchunk/zchunk/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/zchunk/zchunk.git")
  7. add_versions("1.5.2", "b7346d950fec2e0c72761f2a9148b0ece84574c49076585abf4bebd369cd4c60")
  8. add_versions("1.5.1", "2c187055e2206e62cef4559845e7c2ec6ec5a07ce1e0a6044e4342e0c5d7771d")
  9. add_patches("<=1.5.1", "patches/fix-cdecl.patch", "7ca1cbabe8516152e5d4e5cd5dc7c14b2fd0134f8ad7a8fa64159e07998ebeb4")
  10. if is_plat("wasm") then
  11. add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
  12. end
  13. add_configs("zstd", {description = "Enable compression support.", default = false, type = "boolean"})
  14. add_configs("openssl", {description = "Use openssl or bundled sha libraries.", default = false, type = "boolean"})
  15. add_deps("meson", "ninja")
  16. if not is_subhost("windows") then
  17. add_deps("pkg-config")
  18. else
  19. add_deps("pkgconf")
  20. end
  21. on_load(function(package)
  22. if not package:config("shared") then
  23. package:add("defines", "ZCHUNK_STATIC_LIB")
  24. end
  25. if package:config("zstd") then
  26. package:add("deps", "zstd")
  27. end
  28. if package:config("openssl") then
  29. package:add("deps", "openssl3")
  30. end
  31. end)
  32. -- @see https://github.com/zchunk/zchunk/issues/94
  33. on_install("!mingw and !msys and !cygwin", function (package)
  34. local configs = {
  35. '-Ddocs=false',
  36. '-Dtests=false',
  37. '-Dwith-curl=disabled'
  38. }
  39. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  40. table.insert(configs, "-Dwith-zstd=" .. (package:config("zstd") and "enabled" or "disabled"))
  41. table.insert(configs, "-Dwith-openssl=" .. (package:config("openssl") and "enabled" or "disabled"))
  42. io.replace("meson.build", "subdir('src')", "subdir('src/lib')", {plain = true})
  43. io.replace("meson.build", "not argplib.found()", "false", {plain = true})
  44. import("package.tools.meson").install(package, configs)
  45. end)
  46. on_test(function (package)
  47. assert(package:has_cfuncs("zck_create", {configs = {languages = "c99"}, includes = "zck.h"}))
  48. end)