bazel
Fast, scalable multi-language build system
TLDR
Build target
SYNOPSIS
bazel command [options] [targets]
DESCRIPTION
bazel is a fast, scalable build system that supports multi-language projects and massive codebases. Developed by Google based on their internal Blaze system, it provides reproducible builds, remote caching, and distributed execution.
The tool is designed for monorepos and projects requiring strict dependency management and incremental builds.
PARAMETERS
build target
Build specified targetsrun target
Build and run executable targettest target
Build and run testsquery expression
Query build graphclean
Remove build artifactsfetch target
Fetch external dependencies--jobs n
Number of parallel jobs--config name
Use configuration from .bazelrc--remote_cache url
Remote cache URL--disk_cache path
Disk cache location
CONFIGURATION
~/.bazelrc
User-level build options and configuration flags.WORKSPACE or WORKSPACE.bazel
Root file that defines external dependencies and the project boundary..bazelrc
Project-level build options, config groups, and default flags.
TARGET SYNTAX
- //path/to:target - Specific target
- //path/to:all - All targets in package
- //... - All targets recursively
- @repo//path:target - External repository
FEATURES
- Incremental builds
- Remote caching
- Distributed execution
- Hermetic builds
- Multi-language support (Java, C++, Go, Python, etc.)
- Dependency analysis
- Reproducible builds
BUILD FILES
BUILD or BUILD.bazel files define targets:
name = "hello",
srcs = ["hello.cc"],
)
CAVEATS
Steep learning curve. Requires BUILD files throughout project. Initial setup complex. Can be overkill for small projects. Build times include analysis phase. JVM-based (high memory usage).
HISTORY
Bazel was released by Google in 2015 as an open-source version of their internal Blaze build system, designed to handle massive multi-language monorepos.
