What problem does it solve?
Navigating Bazel's C and C++ workflows can be complex: developers need clear BUILD file patterns, dependency management with Bzlmod, toolchain registration, remote execution configuration, and sandbox debugging guidance to build, test, and run reliably across environments.
Core Features & Use Cases
- BUILD file guidance: How to author cc_library, cc_binary, and cc_test rules with correct srcs, hdrs, deps, copts, and visibility.
- Dependency management with Bzlmod: Add and inspect external dependencies, view the module graph, and transition from legacy WORKSPACE layouts.
- Toolchain registration & platforms: Define platforms, cc_toolchain_config, cc_toolchain, and register toolchains for custom or cross-compilation workflows.
- Remote execution & caching: Configure remote_executor, remote_cache, and instance names for distributed builds and caching strategies.
- Querying and debugging: Use bazel query, cquery, aquery and sandbox_debug techniques to explore dependency graphs, action arguments, and common sandbox failures.
- Use case example: Migrate a small CMake-based project to Bazel by creating BUILD files for libraries and binaries, adding external deps via MODULE.bazel, registering a custom toolchain, and enabling remote cache for CI.
Quick Start
Create a BUILD file for a C++ library named mylib with its sources and headers, add abseil and googletest as Bzlmod dependencies, and outline steps to register and use a custom cc toolchain.