Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Bazel rules for Buf.

License

NotificationsYou must be signed in to change notification settings

bufbuild/rules_buf

Repository files navigation

Bazel rules forBuf. The rules work alongside theproto_library rule ofrules_proto.

Status

This module is a beta, but we may make a few changes as we gather feedback from early adopters.

Setup

Include the following snippet in the Workspace file to setuprules_buf. Refer torelease notes of a specific version for setup instructions.

load("@bazel_tools//tools/build_defs/repo:http.bzl","http_archive")http_archive(name="rules_buf",integrity="sha256-Hr64Q/CaYr0E3ptAjEOgdZd1yc+cBjp7OG1wzuf3DIs=",strip_prefix="rules_buf-0.3.0",urls= ["https://github.com/bufbuild/rules_buf/archive/refs/tags/v0.3.0.zip",    ],)load("@rules_buf//buf:repositories.bzl","rules_buf_dependencies","rules_buf_toolchains")rules_buf_dependencies()rules_buf_toolchains(version="v1.32.1")# rules_protoload("@rules_proto//proto:repositories.bzl","rules_proto_dependencies","rules_proto_toolchains")rules_proto_dependencies()rules_proto_toolchains()

Refer thedocs or browse theexamples on how to setup and use for various scenarios.

List of rules

Gazelle Extension

The repo also offers a Gazelle extension for generating the rules.

Please refer to thegazelle section in the docs.

Development

The repository follows theofficial recommendation on deploying bazel rules.All the rule definitions are inbuf/internal.

Gazelle

Gazelle extension is ingazelle/buf. Before looking at the code it would be best to understand thearchitecture of gazelle. The file structure is loosely based on thego andprotoextensions that are shipped with gazelle.They are also excellent to better understand the architecture.

The main entry point to the extension is via theNewLanguage function ingazelle/buf/buf.go. Gazelle mostly depends onLanguage interface. Apart from that one can also implement some optional interfaces.

We implement the following interfaces,

  • Language: Required. Used for build/test rule generation and label resolutions for these rules.
  • RepoImporter: Optional. Used to generatebuf_dependencies rule frombuf.yaml/buf.work.yaml.
  • CrossResolver: Optional. Used to resolve dependencies across extensions/languages. We use it to resolve any proto files that are part ofbuf_dependencies rules.

[8]ページ先頭

©2009-2025 Movatter.jp