2
0

xmake.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("miniz")
  2. set_homepage("https://github.com/richgel999/miniz/")
  3. set_description("miniz: Single C source file zlib-replacement library")
  4. set_license("MIT")
  5. add_urls("https://github.com/richgel999/miniz/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/richgel999/miniz.git")
  7. add_versions("3.0.2", "c4b4c25a4eb81883448ff8924e6dba95c800094a198dc9ce66a292ac2ef8e018")
  8. add_versions("2.2.0", "bd1136d0a1554520dcb527a239655777148d90fd2d51cf02c36540afc552e6ec")
  9. add_versions("2.1.0", "95f9b23c92219ad2670389a23a4ed5723b7329c82c3d933b7047673ecdfc1fea")
  10. add_configs("cmake", {description = "Use cmake buildsystem", default = true, type = "boolean"})
  11. add_includedirs("include", "include/miniz")
  12. on_load(function (package)
  13. local version = package:version()
  14. if version and version:lt("2.2.0") then
  15. package:config_set("cmake", false)
  16. end
  17. if package:config("cmake") then
  18. package:add("deps", "cmake")
  19. if not package:config("shared") then
  20. package:add("defines", "MINIZ_STATIC_DEFINE")
  21. end
  22. end
  23. end)
  24. on_install(function (package)
  25. if package:config("cmake") then
  26. local configs = {"-DCMAKE_POLICY_DEFAULT_CMP0057=NEW", "-DBUILD_EXAMPLES=OFF", "-DBUILD_TESTS=OFF", "-DINSTALL_PROJECT=ON"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  29. import("package.tools.cmake").install(package, configs)
  30. else
  31. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  32. import("package.tools.xmake").install(package, {ver = package:version()})
  33. end
  34. end)
  35. on_test(function (package)
  36. assert(package:has_cfuncs("mz_compress", {includes = "miniz.h"}))
  37. end)