Skip to content

docs: add Bazel build guide and bzlmod example - #11

Closed
cw20050111-prog wants to merge 17 commits into
LinQuickDev:urma_transportfrom
cw20050111-prog:2991
Closed

docs: add Bazel build guide and bzlmod example#11
cw20050111-prog wants to merge 17 commits into
LinQuickDev:urma_transportfrom
cw20050111-prog:2991

Conversation

@cw20050111-prog

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: resolve apache#2991

Problem Summary:

The official documentation currently only describes CMake and config_brpc.sh build steps. It lacks Bazel build instructions, making it harder for developers to understand how to build and use bRPC with Bazel.

What is changed and the side effects?

Changed:

  • Add Bazel/bzlmod usage instructions to the English and Chinese Bazel documentation.
  • Add example/build_with_bazel_module with runnable server/client targets.
  • Document required registries and root MODULE.bazel setup for using bRPC as a Bazel dependency.
  • Add required single_version_override entries for leveldb and openssl, and document that users must repeat these overrides in their own root MODULE.bazel.
  • Add related Bazel/CI/build updates for URMA-enabled builds.

Side effects:

  • Performance effects: None.

  • Breaking backward compatibility: None.


Check List:

cw20050111-prog and others added 17 commits August 20, 2026 13:40
Reviewer noted docs/cn/urma.md only covered the CMake build and that
DOWNLOAD_URMA_HEADERS has no Bazel equivalent. Document the Bazel
build command and clarify that Bazel always fetches UMDK headers from
the pinned git_repository commit and always links the mock backend
(no real-liburma detection yet), and that urma_performance has no
Bazel target.
bazel/third_party/umdk only contained umdk.BUILD, unlike every other
bazel/third_party/<dep> directory which pairs its <dep>.BUILD with an
empty BUILD.bazel marking the directory as a package. Without it,
resolving the git_repository(build_file = "//bazel/third_party/umdk:umdk.BUILD")
label fails once the umdk repo is actually fetched:

  Error in read: Unable to load package for //bazel/third_party/umdk:umdk.BUILD:
  BUILD file not found ...

This broke `bazel build --define=BRPC_WITH_URMA=true //:brpc` on both
x86_64 and arm64 (confirmed via GitHub Actions CI on ubuntu-22.04 and
ubuntu-24.04-arm).
…works

The umdk repo ships its own src/urma/BUILD.bazel, which makes Bazel
treat src/urma/ as a separate package. glob() in our umdk.BUILD
(rooted at the umdk repo root) can't cross that boundary, so
hdrs = glob(["src/urma/lib/urma/**/include/*.h"]) silently resolved to
an empty list. The cc_library then exported no header inputs, so
compiling anything that #includes urma_api.h failed with "No such
file or directory" even though the -isystem path was correct and the
file existed on disk.

Confirmed via GitHub Actions on both ubuntu-22.04 (x86_64) and
ubuntu-24.04-arm (arm64): `bazel build --define=BRPC_WITH_URMA=true //:brpc`
failed identically on both before this patch_cmds fix.
Reviewer dwh110 pointed out that src/brpc/urma/mock_urma.cpp had no
independent feature switch: whenever liburma wasn't found, CMake/Make
silently linked the mock, which can produce a binary that looks
URMA-capable but can't reach real hardware.

Add WITH_URMA_MOCK (CMake) / --with-urma-mock (config_brpc.sh),
default OFF. When WITH_URMA is enabled and liburma isn't found, the
build now fails with a clear message unless the mock is explicitly
requested, instead of substituting it implicitly. Document the new
flag in docs/en/urma.md and docs/cn/urma.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Add conditional linking for URMA library based on availability.
Added a comment regarding linking with liburma based on brpc build options.
Added logic to find the URMA library and handle its absence.
Removed conditional check for URMA library and related messages.
Update logic for linking liburma based on header presence.
- ci-linux.yml: new compile-and-test-with-urma job builds with
  -DWITH_URMA=ON against the openEuler-mirror UMDK headers on GitHub
  (avoids the atomgit.com dependency) and runs brpc_urma_unittest with
  the link-time mock, since no URMA hardware is available on runners.
- mock_urma.cpp: add urma_user_ctl(), referenced by SetBondingMode()
  whenever urma_ubagg.h is available; without it, WITH_URMA=ON fails
  to link against the mock.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JX6CCou3VWh8ZxRR4x6zvY
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.

1 participant