From 98577d7c0528f9d6a9be8e05e54ca3edac184f34 Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Fri, 5 Jul 2024 03:12:00 +0100 Subject: [PATCH] libtomcrypt: add package (#4576) * libtomcrypt: add package * libtommath: fix test * libtommath: fix test again * libtommath: fix moving files * libtomcrypt: add limits * Update xmake.lua --------- Co-authored-by: ruki --- packages/l/libtomcrypt/xmake.lua | 33 ++++++++++++++++++++++++++++++++ packages/l/libtommath/xmake.lua | 4 ++++ 2 files changed, 37 insertions(+) create mode 100644 packages/l/libtomcrypt/xmake.lua diff --git a/packages/l/libtomcrypt/xmake.lua b/packages/l/libtomcrypt/xmake.lua new file mode 100644 index 000000000..62306ff9c --- /dev/null +++ b/packages/l/libtomcrypt/xmake.lua @@ -0,0 +1,33 @@ +package("libtomcrypt") + set_homepage("https://www.libtom.net") + set_description("A fairly comprehensive, modular and portable cryptographic toolkit.") + set_license("Unlicense") + + add_urls("https://github.com/libtom/libtomcrypt.git") + + add_versions("2024.06.26", "2302a3a89752b317d59e9cdb67d2d4eb9b53be8e") + + add_deps("libtommath", "cmake") + + on_install("!wasm and (macosx|!x86_64 or !macosx)", function (package) + local configs = {} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + if package:is_plat("windows") and package:config("shared") then + table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") + end + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + void test() { + unsigned char input[] = "hello"; + unsigned long input_len = 5; + char out[256]; + unsigned long out_len; + base64_encode(input, input_len, out, &out_len); + } + ]]}, {configs = {languages = "cxx11"}})) + end) diff --git a/packages/l/libtommath/xmake.lua b/packages/l/libtommath/xmake.lua index abc16e8c7..11d9ad0e4 100644 --- a/packages/l/libtommath/xmake.lua +++ b/packages/l/libtommath/xmake.lua @@ -19,6 +19,8 @@ package("libtommath") add_deps("cmake") + add_includedirs("include", "include/libtommath") + on_install(function (package) local configs = {} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) @@ -28,8 +30,10 @@ package("libtommath") table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON") end import("package.tools.cmake").install(package, configs) + os.trymv(package:installdir("include/*.h"), package:installdir("include/libtommath")) end) on_test(function (package) assert(package:has_cfuncs("mp_init", {includes = "tommath.h"})) + assert(package:has_cfuncs("mp_init", {includes = "libtommath/tommath.h"})) end)