From e31fed0cea32669745662aeaf0272bb58f35a321 Mon Sep 17 00:00:00 2001 From: star9029 Date: Tue, 24 Sep 2024 00:03:27 +0800 Subject: [PATCH] gfx-timsort: add package (#5323) * timsort: add package * rename to gfx-timsort * add check * check c++20 ranges --- packages/g/gfx-timsort/xmake.lua | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 packages/g/gfx-timsort/xmake.lua diff --git a/packages/g/gfx-timsort/xmake.lua b/packages/g/gfx-timsort/xmake.lua new file mode 100644 index 00000000000..08782af4c28 --- /dev/null +++ b/packages/g/gfx-timsort/xmake.lua @@ -0,0 +1,52 @@ +package("gfx-timsort") + set_kind("library", {headeronly = true}) + set_homepage("https://github.com/timsort/cpp-TimSort") + set_description("A C++ implementation of timsort") + set_license("MIT") + + add_urls("https://github.com/timsort/cpp-TimSort/archive/refs/tags/$(version).tar.gz", + "https://github.com/timsort/cpp-TimSort.git") + + add_versions("v3.0.0", "d61b92850996305e5248d1621c8ac437c31b474f74907e223019739e2e556b1f") + + add_deps("cmake") + + if on_check then + on_check(function (package) + if package:is_plat("android") then + local ndk = package:toolchain("ndk"):config("ndkver") + assert(ndk and tonumber(ndk) > 22, "package(gfx-timsort) requires ndk version > 22") + end + + assert(package:check_cxxsnippets({test = [[ + #include + #include + void test() { + std::vector data; + auto lower = std::ranges::lower_bound(data, 0); + } + ]]}, {configs = {languages = "c++20"}}), "package(gfx-timsort) Require at least C++20.") + end) + end + + on_install(function (package) + local configs = {"-DBUILD_TESTING=OFF"} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + #include + #include + + size_t len(const std::string& str) { + return str.size(); + } + void test() { + std::vector collection; + gfx::timsort(collection, {}, &len); + } + ]]}, {configs = {languages = "c++20"}})) + end)