xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package("libsodium")
  2. set_homepage("https://libsodium.org")
  3. set_description("Sodium is a new, easy-to-use software library for encryption, decryption, signatures, password hashing and more.")
  4. if is_plat("windows") then
  5. set_urls("https://download.libsodium.org/libsodium/releases/libsodium-$(version)-msvc.zip",
  6. "https://github.com/jedisct1/libsodium/releases/download/$(version)-RELEASE/libsodium-$(version)-msvc.zip")
  7. add_versions("1.0.18", "c1d48d85c9361e350931ffe5067559cd7405a697c655d26955fb568d1084a5f4")
  8. elseif is_plat("linux", "macosx") then
  9. add_deps("autoconf", "automake", "libtool", "pkg-config")
  10. set_urls("https://download.libsodium.org/libsodium/releases/libsodium-$(version).tar.gz",
  11. "https://github.com/jedisct1/libsodium/releases/download/$(version)-RELEASE/libsodium-$(version).tar.gz")
  12. add_versions("1.0.18", "6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1")
  13. elseif is_plat("mingw") then
  14. set_urls("https://download.libsodium.org/libsodium/releases/libsodium-$(version)-mingw.tar.gz",
  15. "https://github.com/jedisct1/libsodium/releases/download/$(version)-RELEASE/libsodium-$(version)-mingw.tar.gz")
  16. add_versions("1.0.18", "e499c65b1c511cbc6700e436deb3771c3baa737981114c9e9f85f2ec90176861")
  17. end
  18. on_load(function (package)
  19. if not package:config("shared") then
  20. package:add("defines", "SODIUM_STATIC")
  21. end
  22. end)
  23. on_install("windows", function (package)
  24. os.cp("include", package:installdir())
  25. os.cp(path.join((package:is_arch("x64") and "x64" or "Win32"), (package:debug() and "Debug" or "Release"), "v142", (package:config("shared") and "dynamic" or "static"), "*"), package:installdir("lib"))
  26. end)
  27. on_install("mingw", function (package)
  28. local root_dir = (package:is_arch("x86_64") and "libsodium-win64" or "libsodium-win32")
  29. os.cp(path.join(root_dir, "include"), package:installdir())
  30. if package:config("shared") then
  31. os.cp(path.join(root_dir, "lib", "libsodium.dll.a"), package:installdir("lib"))
  32. os.cp(path.join(root_dir, "bin", "*"), package:installdir("lib"))
  33. else
  34. os.cp(path.join(root_dir, "lib", "libsodium.a"), package:installdir("lib"))
  35. end
  36. end)
  37. on_install("linux", "macosx", function (package)
  38. import("package.tools.autoconf").install(package)
  39. end)
  40. on_test(function (package)
  41. assert(package:check_cxxsnippets({test = [[
  42. int test(int args, char** argv) {
  43. if (sodium_init() < 0) {
  44. return -1;
  45. }
  46. return 0;
  47. }
  48. ]]}, {includes = "sodium.h"}))
  49. end)