2
0

xmake.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("libargon2")
  2. set_homepage("https://github.com/P-H-C/phc-winner-argon2")
  3. set_description("The password hash Argon2, winner of PHC")
  4. add_urls("https://github.com/P-H-C/phc-winner-argon2/archive/refs/tags/$(version).zip",
  5. "https://github.com/P-H-C/phc-winner-argon2.git")
  6. add_versions("20190702", "506a80b90ac3ca8407636f3b26b7fed87a55f2f1275cde850cd6698903c4f008")
  7. if is_plat("linux") then
  8. add_syslinks("pthread")
  9. end
  10. on_install("windows", "macosx", "linux", "mingw", function (package)
  11. if not package:config("shared") then
  12. io.replace("include/argon2.h", "__declspec(dllexport)", "", {plain = true})
  13. end
  14. io.writefile("xmake.lua", [[
  15. add_rules("mode.debug", "mode.release")
  16. target("argon2")
  17. set_kind("$(kind)")
  18. add_files("src/core.c", "src/argon2.c", "src/thread.c", "src/encoding.c", "src/blake2/blake2b.c", "src/opt.c")
  19. add_includedirs("include", "src")
  20. add_headerfiles("include/argon2.h")
  21. if not is_plat("windows") then
  22. add_defines("A2_VISCTL")
  23. add_cflags("-march=native")
  24. end
  25. if is_plat("linux") then
  26. add_syslinks("pthread")
  27. end
  28. ]])
  29. import("package.tools.xmake").install(package)
  30. if package:config("shared") then
  31. io.replace(path.join(package:installdir("include"), "argon2.h"), "__declspec(dllexport)", "__declspec(dllimport)", {plain = true})
  32. end
  33. end)
  34. on_test(function (package)
  35. assert(package:has_cfuncs("argon2_error_message", {includes = "argon2.h"}))
  36. end)