xmake.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package("7z")
  2. set_kind("binary")
  3. set_homepage("https://www.7-zip.org/")
  4. set_description("A file archiver with a high compression ratio.")
  5. if is_host("windows") then
  6. if is_arch("x64", "x86_64") then
  7. set_urls("https://github.com/xmake-mirror/7zip/releases/download/$(version)/7z$(version)-x64.zip",
  8. "https://gitlab.com/xmake-mirror/7zip-releases/raw/master/7z$(version)-x64.zip")
  9. add_versions("19.00", "fc21cf510d70a69bfa8e5b0449fe0a054fb76e2f8bd568364821f319c8b1d86d")
  10. add_versions("18.05", "e6e2d21e2c482f1b1c5a6d21ed80800ce1273b902cf4b9afa68621545540ee2f")
  11. else
  12. set_urls("https://github.com/xmake-mirror/7zip/releases/download/$(version)/7z$(version)-x86.zip",
  13. "https://gitlab.com/xmake-mirror/7zip-releases/raw/master/7z$(version)-x86.zip")
  14. add_versions("19.00", "f84fab081a2d8a6b5868a2eaf01cd56017363fb24560259cea80567f8062334f")
  15. add_versions("18.05", "544c37bebee30437aba405071484e0ac6310332b4bdabe4ca7420a800d4b4b5e")
  16. end
  17. else
  18. set_urls("https://github.com/xmake-mirror/7zip/archive/refs/tags/$(version).tar.gz",
  19. "https://github.com/xmake-mirror/7zip.git")
  20. add_versions("21.02", "b2a4c5bec8207508b26f94507f62f5a79c57ae9ab77dbf393f3b2fc8eef2e382")
  21. add_patches("21.02", path.join(os.scriptdir(), "patches", "21.02", "backport-21.03-fix-for-GCC-10.patch"), "f1d8fa0bbb25123b28e9b2842da07604238b77e51b918260a369f97c2f694c89")
  22. end
  23. on_install("macosx", "linux", function (package)
  24. -- Clang has some indentation warnings that fails compilation using -Werror, remove it
  25. io.replace("CPP/7zip/7zip_gcc.mak", "CFLAGS_WARN_WALL = -Wall -Werror -Wextra", "CFLAGS_WARN_WALL = -Wall -Wextra", {plain = true})
  26. os.cd("CPP/7zip/Bundles/Alone2")
  27. os.vrun("make -j -f makefile.gcc")
  28. local bin = package:installdir("bin")
  29. os.cp("_o/7zz", bin)
  30. os.ln(bin .. "/7zz", bin .. "/7z")
  31. end)
  32. on_install("windows", function (package)
  33. os.cp("*", package:installdir("bin"))
  34. --[[
  35. Build code for windows
  36. local archdir = package:is_arch("x64", "x86_64") and "x64" or "x86"
  37. os.cd("CPP/7zip/Bundles/Alone2")
  38. local configs = {"-f", "makefile"}
  39. table.insert(configs, "PLATFORM=" .. archdir)
  40. import("package.tools.nmake").build(package, configs)
  41. local bin = package:installdir("bin")
  42. os.cp(archdir .. "/7zz.exe", bin .. "/7z.exe")
  43. ]]
  44. end)
  45. on_test(function (package)
  46. os.vrun("7z --help")
  47. end)