Add example for build brpc as a third party dependency with bazel?
hey, brpc team, could you guys pls add a example about how to build brpc as an external dependency with bazel build? I didn't find any such instructions online. However, it seems brpc do support bazel build. It would be appreciated if a bazel build example can be provided. Thanks.
Does this example meet your needs? https://github.com/apache/incubator-brpc/tree/master/example/build_with_old_bazel
I want to work on this. Should we add some related documents for this?
/assign
I tried to make brpc an external dependency directly. But bazel give me many errors. such as @openssl: can not found.
git_repository(
name = "apache_brpc",
branch = "release-1.3",
remote = "https://github.com/apache/incubator-brpc",
)
a BUILD file like this :
cc_test(
name = "slice_test",
srcs = glob([
"slice_test.cpp",
]),
deps = [
"@apache_brpc//:bvar",
],
)
Some brpc reliances are in /bazel/third_patry/*, but bazel don't identification them. can give me some help?
I tried to make brpc an external dependency directly. But bazel give me many errors. such as
@openssl:can not found.git_repository( name = "apache_brpc", branch = "release-1.3", remote = "https://github.com/apache/incubator-brpc", )a BUILD file like this :
cc_test( name = "slice_test", srcs = glob([ "slice_test.cpp", ]), deps = [ "@apache_brpc//:bvar", ], )Some brpc reliances are in
/bazel/third_patry/*, but bazel don't identification them. can give me some help?
Actually, I end up with not finding a decent way to resolve this. So, basically, what I did was build the brpc library to an .a library first and then just link against that .a file. It's dirty but it actually works. Hope that helps.
oh, so pity!. how about rewrite the brpc bazel BUILD rules? that we can open a new issue. If other guys can help us. i think it's easy to do it. 😄
You might need to resort to the BRPC team for help then. Actually I'm persuading my team to use GRPC instead but there's an ex-Baiduer who insists on using BRPC. So that's what I can do for it's shitty bazel build system. :-P
You might need to resort to the BRPC team for help then. Actually I'm persuading my team to use GRPC instead but there's an ex-Baiduer who insists on using BRPC. So that's what I can do for it's shitty bazel build system. :-P
Yep, if we want to do it. it is really a big problem. Anyway I think bRPC is a superior rpc project. I will try to do the bazel build file rewrite. If someone is interesting in it or can help me. welcome to reach me.
alright, it turns out to be my problem. They do support building as an external lib from source. My humble bazel knowledge limits my ability to appreciate this project.
custom_http_archive(
name = "brpc",
auto_bind = False,
repository_name = "com_github_brpc_brpc",
auto_strip = False,
strip_prefix = "incubator-brpc-1.3.0",
repo_mapping = {
"@com_github_google_leveldb": "@com_leveldb",
"@com_github_gflags_gflags": "@com_gflags",
"@com_github_madler_zlib": "@net_zlib_zlib_2",
"@openssl": "@com_openssl",
"@com_github_google_glog": "@com_glog",
},
)
native.bind(
name = "brpc",
actual = "@com_github_brpc_brpc//:brpc",
)
this is my solution, basically we already had some local names like leveldb, gflags, ... all we need to do is using repo_mapping to map it.
One caveat, we statically linked openssl and in static linkage the order of these two dependencies matter, "@openssl//:crypto", "@openssl//:ssl", I do suggest the BRPC team switch these two lines so that I don't need to patch it.
Hope that helps. And I think this issue can close now.
it's already resolved close now.
alright, it turns out to be my problem. They do support building as an external lib from source. My humble bazel knowledge limits my ability to appreciate this project.
custom_http_archive( name = "brpc", auto_bind = False, repository_name = "com_github_brpc_brpc", auto_strip = False, strip_prefix = "incubator-brpc-1.3.0", repo_mapping = { "@com_github_google_leveldb": "@com_leveldb", "@com_github_gflags_gflags": "@com_gflags", "@com_github_madler_zlib": "@net_zlib_zlib_2", "@openssl": "@com_openssl", "@com_github_google_glog": "@com_glog", }, ) native.bind( name = "brpc", actual = "@com_github_brpc_brpc//:brpc", )this is my solution, basically we already had some local names like leveldb, gflags, ... all we need to do is using repo_mapping to map it.
One caveat, we statically linked openssl and in static linkage the order of these two dependencies matter, "@openssl//:crypto", "@openssl//:ssl", I do suggest the BRPC team switch these two lines so that I don't need to patch it.
Hope that helps. And I think this issue can close now.
looks more great than my way.
alright, it turns out to be my problem. They do support building as an external lib from source. My humble bazel knowledge limits my ability to appreciate this project.
custom_http_archive( name = "brpc", auto_bind = False, repository_name = "com_github_brpc_brpc", auto_strip = False, strip_prefix = "incubator-brpc-1.3.0", repo_mapping = { "@com_github_google_leveldb": "@com_leveldb", "@com_github_gflags_gflags": "@com_gflags", "@com_github_madler_zlib": "@net_zlib_zlib_2", "@openssl": "@com_openssl", "@com_github_google_glog": "@com_glog", }, ) native.bind( name = "brpc", actual = "@com_github_brpc_brpc//:brpc", )this is my solution, basically we already had some local names like leveldb, gflags, ... all we need to do is using repo_mapping to map it.
One caveat, we statically linked openssl and in static linkage the order of these two dependencies matter, "@openssl//:crypto", "@openssl//:ssl", I do suggest the BRPC team switch these two lines so that I don't need to patch it.
Hope that helps. And I think this issue can close now.
Can you provide more details about your build way? I try a demo with the build style, but bazel can not found the custom_http_archive. I want to make the way to the master branch.
oh, that's my customized http_archive, because I already had those dependencies in my workspace (some other projects already depended on them). but I think you basically need is something like grpc_deps.bzl. You put all those dependencies in this file and when people want to use brpc as an external dependent, all they need to do is put codes like
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
in their WORKSPACE
one caveat is that they used a bazel defined variable to control if building with glog or not. I didn't find a good way to pass this variable to brpc when built as an external dependency, so I slapped a patch on it to stipulate the building with glog. If you find a way to solve this, pls let me know. Thanks.