xmake.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package("srpc")
  2. set_homepage("https://github.com/sogou/srpc")
  3. set_description("RPC framework based on C++ Workflow. Supports SRPC, Baidu bRPC, Tencent tRPC, thrift protocols.")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/sogou/srpc/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/sogou/srpc.git")
  7. add_versions("v0.10.2", "da570f3522e9dfec9c396632044fcb51b5ddc5c854ba7824d1770de138f469fb")
  8. add_deps("cmake", "protobuf-cpp")
  9. add_deps("workflow", "snappy", "lz4", "zlib")
  10. on_install("linux", "macosx", function (package)
  11. local configs = {}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  13. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  14. os.rm("third_party")
  15. io.replace("CMakeLists.txt", 'check_include_file_cxx("workflow/Workflow.h" WORKFLOW_INSTALLED)',
  16. "set(WORKFLOW_INSTALLED TRUE)", {plain = true})
  17. import("package.tools.cmake").install(package, configs, {packagedeps = {
  18. "workflow", "snappy", "lz4", "zlib"}})
  19. if package:config("shared") then
  20. os.rm(path.join(package:installdir("lib"), "*.a"))
  21. else
  22. os.tryrm(path.join(package:installdir("lib"), "*.dylib"))
  23. os.tryrm(path.join(package:installdir("lib"), "*.so"))
  24. end
  25. package:addenv("PATH", "bin")
  26. end)
  27. on_test(function (package)
  28. os.vrun("srpc_generator --version")
  29. assert(package:check_cxxsnippets({test = [[
  30. #include <iostream>
  31. void test() {
  32. std::cout << srpc::GET_CURRENT_MS() << std::endl;
  33. }
  34. ]]}, {configs = {languages = "c++17"}, includes = "srpc/rpc_basic.h"}))
  35. end)