Using Bzlmod with Bazel 6 or later
- (Bazel 6 only) Enable with
common --enable_bzlmod
in.bazelrc
. - Add to your
MODULE.bazel
file:
# NB: this must come BEFORE bazel_dep(name = "protobuf") because they register the from-source toolchain,
# and the first registration wins.
bazel_dep(name = "toolchains_protoc", version = "0.5.0")
# Optional: choose a version of protoc rather than the latest.
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
# Pin to any version of protoc
version = "v26.0",
)
Using WORKSPACE
Paste this snippet into your WORKSPACE.bazel
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "toolchains_protoc",
sha256 = "77f0fa14b217d328a83b5d0e4d65f84141a19b882c497537237f26ef381ca0f2",
strip_prefix = "toolchains_protoc-0.5.0",
url = "https://github.com/aspect-build/toolchains_protoc/releases/download/v0.5.0/toolchains_protoc-v0.5.0.tar.gz",
)
######################
# toolchains_protoc setup #
######################
# Fetches the toolchains_protoc dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched all the dependencies.
load("@toolchains_protoc//protoc:repositories.bzl", "rules_protoc_dependencies")
rules_protoc_dependencies()
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies")
rules_proto_dependencies()
load("@bazel_features//:deps.bzl", "bazel_features_deps")
bazel_features_deps()
load("@toolchains_protoc//protoc:toolchain.bzl", "protoc_toolchains")
protoc_toolchains(
name = "protoc_toolchains",
version = "v25.3",
)
What's Changed
- chore: mirror protobuf 4.29.5 release by @patricearruda84 in #83
- Changes by create-pull-request action by @github-actions[bot] in #82
- Provide bazelrc preset definition by @hofbi in #84
- Changes by create-pull-request action by @github-actions[bot] in #86
- Fix pre-commit deprecation warnings by @jklukas in #90
- Add linting for unsorted-dict-items by @jklukas in #89
- Changes by create-pull-request action by @github-actions[bot] in #91
New Contributors
- @patricearruda84 made their first contribution in #83
- @hofbi made their first contribution in #84
Full Changelog: v0.4.3...v0.5.0