xmake.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package("tinymcp")
  2. set_homepage("https://github.com/Qihoo360/TinyMCP")
  3. set_description("A lightweight C++ SDK for implementing the MCP Server.")
  4. set_license("MIT")
  5. add_urls("https://github.com/Qihoo360/TinyMCP.git")
  6. add_versions("2025.05.16", "be9e806c0d5ad0fef5a14b0af3788acde76e4d64")
  7. add_deps("jsoncpp")
  8. if is_plat("linux", "bsd") then
  9. add_syslinks("pthread")
  10. end
  11. on_install("!macosx and !iphoneos", function (package)
  12. io.writefile("xmake.lua", [[
  13. add_rules("mode.release", "mode.debug")
  14. add_requires("jsoncpp")
  15. target("tinymcp")
  16. set_kind("$(kind)")
  17. add_files("Source/Protocol/**.cpp")
  18. add_headerfiles("Source/Protocol/(**.h)")
  19. add_packages("jsoncpp")
  20. if is_plat("windows") and is_kind("shared") then
  21. add_rules("utils.symbols.export_all", {export_classes = true})
  22. end
  23. if is_plat("linux", "bsd") then
  24. add_syslinks("pthread")
  25. end
  26. ]])
  27. import("package.tools.xmake").install(package)
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({test = [[
  31. #include <Entity/Server.h>
  32. namespace Implementation
  33. {
  34. class CEchoServer : public MCP::CMCPServer<CEchoServer>
  35. {
  36. public:
  37. int Initialize() override;
  38. private:
  39. friend class MCP::CMCPServer<CEchoServer>;
  40. CEchoServer() = default;
  41. static CEchoServer s_Instance;
  42. };
  43. }
  44. namespace Implementation
  45. {
  46. int CEchoServer::Initialize()
  47. {
  48. MCP::Implementation serverInfo;
  49. SetServerInfo(serverInfo);
  50. return 0;
  51. }
  52. CEchoServer CEchoServer::s_Instance;
  53. }
  54. void test() {
  55. auto& server = Implementation::CEchoServer::GetInstance();
  56. int iErrCode = server.Initialize();
  57. }
  58. ]]}))
  59. end)