xmake.lua 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package("trantor")
  2. set_homepage("https://github.com/an-tao/trantor/")
  3. set_description("a non-blocking I/O tcp network lib based on c++14/17")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/an-tao/trantor/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/an-tao/trantor.git")
  7. add_versions("v1.3.0", "524589dc9258e1ace3b2f887b835cfbeccab3c5efc4ba94963c59f3528248d9b")
  8. add_versions("v1.4.1", "aa3f4dddfd3fd1a6e04f79744e69f23bb6472c314724eaa3051872a2a03bbda9")
  9. add_versions("v1.5.0", "8704df75b783089d7e5361174054e0e46a09cc315b851dbc2ab6736e631b090b")
  10. add_versions("v1.5.2", "6ccd781b3a2703b94689d7da579a38a78bc5c89616cce18ec27fcb6bc0b1620f")
  11. add_deps("cmake")
  12. add_deps("openssl", "c-ares", {optional = true})
  13. if is_plat("windows") or is_plat("mingw") then
  14. add_syslinks("ws2_32")
  15. elseif is_plat("linux") then
  16. add_syslinks("pthread")
  17. end
  18. on_install("windows", "macosx", "linux", "mingw@windows", function (package)
  19. local configs = {}
  20. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  21. if package:config("pic") ~= false then
  22. table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
  23. end
  24. import("package.tools.cmake").install(package, configs)
  25. end)
  26. on_test(function (package)
  27. assert(package:check_cxxsnippets({test = [[
  28. #include <thread>
  29. #include <chrono>
  30. using namespace std::chrono_literals;
  31. void test() {
  32. trantor::SerialTaskQueue queue("");
  33. queue.runTaskInQueue([&]() {
  34. for (int i = 0; i < 5; ++i)
  35. std::this_thread::sleep_for(0.1s);
  36. });
  37. queue.waitAllTasksFinished();
  38. }
  39. ]]}, {configs = {languages = "c++17"}, includes = "trantor/utils/SerialTaskQueue.h"}))
  40. end)