← 返回命令列表

Linux command

bazel 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Build

bazel build [//path/to:target]

Run

bazel run [//path/to:binary]

Test

bazel test [//path/to:tests]

Query

bazel query "deps([//path/to:target])"

Clean

bazel clean

Example

bazel build //...

Info

bazel info

说明

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.

参数

build _target_
Build specified targets
run _target_
Build and run executable target
test _target_
Build and run tests
query _expression_
Query build graph
cquery _expression_
Query configured build graph (post-analysis)
aquery _expression_
Query action graph
clean
Remove build artifacts
fetch _target_
Fetch external dependencies
coverage _target_
Generate code coverage report for tests
version
Print Bazel version
shutdown
Stop the Bazel server
info
Show build environment info
--jobs _n_
Number of parallel jobs
--config _name_
Use configuration from .bazelrc
--remote_cache _url_
Remote cache URL
--disk_cache _path_
Disk cache location
--compilation_mode (_-c_) _mode_
Compilation mode: fastbuild, dbg, or opt
--keep_going (_-k_)
Continue building after errors
--verbose_failures
Show full command line for failed commands

FAQ

What is the bazel command used for?

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.

How do I run a basic bazel example?

Run `bazel build [//path/to:target]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does build _target_ do in bazel?

Build specified targets