From 7fed3ebea298d495823cec3abb680fa220229cfe Mon Sep 17 00:00:00 2001 From: star9029 Date: Sat, 25 Nov 2023 23:32:18 +0800 Subject: [PATCH] zpp_throwing: add package (#2875) --- packages/z/zpp_throwing/xmake.lua | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 packages/z/zpp_throwing/xmake.lua diff --git a/packages/z/zpp_throwing/xmake.lua b/packages/z/zpp_throwing/xmake.lua new file mode 100644 index 000000000..10c75b4b3 --- /dev/null +++ b/packages/z/zpp_throwing/xmake.lua @@ -0,0 +1,32 @@ +package("zpp_throwing") + set_kind("library", {headeronly = true}) + set_homepage("https://github.com/eyalz800/zpp_throwing") + set_description("Using coroutines to implement C++ exceptions for freestanding environments") + set_license("MIT") + + add_urls("https://github.com/eyalz800/zpp_throwing/archive/refs/tags/$(version).tar.gz", + "https://github.com/eyalz800/zpp_throwing.git") + + add_versions("v1.0.1", "c15651ad36f9ddcb51e6244b0a78dbdebf7be8748b3e7ffe1c7339f0e41fd411") + + on_install("linux", "macosx", "bsd", "mingw", "msys", "android", "iphoneos", "cross", "wasm", function (package) + os.cp("zpp_throwing.h", package:installdir("include")) + end) + + on_test(function (package) + local cxxflags + if package:is_plat("windows") then + cxxflags = {"/EHsc-", "/GR-"} + else + cxxflags = {"-fno-exceptions", "-fno-rtti"} + end + assert(package:check_cxxsnippets({test = [[ + #include + zpp::throwing test(bool success) { + if (!success) { + co_yield std::runtime_error("My runtime error"); + } + co_return 1337; + } + ]]}, {configs = {languages = "c++20", cxxflags = cxxflags}})) + end)