xmake.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package("libb2")
  2. set_homepage("https://blake2.net")
  3. set_description("C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp")
  4. set_license("CC0-1.0")
  5. add_urls("https://github.com/BLAKE2/libb2/archive/643decfbf8ae600c3387686754d74c84144950d1.tar.gz",
  6. "https://github.com/BLAKE2/libb2.git")
  7. add_versions("v0.98.1", "9eb776149c41a34619e801adeae8056ca68faadc7cea3a68a54b2a4d93ef1937")
  8. add_configs("openmp", {description = "Enable Openmp", default = false, type = "boolean"})
  9. add_configs("sse", {description = "Enable SSE", default = false, type = "boolean"})
  10. if is_plat("linux", "bsd") then
  11. add_syslinks("m")
  12. end
  13. on_load(function (package)
  14. if package:config("openmp") then
  15. package:add("deps", "openmp")
  16. end
  17. end)
  18. on_install(function (package)
  19. if package:config("shared") then
  20. package:add("defines", "BLAKE2_DLL")
  21. end
  22. local configs = {
  23. openmp = package:config("openmp"),
  24. sse = package:config("sse"),
  25. }
  26. io.writefile("src/config.h")
  27. io.replace("src/blake2-impl.h",
  28. "#define BLAKE2_IMPL_NAME(fun) BLAKE2_IMPL_EVAL(fun, SUFFIX)",
  29. "#define BLAKE2_IMPL_NAME", {plain = true})
  30. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  31. import("package.tools.xmake").install(package, configs)
  32. end)
  33. on_test(function (package)
  34. assert(package:has_cfuncs("blake2", {includes = "blake2.h"}))
  35. end)