docs: add Bazel build guide and bzlmod example - #3468
Open
zchuango wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands bRPC’s Bazel documentation with bzlmod-first guidance and updates the example/build_with_bazel_module example so it builds both an echo server and a new echo client target against a local bRPC checkout.
Changes:
- Add Bazel build instructions to English/Chinese getting started docs and rewrite Bazel support docs with bzlmod-first setup and required registry guidance.
- Extend
example/build_with_bazel_moduleto include anecho_c++_clientcc_binaryand supportingclient.cpp. - Add bzlmod
single_version_overrideentries (leveldb/openssl) to support aarch64 builds in the bzlmod example.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| example/build_with_bazel_module/MODULE.bazel | Adds bzlmod overrides for leveldb/openssl alongside local brpc checkout usage. |
| example/build_with_bazel_module/client.cpp | Introduces a Bazel/bzlmod-built echo client example. |
| example/build_with_bazel_module/BUILD.bazel | Adds a new echo_c++_client cc_binary target. |
| docs/en/getting_started.md | Adds a “Compile brpc with Bazel” section pointing to the bzlmod example and Bazel docs. |
| docs/en/bazel_support.md | Rewrites Bazel support docs to emphasize bzlmod usage and provides example MODULE.bazel snippets. |
| docs/cn/getting_started.md | Adds a Bazel build section mirroring the English getting started guide. |
| docs/cn/bazel_support.md | Rewrites Chinese Bazel support docs with bzlmod-first guidance and example snippets. |
Suppressed comments (3)
docs/en/bazel_support.md:11
- These
bazel runcommands imply the example is runnable out-of-the-box, but the server requires TLS cert/key files (cert.pem/key.pem). Consider limiting this snippet to build instructions (or add explicit steps to provide/generate the certs).
$ cd example/build_with_bazel_module
$ bazel build //:echo_c++_server //:echo_c++_client
$ bazel run //:echo_c++_server &
$ bazel run //:echo_c++_client
docs/cn/bazel_support.md:10
- 这里的
bazel run会让读者以为示例可以直接运行,但 server 需要cert.pem/key.pem。建议这段只保留 build 命令,或补充如何准备证书文件。
$ cd example/build_with_bazel_module
$ bazel build //:echo_c++_server //:echo_c++_client
$ bazel run //:echo_c++_server &
$ bazel run //:echo_c++_client
example/build_with_bazel_module/client.cpp:74
- Use
nullptr(C++11+) instead ofNULLfor thedonecallback argument, matching other examples (e.g. example/echo_c++/client.cpp) and avoiding the macro’s ambiguous type.
// Because `done'(last parameter) is NULL, this function waits until
// the response comes back or error occurs(including timedout).
stub.Echo(&cntl, &request, &response, NULL);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3
to
+5
| The recommended way to depend on a local bRPC checkout from a Bazel project is | ||
| to use bzlmod (`MODULE.bazel`). See `example/build_with_bazel_module` for a | ||
| runnable example with both a server and a client: |
Comment on lines
+3
to
+4
| 推荐在 Bazel 项目中使用 bzlmod(`MODULE.bazel`)依赖本地 bRPC 源码。 | ||
| `example/build_with_bazel_module` 中有一个包含 server 和 client 的可运行示例: |
| // Channel is thread-safe and can be shared by all threads in your program. | ||
| brpc::Channel channel; | ||
|
|
||
| // Initialize the channel, NULL means using default options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: resolve #2991
Problem Summary:
The build documentation currently focuses on config_brpc.sh and CMake. It does not provide a clear Bazel/bzlmod build path for users who want to build bRPC or use bRPC as a Bazel dependency.
What is changed and the side effects?
Changed:
Side effects:
Performance effects: None. This PR only changes documentation and the Bazel example.
Breaking backward compatibility: None.
Validation:
example/build_with_bazel_module.cd example/build_with_bazel_module && bazel-7.2.1 $JVMARG build //:echo_c++_server //:echo_c++_client.Check List: