From 6a28d66d3d6caafaac871a0fc5b2cefb2ebe102f Mon Sep 17 00:00:00 2001 From: star9029 Date: Fri, 3 Nov 2023 22:24:51 +0800 Subject: [PATCH 1/2] stx: add package --- packages/s/stx/xmake.lua | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 packages/s/stx/xmake.lua diff --git a/packages/s/stx/xmake.lua b/packages/s/stx/xmake.lua new file mode 100644 index 00000000000..eb8dc4aaf79 --- /dev/null +++ b/packages/s/stx/xmake.lua @@ -0,0 +1,42 @@ +package("stx") + set_homepage("https://lamarrr.github.io/STX") + set_description("C++17 & C++ 20 error-handling and utility extensions. ") + set_license("MIT") + + add_urls("https://github.com/lamarrr/STX/archive/refs/tags/$(version).tar.gz", + "https://github.com/lamarrr/STX.git") + + add_versions("v1.0.3", "0118b76a5f2a7a60132edecc9b632d9fc82a187bc232ac1a3fd9200fdd92dc7d") + + add_configs("backtrace", {description = "Enable stack backtraces", default = false, type = "boolean"}) + add_configs("shared", {description = "Build shared binaries", default = false, type = "boolean", readonly = true}) + + if is_plat("linux", "bsd") then + add_syslinks("pthread") + end + + add_deps("cmake") + + 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, "-DSTX_ENABLE_BACKTRACE=" .. (package:config("backtrace") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + using stx::Option, stx::Some, stx::None; + auto safe_divide(double numerator, double denominator) -> Option { + if (denominator == 0.0) return None; + return Some(numerator / denominator); + } + void test() { + safe_divide(5.0, 2.0).match( + [](auto value){}, + [](){}); + } + ]]}, {configs = {languages = "c++17"}})) + end) From c387eb6b77e0723cdb32dd32b05f3bd0d8599da3 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sat, 4 Nov 2023 08:53:14 +0800 Subject: [PATCH 2/2] disable plat --- packages/s/stx/xmake.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/s/stx/xmake.lua b/packages/s/stx/xmake.lua index eb8dc4aaf79..08cab276e4f 100644 --- a/packages/s/stx/xmake.lua +++ b/packages/s/stx/xmake.lua @@ -9,6 +9,7 @@ package("stx") add_versions("v1.0.3", "0118b76a5f2a7a60132edecc9b632d9fc82a187bc232ac1a3fd9200fdd92dc7d") add_configs("backtrace", {description = "Enable stack backtraces", default = false, type = "boolean"}) + add_configs("custom_handler", {description = "Override the default panic behaviour by implementing a custom panic handler. The default behavior is to print the panic report and abort the program. (You can read the docs for more details)", default = false, type = "boolean"}) add_configs("shared", {description = "Build shared binaries", default = false, type = "boolean", readonly = true}) if is_plat("linux", "bsd") then @@ -17,11 +18,12 @@ package("stx") add_deps("cmake") - on_install(function (package) + on_install("windows", "linux", "macosx", "bsd", "mingw", "msys", "iphoneos", "cross", 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, "-DSTX_ENABLE_BACKTRACE=" .. (package:config("backtrace") and "ON" or "OFF")) + table.insert(configs, "-DSTX_CUSTOM_PANIC_HANDLER=" .. (package:config("custom_handler") and "ON" or "OFF")) import("package.tools.cmake").install(package, configs) end)