xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package("blake3")
  2. set_homepage("https://blake3.io/")
  3. set_description("BLAKE3 is a cryptographic hash function that is much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2; secure, unlike MD5 and SHA-1 (and secure against length extension, unlike SHA-2); highly parallelizable across any number of threads and SIMD lanes, because it's a Merkle tree on the inside; capable of verified streaming and incremental updates (Merkle tree); a PRF, MAC, KDF, and XOF, as well as a regular hash; and is a single algorithm with no variants, fast on x86-64 and also on smaller architectures.")
  4. set_license("CC0-1.0")
  5. add_urls("https://github.com/BLAKE3-team/BLAKE3/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/BLAKE3-team/BLAKE3.git")
  7. add_versions("1.5.0", "f506140bc3af41d3432a4ce18b3b83b08eaa240e94ef161eb72b2e57cdc94c69")
  8. add_versions("1.3.3", "27d2bc4ee5945ba75434859521042c949463ee7514ff17aaef328e23ef83fec0")
  9. add_versions("1.3.1", "112becf0983b5c83efff07f20b458f2dbcdbd768fd46502e7ddd831b83550109")
  10. on_install("windows|x64", "windows|x86", "linux", "macosx", "bsd", "mingw|x86_64", "android", "iphoneos", "cross", function (package)
  11. local configs = {}
  12. io.writefile("xmake.lua", [[
  13. add_rules("mode.release", "mode.debug")
  14. target("blake3")
  15. set_kind("$(kind)")
  16. add_files("c/blake3.c", "c/blake3_dispatch.c", "c/blake3_portable.c")
  17. add_headerfiles("c/blake3.h")
  18. if is_arch("x86_64", "x64") then
  19. if is_subhost("msys", "cygwin") then
  20. add_files("c/*x86-64_windows_gnu.S")
  21. elseif is_plat("windows") then
  22. add_files("c/*x86-64_windows_msvc.asm")
  23. if is_kind("shared") then
  24. add_rules("utils.symbols.export_all")
  25. end
  26. else
  27. add_files("c/*x86-64_unix.S")
  28. end
  29. elseif is_arch("x86", "i386") then
  30. add_files("c/blake3_portable.c")
  31. add_files("c/blake3_sse2.c")
  32. add_files("c/blake3_sse41.c")
  33. add_files("c/blake3_avx2.c")
  34. add_files("c/blake3_avx512.c")
  35. elseif is_arch("arm64", "arm64-v8a") then
  36. add_files("c/blake3_neon.c")
  37. add_defines("BLAKE3_USE_NEON=1")
  38. end
  39. ]])
  40. if package:config("shared") then
  41. configs.kind = "shared"
  42. end
  43. import("package.tools.xmake").install(package, configs)
  44. end)
  45. on_test(function (package)
  46. assert(package:has_cfuncs("blake3_hasher_init", {includes = "blake3.h"}))
  47. end)