Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bazel third_party support #1996

Merged
merged 8 commits into from
Dec 6, 2022
Merged

Conversation

fansehep
Copy link
Contributor

@fansehep fansehep commented Nov 16, 2022

What problem does this PR solve?

Issue Number: #1992 #1918

Problem Summary: bRPC as thirdparty deps is not easy.

What is changed and the side effects?

Changed: I add a example about 1.3 release how to add bRPC to your project and some about this docs.

I have test in my docker debian9 server. bazel version = 4.2.2
and i have test link @apache_brpc:bthread, bvar, butil, brpc all of them are successful.

Side effects:

  • Performance effects(性能影响): null

  • Breaking backward compatibility(向后兼容性): null


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@@ -0,0 +1,14 @@
## bRPC 作为Bazel第三方依赖
1. bRPC 依赖于一些开源库, 但这些库并没有提供bazel支持, 所以需要你手动将一部分依赖加入到你的构建项目中.
2. 将 /example/bazel_1_3_release/build_for_brpc 该文件移动到你的项目根目录下, 将 /example/bazel_1_3_release/build_for_brpc/WORKSPACE_eample 内容添加到你的WORKSPACE中.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eample -> example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eample -> example

🥲 fixed.

@@ -0,0 +1,14 @@
## bRPC as a Bazel third-party dependency
1. bRPC relies on a number of open source libraries that do not provide bazel support, so you will need to manually add some of these dependencies to your build project.
2. Move the file /example/bazel_1_3_release/build_for_brpc to the root of your project, and add the contents of /example/bazel_1_3_release/build_for_brpc/WORKSPACE_eample to your WORKSPACE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eample -> example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eample -> example

fixed.

)


BAZEL_SKYLIB_VERSION = "1.1.1" # 2021-09-27T17:33:49Z
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with line 23

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with line 23

fixed.


BAZEL_SKYLIB_VERSION = "1.1.1" # 2021-09-27T17:33:49Z

BAZEL_SKYLIB_SHA256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with line 25

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with line 25

fixed.



http_archive(
name = "bazel_skylib",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated with line 29

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contributor

fixed.

#include <bthread/execution_queue.h>

int main () {
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may call some bthread function here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may call some bthread function here

should we need a test? the BUILD add a empty test here.

@@ -0,0 +1,14 @@
## bRPC 作为Bazel第三方依赖
1. bRPC 依赖于一些开源库, 但这些库并没有提供bazel支持, 所以需要你手动将一部分依赖加入到你的构建项目中.
2. 将 /example/bazel_1_3_release/build_for_brpc 该文件移动到你的项目根目录下, 将 /example/bazel_1_3_release/build_for_brpc/WORKSPACE_eample 内容添加到你的WORKSPACE中.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may change the directory name from bazel_1_3_release to build_with_bazel since there is an existing directory named build_with_old_bazel
And you can follow the directory structure of build_with_old_bazel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@wwbmmm
Copy link
Contributor

wwbmmm commented Nov 16, 2022

CI is failed

@fansehep
Copy link
Contributor Author

CI is failed

maybe it is the test failed.

@fansehep fansehep changed the title add bazel third_pary support add bazel third_party support Nov 16, 2022
@@ -0,0 +1,14 @@
## bRPC 作为Bazel第三方依赖
1. bRPC 依赖于一些开源库, 但这些库并没有提供bazel支持, 所以需要你手动将一部分依赖加入到你的构建项目中.
2. 将 /example/build_with_bazel/build_for_brpc 该文件移动到你的项目根目录下, 将 /example/build_with_bazel/build_for_brpc/WORKSPACE_example 内容添加到你的WORKSPACE中.
Copy link
Contributor

@wwbmmm wwbmmm Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_for_brpc/WORKSPACE_example
this path does not exist now

Copy link
Contributor Author

@fansehep fansehep Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed and add a test for it. test is successfull run.

@@ -0,0 +1,14 @@
## bRPC 作为Bazel第三方依赖
1. bRPC 依赖于一些开源库, 但这些库并没有提供bazel支持, 所以需要你手动将一部分依赖加入到你的构建项目中.
2. 将 /example/build_with_bazel/build_for_brpc 该文件移动到你的项目根目录下, 将 /example/build_with_bazel/build_for_brpc/WORKSPACE 内容添加到你的WORKSPACE中.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove /build_for_brpc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove /build_for_brpc

fixed.

)

config_setting(
name = "have_rdma",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上面有个 //bazel/config:brpc_with_rdma
看能直接复用吗?

@wwbmmm
Copy link
Contributor

wwbmmm commented Nov 17, 2022

LGTM

@Huixxi
Copy link
Contributor

Huixxi commented Nov 17, 2022

Does it support MacOS?

@fansehep
Copy link
Contributor Author

Does it support MacOS?

I do not have Mac laptop, you can try it?

@Huixxi
Copy link
Contributor

Huixxi commented Nov 17, 2022

Ok, I will try it later.

@guodongxiaren
Copy link
Member

Ok, I will try it later.
Mac能生效吗?
@Huixxi

Copy link
Contributor

@372046933 372046933 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could brpc_workspace be applied to BRPC WORKSPACE?

native.new_local_repository(
name = "openssl",
path = "/usr",
build_file = "//:openssl.BUILD",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//:openssl.BUILD actually links to openssl on the system. While openssl in BRPC WORKSPACE is compiled by foreign_rules.
It's better to keep the same with that in BRPC WORKSPACE
So brpc_workspace.bzl is different from the original WORKSPACE file. Could brpc_workspace be used by WORKSPACE in BRPC as well to maintain a consistent WORKSPACE?

@fansehep
Copy link
Contributor Author

Ok, I will try it later.

@Huixxi Have you test successful in MacOS?
Here is a simple demo in this pull request.

cd example/build_with_bazel
bazel build "..."
./bazel-bin/test

Try this?

name = "openssl",
path = "/usr",
http_archive(
name = "openssl", # 2021-12-14T15:45:01Z
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

example/build_with_bazel/openssl.BUILD does not build but links to system installed openssl.
Here is the real build:
https://github.com/apache/incubator-brpc/blob/fae30e6a9a84ef8c2e0bfe1ce23afa5611a1ffab/bazel/third_party/openssl/openssl.BUILD#L132

@zyearn
Copy link
Member

zyearn commented Nov 30, 2022

Hi, What's the status on it? Could you update the latest code?

@fansehep
Copy link
Contributor Author

fansehep commented Dec 1, 2022

Hi, What's the status on it? Could you update the latest code?

In fact, this is ok. I have tried some other methods, but none of them seem very elegant. So I thinks it can be merged. 😢

@wwbmmm wwbmmm merged commit 0aa1cf1 into apache:master Dec 6, 2022
@89dexua
Copy link

89dexua commented Dec 30, 2023

Any chance to support protobuf 3.21.9
Tensorflow 2.15.0 not Compatible with protobuf 3.19.1

Simply change the protobuf version got this error message

ERROR: brpc/example/BUILD.bazel:40:14: every rule of type proto_library implicitly depends upon the target '@com_google_protobuf//:protoc', but this target could not be found because of: error loading package '@com_google_protobuf//': cannot load '@com_google_protobuf//:compiler_config_setting.bzl': no such file

@fansehep
Copy link
Contributor Author

Any chance to support protobuf 3.21.9 Tensorflow 2.15.0 not Compatible with protobuf 3.19.1

Simply change the protobuf version got this error message

ERROR: brpc/example/BUILD.bazel:40:14: every rule of type proto_library implicitly depends upon the target '@com_google_protobuf//:protoc', but this target could not be found because of: error loading package '@com_google_protobuf//': cannot load '@com_google_protobuf//:compiler_config_setting.bzl': no such file

Problems with rhombic dependence, Can try change the build stricp brpc protobuf name to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants