xmake.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package("handy")
  2. set_homepage("https://github.com/yedf2/handy")
  3. set_description("A simple C++11 network server framework")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/yedf2/handy/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/yedf2/handy.git")
  7. add_versions("0.2.0", "831d9e7cdf94d19fbc8438e75dc6c63fa75777ff2f83ac48df981c22e924a2d1")
  8. add_deps("cmake")
  9. if is_plat("linux") then
  10. add_syslinks("pthread")
  11. end
  12. on_install("linux", "macosx", "iphoneos", function (package)
  13. local configs = {}
  14. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  15. table.insert(configs, "-DBUILD_HANDY_SHARED_LIBRARY=" .. (package:config("shared") and "ON" or "OFF"))
  16. table.insert(configs, "-DBUILD_HANDY_STATIC_LIBRARY=" .. (package:config("shared") and "OFF" or "ON"))
  17. import("package.tools.cmake").install(package, configs)
  18. end)
  19. on_test(function (package)
  20. assert(package:check_cxxsnippets({test = [[
  21. #include <handy/handy.h>
  22. using namespace handy;
  23. void test() {
  24. EventBase base;
  25. Signal::signal(SIGINT, [&]{ base.exit(); });
  26. TcpServerPtr svr = TcpServer::startServer(&base, "", 2099);
  27. exitif(svr == NULL, "start tcp server failed");
  28. svr->onConnRead([](const TcpConnPtr& con) {
  29. con->send(con->getInput());
  30. });
  31. base.loop();
  32. }
  33. ]]}, {configs = {languages = "c++11"}}))
  34. end)