From 8ce8247af322511cf2e967314327cce206313df8 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 25 Nov 2022 17:12:09 +0800 Subject: [PATCH] add concurrencpp (#1657) * add concurrencpp * Update xmake.lua --- packages/c/concurrencpp/xmake.lua | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 packages/c/concurrencpp/xmake.lua diff --git a/packages/c/concurrencpp/xmake.lua b/packages/c/concurrencpp/xmake.lua new file mode 100644 index 000000000..978c0e4a8 --- /dev/null +++ b/packages/c/concurrencpp/xmake.lua @@ -0,0 +1,44 @@ +package("concurrencpp") + set_homepage("https://github.com/David-Haim/concurrencpp") + set_description("Modern concurrency for C++. Tasks, executors, timers and C++20 coroutines to rule them all") + set_license("MIT") + + add_urls("https://github.com/David-Haim/concurrencpp/archive/refs/tags/$(version).tar.gz", {version = function (version) + return "v." .. version + end}) + add_urls("https://github.com/David-Haim/concurrencpp.git") + add_versions("0.1.5", "330150ebe11b3d30ffcb3efdecc184a34cf50a6bd43b68e294a496225d286651") + + add_deps("cmake") + + if is_plat("windows") then + add_syslinks("synchronization", "ws2_32", "mswsock") + elseif is_plat("linux", "bsd") then + add_syslinks("pthread") + end + + on_load(function (package) + package:add("includedirs", "include/concurrencpp-" .. package:version_str()) + end) + + on_install("macosx", "windows", function (package) + assert(package:has_tool("cxx", "clang", "cl"), "compiler not supported!") + local configs = {} + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) + table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include "concurrencpp/concurrencpp.h" + #include + void test() { + concurrencpp::runtime runtime; + auto result = runtime.thread_executor()->submit([] { + std::cout << "hello world" << std::endl; + }); + result.get(); + } + ]]}, {configs = {languages = "c++20"}})) + end)