buf icon indicating copy to clipboard operation
buf copied to clipboard

Add a way to supply custom buf plugin paths to `protoc-gen-buf-*`

Open srikrsna-buf opened this issue 6 months ago • 2 comments

Feature

rules_buf uses protoc-gen-buf-* plugins to support lint and breaking checks in Bazel. To be able to use custom buf plugins we will need a way to pass the custom plugin paths to protoc-gen-buf-*.

One way to do this is to use a map to override the path to custom plugins in protoc-gen-buf-* config. We can add a new config option called plugin_paths or plugin_overrides that is a map of plugin names (as they appear in buf.yaml) to the path of the plugin. This will let rules_buf pass the plugin paths.

This feature is similar to protoc's --plugin option.

srikrsna-buf avatar Jun 10 '25 15:06 srikrsna-buf

Can rules_buf pass an array of plugins with the config as an array of external buf.yaml v2 config type? This would then set the lint and breaking plugin options. A mapping from the buf.yaml would be handled by rules_buf in this case.

Another option would be to always modify the config override and pass it as a JSON object as the input_config. Buf could then pass those plugin options for the protoc-gen-buf-* cmds without adding any additional configuration inputs.

emcfarlane avatar Jun 10 '25 20:06 emcfarlane

The problem in Bazel is that we cannot read the buf.yaml in the rule, we can only pass the file along and declare outputs to commands.

srikrsna-buf avatar Jun 11 '25 11:06 srikrsna-buf