xmake.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package("leancrypto")
  2. set_homepage("https://leancrypto.org")
  3. set_description("Lean cryptographic library usable for bare-metal environments")
  4. add_urls("https://github.com/smuellerDD/leancrypto/archive/refs/tags/$(version).tar.gz",
  5. "https://github.com/smuellerDD/leancrypto.git")
  6. add_versions("v1.2.0", "247481cac4cedbf4b9e1c689b7726592015352a11cd22625013185d01cda2c15")
  7. if is_plat("linux") then
  8. add_extsources("pacman::leancrypto")
  9. end
  10. add_deps("meson", "ninja")
  11. on_install("linux", "cross", "mingw", "macosx", function (package)
  12. io.replace("meson.build", "cc.has_argument('-flto')", "false", {plain = true})
  13. io.replace("meson.build", "cc.has_argument('-ffat-lto-objects')", "false", {plain = true})
  14. local configs = {}
  15. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  16. import("package.tools.meson").install(package, configs)
  17. end)
  18. on_test(function (package)
  19. assert(package:check_csnippets({test = [[
  20. void test(void) {
  21. static const uint8_t msg_256[] = {0x06, 0x3A, 0x53};
  22. uint8_t act[LC_SHA256_SIZE_DIGEST];
  23. LC_SHA256_CTX_ON_STACK(sha256_stack);
  24. lc_hash_init(sha256_stack);
  25. lc_hash_update(sha256_stack, msg_256, sizeof(msg_256));
  26. lc_hash_final(sha256_stack, act);
  27. lc_hash_zero(sha256_stack);
  28. }
  29. ]]}, {includes = "leancrypto/lc_sha256.h"}))
  30. end)