improve brpc (#1731)

pull/1734/head
ruki 2 years ago committed by GitHub
parent 61a68a3b7e
commit 314103059e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      packages/b/brpc/xmake.lua
  2. 29
      packages/p/protobuf-cpp/xmake.lua

@ -6,8 +6,9 @@ package("brpc")
add_versions("1.3.0", "a90cf60714941632b2986826336a7c50cbd3d530")
add_patches("1.3.0", path.join(os.scriptdir(), "patches", "1.3.0", "cmake.patch"), "a71bf46a4a6038a89da3ee9057dea5f452155a2da1f1c9bdcae7ecd0bb5e0510")
add_deps("protobuf-cpp 3.19.4")
add_deps("leveldb", "gflags", "openssl", "libzip")
-- we enable zlib in protobuf-cpp, because brpc need google/protobuf/io/gzip_stream.h
add_deps("protobuf-cpp 3.19.4", {configs = {zlib = true}})
add_deps("leveldb", "gflags", "openssl", "libzip", "snappy", "zlib")
add_deps("cmake")
if is_plat("macosx") then
@ -18,8 +19,10 @@ package("brpc")
end
on_install("linux", "macosx", function (package)
local configs = {"-DWITH_DEBUG_SYMBOLS=OFF", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"}
import("package.tools.cmake").install(package, configs)
local configs = {"-DWITH_DEBUG_SYMBOLS=OFF", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-DWITH_SNAPPY=ON"}
io.replace("CMakeLists.txt", 'set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS}', 'set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CPP_FLAGS}', {plain = true})
io.replace("CMakeLists.txt", 'set(CMAKE_C_FLAGS "${CMAKE_CPP_FLAGS}', 'set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CPP_FLAGS}', {plain = true})
import("package.tools.cmake").install(package, configs, {packagedeps = "zlib"})
if not package:config("shared") then
os.rm(package:installdir("lib/*.dylib"))
os.rm(package:installdir("lib/*.so"))

@ -16,9 +16,9 @@ package("protobuf-cpp")
add_patches("3.17.3", path.join(os.scriptdir(), "patches", "3.17.3", "field_access_listener.patch"), "ac9bdf49611b01e563fe74b2aaf1398214129454c3e18f1198245549eb281e85")
add_patches("3.19.4", path.join(os.scriptdir(), "patches", "3.19.4", "vs_runtime.patch"), "8e73e585d29f3b9dca3c279df0b11b3ee7651728c07f51381a69e5899b93c367")
if is_plat("windows") then
add_configs("zlib", {description = "Enable zlib", default = false, type = "boolean"})
add_deps("cmake")
end
if is_plat("windows") then
add_links("libprotobuf")
@ -32,33 +32,26 @@ package("protobuf-cpp")
on_load(function (package)
package:addenv("PATH", "bin")
if package:config("zlib") then
package:add("deps", "zlib")
end
end)
on_install("windows", function (package)
on_install("windows", "linux", "macosx", function (package)
os.cd("cmake")
local configs = {"-Dprotobuf_BUILD_TESTS=OFF", "-Dprotobuf_BUILD_PROTOC_BINARIES=ON"}
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:is_plat("windows") then
table.insert(configs, "-Dprotobuf_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
if package:config("shared") then
package:add("defines", "PROTOBUF_USE_DLLS")
end
import("package.tools.cmake").install(package, configs)
os.cp("build_*/Release/protoc.exe", package:installdir("bin"))
end)
on_install("linux", "macosx", function (package)
local configs = {}
if package:config("pic") ~= false then
table.insert(configs, "--with-pic")
end
if package:config("shared") then
table.insert(configs, "--enable-shared=yes")
table.insert(configs, "--enable-static=no")
else
table.insert(configs, "--enable-static=yes")
table.insert(configs, "--enable-shared=no")
if package:config("zlib") then
table.insert(configs, "-Dprotobuf_WITH_ZLIB=ON")
end
import("package.tools.autoconf").install(package, configs)
import("package.tools.cmake").install(package, configs, {buildir = "build"})
os.trycp("build/Release/protoc.exe", package:installdir("bin"))
end)
on_test(function (package)

Loading…
Cancel
Save