brpc 在 linux 下编译构建,比在 mac 下还要更复杂些,mac 下可以走官方说明编译成功,过程中也需要进行一些配置调整。
在 linux 通过 bazel 最终实现了 brpc 编译通过。
相关版本 centos 版本 7,bazel 版本 2.0.0
brpc 版本 1.0,gflags 、protobuf、leveldb 相关版本因网络加载慢原因,通过下载下来配置到本地实现。
bazel WORKSPACE 配置
workspace(name = "com_github_brpc_brpc")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
skylib_version = "0.8.0"
http_archive(
name = "bazel_skylib",
type = "tar.gz",
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.tar.gz".format (skylib_version, skylib_version),
sha256 = "2ef429f5d7ce7111263289644d233707dba35e39696377ebab8b0bc701f7818e",
)
local_repository(
name = "rules_cc",
path = "/root/rules_cc-8bd6cd75d03c01bb82561a96d9c1f9f7157b13d0",
)
local_repository(
name = "rules_java",
path = "/root/rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178",
)
local_repository(
name = "com_google_protobuf",
path = "/root/protobuf-3.6.1.3",
)
local_repository(
name = "com_github_gflags_gflags",
path = "/root/gflags-46f73f88b18aee341538c0dfc22b1710a6abedef",
)
bind(
name = "gflags",
actual = "@com_github_gflags_gflags//:gflags",
)
new_local_repository(
name = "com_github_google_leveldb",
path = "/root/leveldb-a53934a3ae1244679f812d998a4f16f2c7f309a6",
build_file = "//:leveldb.BUILD",
)
http_archive(
name = "com_github_google_glog",
build_file = "//:glog.BUILD",
strip_prefix = "glog-a6a166db069520dbbd653c97c2e5b12e08a8bb26",
url = "https://github.com/google/glog/archive/a6a166db069520dbbd653c97c2e5b12e08a8bb26.tar.gz"
)
http_archive(
name = "com_google_googletest",
strip_prefix = "googletest-0fe96607d85cf3a25ac40da369db62bbee2939a5",
url = "https://github.com/google/googletest/archive/0fe96607d85cf3a25ac40da369db62bbee2939a5.tar.gz",
)
new_local_repository(
name = "openssl",
path = "/usr",
build_file = "//:openssl.BUILD",
)
new_local_repository(
name = "openssl_macos",
build_file = "//:openssl.BUILD",
path = "/usr/local/opt/openssl",
)
bind(
name = "ssl",
actual = "@openssl//:ssl"
)
bind(
name = "ssl_macos",
actual = "@openssl_macos//:ssl"
)
new_local_repository(
name = "zlib",
build_file = "//:zlib.BUILD",
path = "/usr",
)
编译命令
brpc bazel编译:
bazel build //:protoc-gen-mcpack --incompatible_disable_deprecated_attr_params=false --incompatible_new_actions_api=false
echo_c++_server bazel编译:
bazel build //example:echo_c++_server --incompatible_disable_deprecated_attr_params=false --incompatible_new_actions_api=false --copt -DHAVE_ZLIB=1
标签:gflags,brpc,name,bazel,local,编译,linux,com From: https://www.cnblogs.com/freedommovie/p/18364859