1.5 KiB
1.5 KiB
Bazel CLI
Build
Will generate entries in bazel-bin, bazel-out, bazel-<module> and bazel-testlogs.
In the p18_20 example: the good_read.txt is generated in bazel-bin:
it mirrors how a compilation chain would create a binary,
not how to run it.
Mod
Interacts with the module dependency resolver.
bazel mod tidy: likego mod tidybazel mod explain: likego mod why--verbose_explanationsmode details for--explain
bazel mod explain gazelle
<root> (modern_build_systems@1.0)
├───gazelle@0.40.0 #
├───rules_go@0.51.0-rc2 In MODULE.bazel
│ └───gazelle@0.40.0 # In MODULE.bazel
└───rules_jvm_external@6.10
└───rules_android@0.6.6
└───gazelle@0.40.0 #
Query
List targets. Like in Go, "..." means "everything". Example:
bazel query //...
Starting local Bazel server (9.0.0) and connecting to it...
//sandbox_demo:bad_read
//sandbox_demo:good_read
Run
Executes a generated binary. For the p18_20 example, it does not work because there is nothing to run.
Test
It's just a special case of bazel run:
- runs tests in sandbox,
- captures the output to logs,
- enforces timeouts,
- runs tests in parallel.
- designed for reproducibility and CI
- caches results
Tests can also be run with bazel run:
- directly in the shell, not sandboxed
- has access to envvars
- streams output to terminal
- run non-paralle
- always re-runs
- interactive, can use stdin and debuggers