From 5a822acd3a4590648fa28d9ccd699b41a4c202ba Mon Sep 17 00:00:00 2001 From: star9029 Date: Thu, 7 Nov 2024 12:23:18 +0800 Subject: [PATCH] microsoft-kuku: add package --- packages/m/microsoft-kuku/xmake.lua | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 packages/m/microsoft-kuku/xmake.lua diff --git a/packages/m/microsoft-kuku/xmake.lua b/packages/m/microsoft-kuku/xmake.lua new file mode 100644 index 00000000000..10d275b66c4 --- /dev/null +++ b/packages/m/microsoft-kuku/xmake.lua @@ -0,0 +1,57 @@ +package("microsoft-kuku") + set_homepage("https://github.com/microsoft/Kuku") + set_description("Kuku is a compact and convenient cuckoo hashing library written in C++.") + set_license("MIT") + + add_urls("https://github.com/microsoft/Kuku/archive/refs/tags/$(version).tar.gz", + "https://github.com/microsoft/Kuku.git") + + add_versions("v2.1.0", "96ed5fad82ea8c8a8bb82f6eaf0b5dce744c0c2566b4baa11d8f5443ad1f83b7") + + add_configs("c_api", {description = "Builds C API", default = false, type = "boolean"}) + if is_plat("windows") then + add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true}) + end + + add_deps("cmake") + + on_load(function (package) + local version = package:version() + if version then + package:add("includedirs", format("include/Kuku-%s.%s", version:major(), version:minor())) + else + package:add("includedirs", "include/Kuku-2.1") + end + + if package:config("c_api") then + package:add("links", "kukuc", format("kuku-%s.%s", version:major(), version:minor())) + end + end) + + on_install(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")) + table.insert(configs, "-DKUKU_BUILD_KUKU_C=" .. (package:config("c_api") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + using namespace kuku; + void test(int argc, char *argv[]) { + auto table_size = static_cast(atoi(argv[1])); + auto stash_size = static_cast(atoi(argv[2])); + uint8_t loc_func_count = static_cast(atoi(argv[3])); + item_type loc_func_seed = make_random_item(); + uint64_t max_probe = static_cast(atoi(argv[4])); + item_type empty_item = make_item(0, 0); + + KukuTable table(table_size, stash_size, loc_func_count, loc_func_seed, max_probe, empty_item); + } + ]]}, {configs = {languages = "c++14"}, includes = {"kuku/kuku.h"}})) + + if package:config("c_api") then + assert(package:has_cxxfuncs("KukuTable_Insert", {includes = "kuku/c/kuku_ref.h"})) + end + end)