Bazel Fast, hermetic builds
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
bazel build //...
bazel test //...
bazel run //<pkg>:<target>
bazel test --test_output=errors //...
bazel query
"deps(//<pkg>:<target>)"
bazel build -c opt //<pkg>:<target>
bazel cleanbazel infoConcepts
- Load read BUILD files
- Analyze build the action graph
- Execute run actions, use cache
- bazel-bin/ results
Build
bazel build <targets>
bazel build //...
bazel build //<pkg>/...
bazel build //<pkg>:all
bazel build -- //... -//<pkg>/...
bazel build -c <mode>
bazel build -kbazel build --config=<name>
bazel build --nobuild
Test
bazel test <targets>
bazel test --test_output=errors
bazel test --test_output=all
bazel test --test_filter=<expr>
bazel test --test_arg=<arg>
bazel test --runs_per_test=<N>
bazel test --cache_test_results=no
bazel coverage <targets>
Run
bazel run <target>
bazel run <target> -- <args>
bazel-bin/<pkg>/<target>
Query
bazel query "deps(<t>)"
bazel query "rdeps(//..., <t>)"
bazel query "somepath(<a>, <b>)"
bazel query "allpaths(<a>, <b>)"
bazel query "kind(<regex>, //...)"
bazel query //<pkg>/... --output=label_kind
bazel query <expr> --output=graph
bazel query <expr> --noimplicit_deps
bazel cquery <expr>
bazel cquery <expr> --output=files
bazel aquery <expr>
bazel aquery "mnemonic('<regex>',
<t>)"
bazel aquery <expr> --output=commands
Dependencies (Bzlmod)
bazel mod graphbazel mod explain <module>
bazel mod path <module> --from <root>
bazel mod show_repo @<repo>
bazel mod tidybazel fetch //...
--lockfile_mode=error
Server and cleanup
bazel cleanbazel clean --expunge
bazel infobazel info <key>
bazel versionbazel help <command>
Debugging builds
bazel build --verbose_failures
bazel build -sbazel build --sandbox_debug
bazel build --profile=<file>
bazel build --announce_rc
.bazelrc
build --<flag>
common --<flag>
build:<name> --<flag>
try-import %workspace%/user.bazelrc
build:linux --<flag>
Recipes
bazel test //<pkg>:<test> \ --test_output=errors --test_filter=<name> \ --cache_test_results=no --verbose_failures
bazel query "somepath(//<pkg>:<a>, //<pkg>:<b>)"bazel query "rdeps(//..., //<pkg>:<b>)" --output=label_kind
# .bazelrcbuild --keep_goingbuild:release -c optbuild:debug -c dbg --strip=never# bazel build --config=release //...



