LinuxCommandLibrary

bazel

TLDR

Build target

$ bazel build [//path/to:target]
copy
Run binary
$ bazel run [//path/to:binary]
copy
Test targets
$ bazel test [//path/to:tests]
copy
Query dependencies
$ bazel query ["deps(//path/to:target)"]
copy
Clean build artifacts
$ bazel clean
copy
Build all
$ bazel build //...
copy

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 targets
run target
Build and run executable target
test target
Build and run tests
query expression
Query build graph
clean
Remove build artifacts
fetch 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

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:

$ cc_binary(
    name = "hello",
    srcs = ["hello.cc"],
)
copy

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.

SEE ALSO

make(1), ninja(1), buck(1)

Copied to clipboard