2
0

xmake.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.4", "6188f7a5f4211754fee758dfebf73759b74ce78c208719b5cc37d5ab4775d550")
  9. add_versions("1.1", "32d1ea16dfc1741206b6e4a3fbe532eeb1c378619766c1abe11a9efc53109c10")
  10. add_versions("1.2", "a59a2674ac2b0a3997b90873b2bf0fbe4d96fdedbe6a2628c16c92a65a3fa39a")
  11. add_versions("1.3", "0ba0dc3397882611b538d04b8ee6668b1a04ce046128599205184c598b718743")
  12. add_configs("aio", {description = "default not open aio", default = false, type = "boolean"})
  13. add_configs("modules", {description = "default not use modules", default = false, type = "boolean"})
  14. add_deps("cmake")
  15. if on_check then
  16. on_check("android", function (package)
  17. if package:version() and package:version():ge("1.4") then
  18. local ndk = package:toolchain("ndk"):config("ndkver")
  19. assert(ndk and tonumber(ndk) > 22, "package(async_simple >=1.4) require ndk version > 22")
  20. end
  21. end)
  22. end
  23. on_load("!linux and !macosx", function (package)
  24. package:set("kind", "library", {headeronly = true})
  25. end)
  26. on_install(function (package)
  27. if package:is_plat("linux") and package:is_arch("arm.*") then
  28. io.replace("CMakeLists.txt", [[list(APPEND CXX_FLAGS "-m]], [[#list(APPEND CXX_FLAGS "-m]], {plain = true})
  29. end
  30. if package:version():le("1.3") then
  31. io.replace("async_simple/CMakeLists.txt",
  32. [[file(GLOB coro_header "coro/*.h")]],
  33. "file(GLOB coro_header \"coro/*.h\")\nfile(GLOB executors_header \"executors/*.h\")", {plain = true})
  34. end
  35. local configs = {
  36. "-DASYNC_SIMPLE_ENABLE_TESTS=OFF",
  37. "-DASYNC_SIMPLE_BUILD_DEMO_EXAMPLE=OFF"
  38. }
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DASYNC_SIMPLE_DISABLE_AIO=" .. (package:config("aio") and "OFF" or "ON"))
  41. table.insert(configs, "-DASYNC_SIMPLE_BUILD_MODULES=" .. (package:config("modules") and "ON" or "OFF"))
  42. import("package.tools.cmake").install(package, configs)
  43. if package:config("shared") then
  44. os.rm(package:installdir("lib/libasync_simple.a"))
  45. else
  46. os.rm(package:installdir("lib/*.so*"))
  47. end
  48. end)
  49. on_test(function (package)
  50. assert(package:check_cxxsnippets({test = [[
  51. async_simple::coro::Lazy<void> func() {
  52. co_return;
  53. }
  54. void test() {
  55. async_simple::coro::syncAwait(func());
  56. }
  57. ]]}, {configs = {languages = "c++20"}, includes = {"async_simple/coro/Lazy.h", "async_simple/coro/SyncAwait.h"}}))
  58. end)