xmake.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package("async_simple")
  2. set_homepage("https://github.com/alibaba/async_simple")
  3. set_description("Simple, light-weight and easy-to-use asynchronous components")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/alibaba/async_simple/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/alibaba/async_simple/archive/refs/tags/v$(version).tar.gz",
  7. "https://github.com/alibaba/async_simple.git")
  8. add_versions("1.1", "32d1ea16dfc1741206b6e4a3fbe532eeb1c378619766c1abe11a9efc53109c10")
  9. add_versions("1.2", "a59a2674ac2b0a3997b90873b2bf0fbe4d96fdedbe6a2628c16c92a65a3fa39a")
  10. add_versions("1.3", "0ba0dc3397882611b538d04b8ee6668b1a04ce046128599205184c598b718743")
  11. add_configs("aio", {description = "default not open aio", default = false, type = "boolean"})
  12. add_configs("modules", {description = "default not use modules", default = false, type = "boolean"})
  13. add_deps("cmake")
  14. on_install("windows", "linux", "macosx", function (package)
  15. if package:version():le("1.3") then
  16. io.replace("async_simple/CMakeLists.txt",
  17. [[file(GLOB coro_header "coro/*.h")]],
  18. "file(GLOB coro_header \"coro/*.h\")\nfile(GLOB executors_header \"executors/*.h\")", {plain = true})
  19. end
  20. local configs = {
  21. "-DASYNC_SIMPLE_ENABLE_TESTS=OFF",
  22. "-DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF"
  23. }
  24. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  25. table.insert(configs, "-DASYNC_SIMPLE_DISABLE_AIO=" .. (package:config("aio") and "OFF" or "ON"))
  26. table.insert(configs, "-DASYNC_SIMPLE_BUILD_MODULES=" .. (package:config("modules") and "ON" or "OFF"))
  27. import("package.tools.cmake").install(package, configs)
  28. if package:config("shared") then
  29. os.rm(package:installdir("lib/libasync_simple.a"))
  30. else
  31. os.rm(package:installdir("lib/*.so*"))
  32. end
  33. end)
  34. on_test(function (package)
  35. assert(package:check_cxxsnippets({test = [[
  36. #include <async_simple/coro/Lazy.h>
  37. async_simple::coro::Lazy<void> func() {
  38. co_return;
  39. }
  40. void test() {
  41. async_simple::coro::syncAwait(func());
  42. }
  43. ]]}, {configs = {languages = "c++20"}, includes = {"async_simple/coro/Lazy.h", "async_simple/coro/SyncAwait.h"}}))
  44. end)