xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_load("!linux and !macosx", function (package)
  15. package:set("kind", "library", {headeronly = true})
  16. end)
  17. on_install(function (package)
  18. if package:is_plat("linux") and package:is_arch("arm.*") then
  19. io.replace("CMakeLists.txt", [[list(APPEND CXX_FLAGS "-m]], [[#list(APPEND CXX_FLAGS "-m]], {plain = true})
  20. end
  21. if package:version():le("1.3") then
  22. io.replace("async_simple/CMakeLists.txt",
  23. [[file(GLOB coro_header "coro/*.h")]],
  24. "file(GLOB coro_header \"coro/*.h\")\nfile(GLOB executors_header \"executors/*.h\")", {plain = true})
  25. end
  26. local configs = {
  27. "-DASYNC_SIMPLE_ENABLE_TESTS=OFF",
  28. "-DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF"
  29. }
  30. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  31. table.insert(configs, "-DASYNC_SIMPLE_DISABLE_AIO=" .. (package:config("aio") and "OFF" or "ON"))
  32. table.insert(configs, "-DASYNC_SIMPLE_BUILD_MODULES=" .. (package:config("modules") and "ON" or "OFF"))
  33. import("package.tools.cmake").install(package, configs)
  34. if package:config("shared") then
  35. os.rm(package:installdir("lib/libasync_simple.a"))
  36. else
  37. os.rm(package:installdir("lib/*.so*"))
  38. end
  39. end)
  40. on_test(function (package)
  41. assert(package:check_cxxsnippets({test = [[
  42. async_simple::coro::Lazy<void> func() {
  43. co_return;
  44. }
  45. void test() {
  46. async_simple::coro::syncAwait(func());
  47. }
  48. ]]}, {configs = {languages = "c++20"}, includes = {"async_simple/coro/Lazy.h", "async_simple/coro/SyncAwait.h"}}))
  49. end)