xmake.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("hash-library")
  2. set_homepage("https://create.stephan-brumme.com/hash-library/")
  3. set_description("Portable C++ hashing library")
  4. set_license("zlib")
  5. add_urls("https://github.com/stbrumme/hash-library.git")
  6. add_versions("2021.09.29", "d389d18112bcf7e4786ec5e8723f3658a7f433d7")
  7. on_install(function (package)
  8. local configs = {}
  9. io.writefile("xmake.lua", [[
  10. add_rules("mode.release", "mode.debug")
  11. target("hash-library")
  12. set_kind("$(kind)")
  13. add_files("*.cpp")
  14. add_headerfiles("(*.h)")
  15. if is_plat("windows") and is_kind("shared") then
  16. add_rules("utils.symbols.export_all", {export_classes = true})
  17. end
  18. ]])
  19. if package:config("shared") then
  20. configs.kind = "shared"
  21. end
  22. for _, sourcefile in ipairs(os.files("*.cpp")) do
  23. io.replace(sourcefile, "#include <endian.h>", "", {plain = true})
  24. end
  25. import("package.tools.xmake").install(package, configs)
  26. end)
  27. on_test(function (package)
  28. assert(package:check_cxxsnippets({test = [[
  29. #include <string>
  30. #include <iostream>
  31. void test() {
  32. SHA1 sha1;
  33. std::string myHash = sha1("Hello World");
  34. std::cout << myHash << std::endl;
  35. }
  36. ]]}, {configs = {languages = "c++11"}, includes = {"sha1.h"}}))
  37. end)