diff --git a/packages/t/toomanycooks/port/xmake.lua b/packages/t/toomanycooks/port/xmake.lua new file mode 100644 index 00000000000..212b239da83 --- /dev/null +++ b/packages/t/toomanycooks/port/xmake.lua @@ -0,0 +1,27 @@ +add_rules("mode.debug", "mode.release") + +option("more_threads", {default = false, defines = "TMC_MORE_THREADS"}) +option("priority_count", {default = 0}) +option("hwloc", {default = false, defines = "TMC_USE_HWLOC"}) + +if has_config("hwloc") then + add_requires("hwloc") +end + +target("toomanycooks") + set_kind("$(kind)") + set_languages("cxx20") + + add_includedirs("include", {public = true}) + add_headerfiles("include/(**.hpp)") + add_files("lib.cpp") + + add_options("more_threads", "hwloc") + + if has_config("hwloc") then + add_packages("hwloc") + end + + if has_config("priority_count") and tonumber(get_config("priority_count")) ~= 0 then + add_defines("TMC_PRIORITY_COUNT=" .. get_config("priority_count")) + end diff --git a/packages/t/toomanycooks/xmake.lua b/packages/t/toomanycooks/xmake.lua new file mode 100644 index 00000000000..44bbc090700 --- /dev/null +++ b/packages/t/toomanycooks/xmake.lua @@ -0,0 +1,47 @@ +package("toomanycooks") + set_kind("library") + set_homepage("https://github.com/tzcnt/TooManyCooks/") + set_description("C++20 concurrency framework with no compromises. Excellent performance, powerful features, and simple syntax.") + set_license("BSL-1.0") + + add_urls("https://github.com/tzcnt/TooManyCooks/archive/refs/tags/v$(version).tar.gz", + "https://github.com/tzcnt/TooManyCooks.git") + + add_versions("1.4.0", "5c847cfd73231409301732f3e158c52b694a2bd90d336e90f558811d59ef7f69") + + add_configs("priority_count", {default = 0, type = "number", + description = "Allows you to specify the number of priority levels at compile time. 0 = specified at runtime"}) + add_configs("more_threads", {default = false, type = "boolean", + description = "Unlimited threads in cpu executor, otherwise fixed to 64 threads"}) + add_configs("hwloc", {default = false, type = "boolean", description = "Build with hwloc"}) + + on_load(function (package) + if package:config("hwloc") then + package:add("deps", "hwloc") + end + end) + + on_install("linux", function (package) + io.writefile("lib.cpp", [[ + #define TMC_IMPL + #include "tmc/all_headers.hpp" // IWYU pragma: keep + ]]) + + os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua") + + import("package.tools.xmake").install(package, { + kind = package:config("shared") and "shared" or "static", + more_threads = package:config("more_threads"), + priority_count = package:config("priority_count"), + hwloc = package:config("hwloc") + }) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({ test = [[ + #include + int main(int argc, char **argv) { + return tmc::async_main([]() -> tmc::task { co_return 0; }()); + } + ]]}, {configs = {languages = "c++20"}})) + end)