From fbadad8547d4aa02c6891de7d43abbd6cdf2bf60 Mon Sep 17 00:00:00 2001 From: Runge <50059102+RungeCC@users.noreply.github.com> Date: Sun, 23 Jun 2024 14:00:22 +0800 Subject: [PATCH] Add header only package `matchit` (#4441) * [add] headeronly package matchit * [fmt] format matchit/xmake.lua; adopt 4 spaces indentation * [fix]: the followings: - fix incorrect sha256 of v1.0.1 - fix failure due to try to download trunk version through release * [fmt] reformat matchit/xmake.lua * [fix]: address reviewer's suggestions - remove trunk version - install through cmake * Update xmake.lua --------- Co-authored-by: star9029 --- packages/m/matchit/xmake.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/m/matchit/xmake.lua diff --git a/packages/m/matchit/xmake.lua b/packages/m/matchit/xmake.lua new file mode 100644 index 000000000..db4637aa4 --- /dev/null +++ b/packages/m/matchit/xmake.lua @@ -0,0 +1,31 @@ +package("matchit") + set_kind("library", {headeronly = true}) + set_homepage("https://bowenfu.github.io/matchit.cpp/") + set_description("A lightweight single-header pattern-matching library for C++17 with macro-free APIs.") + set_license("Apache-2.0") + + add_urls("https://github.com/BowenFu/matchit.cpp/archive/refs/tags/$(version).tar.gz", + "https://github.com/BowenFu/matchit.cpp.git") + + add_versions("v1.0.1", "2860cb85febf37220f75cef5b499148bafc9f5541fe1298e11b0c169bb3f31ac") + + add_deps("cmake") + + on_install(function (package) + import("package.tools.cmake").install(package, {"-DBUILD_TESTING=OFF"}) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + constexpr int32_t gcd(int32_t a, int32_t b) { + using namespace matchit; + return match(a, b)( + pattern | ds(_, 0) = [&] { return a >= 0 ? a : -a; }, + pattern | _ = [&] { return gcd(b, a%b); } + ); + } + void test() { + static_assert(gcd(12, 6) == 6); + } + ]]}, {configs = {languages = "c++17"}, includes = "matchit.h"})) + end)