xmake.lua 1.5 KB

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