xmake.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package("zstd")
  2. set_homepage("https://www.zstd.net/")
  3. set_description("Zstandard - Fast real-time compression algorithm")
  4. set_license("BSD-3-Clause")
  5. set_urls("https://github.com/facebook/zstd/archive/$(version).tar.gz",
  6. "https://github.com/facebook/zstd.git")
  7. add_versions("v1.4.5", "734d1f565c42f691f8420c8d06783ad818060fc390dee43ae0a89f86d0a4f8c2")
  8. add_versions("v1.5.0", "0d9ade222c64e912d6957b11c923e214e2e010a18f39bec102f572e693ba2867")
  9. add_versions("v1.5.2", "f7de13462f7a82c29ab865820149e778cbfe01087b3a55b5332707abf9db4a6e")
  10. add_versions("v1.5.5", "98e9c3d949d1b924e28e01eccb7deed865eefebf25c2f21c702e5cd5b63b85e1")
  11. on_load("windows", function (package)
  12. if package:config("shared") then
  13. package:add("defines", "ZSTD_DLL_IMPORT=1")
  14. end
  15. end)
  16. on_install(function (package)
  17. io.writefile("xmake.lua", ([[
  18. set_version("%s")
  19. add_rules("mode.debug", "mode.release", "asm")
  20. add_rules("utils.install.pkgconfig_importfiles", {filename = "libzstd.pc"})
  21. target("zstd")
  22. set_kind("$(kind)")
  23. add_files("lib/common/*.c")
  24. add_files("lib/compress/*.c")
  25. add_files("lib/decompress/*.c")
  26. add_files("lib/dictBuilder/*.c")
  27. add_headerfiles("lib/*.h")
  28. add_defines("XXH_NAMESPACE=ZSTD_")
  29. if is_kind("shared") and is_plat("windows") then
  30. add_defines("ZSTD_DLL_EXPORT=1")
  31. end
  32. on_config(function (target)
  33. if target:is_arch("x64", "x86_64") and target:has_tool("cc", "clang", "gcc") then
  34. target:add("files", "lib/decompress/*.S")
  35. else
  36. target:add("defines", "ZSTD_DISABLE_ASM")
  37. end
  38. end)
  39. ]]):format(package:version_str()))
  40. import("package.tools.xmake").install(package)
  41. end)
  42. on_test(function (package)
  43. assert(package:has_cfuncs("ZSTD_compress", {includes = {"zstd.h"}}))
  44. assert(package:has_cfuncs("ZSTD_decompress", {includes = {"zstd.h"}}))
  45. end)