bazel --version
bazel 6.0.0
-
Workspace
: a directory on your filesystem that contains the source files for the software you want to build. Each workspace directory has a text file namedWORKSPACE
.Repository
: The directory containing theWORKSPACE
file is the root of the main repository, also called@
.Package
: The primary unit of code organization in a repository. A package is defined as a directory containing a file namedBUILD
orBUILD.bazel
.Target
: A package is a container. The elements of a package are called targets.Labels
:@myrepo//my/app/main:app_binary
=//my/app/main:app_binary
inside@myrepo
my/app/main
: un-qualified package name@myrepo//my/app/main
: full-qualified package nameapp_binary
or:app_binary
inside@myrepo//my/app/main
-
Repository rules (
WORKSPACE
):- Git
git_repository
- Http
http_archive
- util
maybe
- Git
- Build Go with Gazelle (v0.1.0)
- Build Protobuf (v0.2.0)
- Build Python (v0.3.0)
- Build Java (v0.4.0)
- Build Python with Poetry (v0.5.0)
- Build Python with Proto (v0.6.0)
- Bazel
bazel clean
: clean up the cache.
- Java:
- build:
bazel build //java:App
- run:
bazel run //java:App
- check dep:
bazel query --notool_deps --noimplicit_deps "deps(//java:App)" --output graph
- build:
- Python:
bazel run //python:main
- Go:
- build:
bazel build //go/cmd
: Build a packagecmd
. - run:
bazel run //go/cmd
: Run a packagecmd
. bazel run //:gazelle
: Generate build file.bazel run //:gazelle -- update-repos -from_file=go.mod
: Updatego_repository
inWORKSPACE
fromgo.mod
.
- build:
- How to upgrade
http_archive
version?
- https://www.youtube.com/watch?v=8P3m1-U7v0k
- https://christina04.hatenablog.com/entry/using-bazel-to-build-go
- https://christina04.hatenablog.com/entry/using-bazel-to-build-protobuf
- https://christina04.hatenablog.com/entry/using-bazel-to-build-docker-image
- https://christina04.hatenablog.com/entry/using-bazel-to-build-grpc
- https://christina04.hatenablog.com/entry/bazel-remote-cache
- https://christina04.hatenablog.com/entry/test-with-bazel
- https://christina04.hatenablog.com/entry/bazel-tips
- https://note.crohaco.net/2020/bazel-golang/
- bazelbuild/bazel#10134
- bazelbuild/bazel#15673