xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package("brpc")
  2. set_homepage("https://github.com/apache/incubator-brpc")
  3. set_description("brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc.")
  4. add_urls("https://github.com/apache/brpc/archive/refs/tags/$(version).tar.gz")
  5. add_versions("1.4.0", "6ea39d8984217f62ef954b7ebc0dfa724c62472a5ae7033ed189f994f28b9e30")
  6. add_patches("1.4.0", path.join(os.scriptdir(), "patches", "1.4.0", "cmake.patch"), "006fa842e84a6e8091f236a12e7c44dd60962cc61fddf46bcfc65a2093383cef")
  7. add_versions("1.3.0", "b9d638b76725552ed11178c650d7fc95e30f252db7972a93dc309a0698c7d2b8")
  8. add_patches("1.3.0", path.join(os.scriptdir(), "patches", "1.3.0", "cmake.patch"), "a71bf46a4a6038a89da3ee9057dea5f452155a2da1f1c9bdcae7ecd0bb5e0510")
  9. -- we enable zlib in protobuf-cpp, because brpc need google/protobuf/io/gzip_stream.h
  10. add_deps("protobuf-cpp 3.19.4", {configs = {zlib = true}})
  11. add_deps("leveldb", "gflags", "openssl", "libzip", "snappy", "zlib")
  12. add_deps("cmake")
  13. if is_plat("macosx") then
  14. add_frameworks("Foundation", "CoreFoundation", "Security", "CoreGraphics", "CoreText")
  15. add_ldflags("-Wl,-U,_ProfilerStart", "-Wl,-U,_ProfilerStop")
  16. elseif is_plat("linux") then
  17. add_syslinks("rt", "dl")
  18. end
  19. on_install("linux", "macosx", function (package)
  20. local configs = {"-DWITH_DEBUG_SYMBOLS=OFF", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-DWITH_SNAPPY=ON"}
  21. io.replace("CMakeLists.txt", 'set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS}', 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CPP_FLAGS}', {plain = true})
  22. io.replace("CMakeLists.txt", 'set(CMAKE_C_FLAGS "${CMAKE_CPP_FLAGS}', 'set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CPP_FLAGS}', {plain = true})
  23. import("package.tools.cmake").install(package, configs, {packagedeps = "zlib"})
  24. if not package:config("shared") then
  25. os.rm(package:installdir("lib/*.dylib"))
  26. os.rm(package:installdir("lib/*.so"))
  27. end
  28. end)
  29. on_test(function (package)
  30. assert(package:check_cxxsnippets({
  31. test = [[
  32. #include <brpc/server.h>
  33. static void test() {
  34. brpc::Server server;
  35. }
  36. ]]
  37. }, {configs = {languages = "c++11"}}))
  38. end)