bazel
Build and test software
TLDR
Build the specified target in the workspace
Remove output files and stop the server if running
Stop the bazel server
Display runtime info about the bazel server
Display help
Display version
SYNOPSIS
bazel [global-options] <command> [<subcommand-options>] [<targets>]
PARAMETERS
--help
Display help for command or option
--version
Print Bazel version
--bazelrc=FILE
Load specific bazelrc config file
--batch
Run in batch mode without daemon
--nocheck_visibility
Skip visibility checks
--compilation_mode=(dbg|opt|fastbuild)
Select debug, optimized, or fastbuild mode
--config=NAME
Apply config section from bazelrc
--define=NAME=VALUE
Set make variable for build
--distinct_host_configuration
Use separate config for host tools
--keep_state_after_build
Retain state post-build
--output_base=PATH
Set output directory base
--output_user_root=PATH
Set user root output directory
--platform_suffix=STR
Suffix for target platforms
--symlink_prefix=PATH
Prefix for output symlinks
--workspace_status_command=FILE
Command for workspace status
DESCRIPTION
Bazel is an open-source build and test system developed by Google for handling massive, multi-language codebases with high performance and reproducibility. It scales to millions of source files and thousands of engineers, using a declarative configuration language called Starlark to define build rules in BUILD files.
Key features include incremental builds that only rebuild changed files, remote caching and execution for distributed teams, and support for languages like Java, C/C++, Python, Go, Android, Node.js, and more. Bazel hermetically seals builds, ensuring identical outputs across environments by downloading exact tool versions.
Workflows start with bazel build //path/to:target for compilation, bazel test //... for unit tests, and bazel run //app:main for deployment. It analyzes dependencies upfront for parallel execution and caching, minimizing build times even on clean checkouts.
CAVEATS
Requires JDK 11+; large initial download (~2GB); steep learning curve for BUILD files and Starlark; not ideal for small projects.
COMMON SUBCOMMANDS
build: Compile targets.
test: Execute tests.
run: Run binaries.
query: Analyze dependency graph.
coverage: Generate coverage reports.
shutdown: Stop Bazel server.
TARGET SYNTAX
Targets like //package:target or //... for recursive; use bazel query to explore.
HISTORY
Developed at Google as Blaze (2006); open-sourced as Bazel in 2015 under Apache 2.0; actively maintained with versions up to 7.x; widely used in monorepos like Google, Facebook.


