protoc-gen-validate
protoc-gen-validate copied to clipboard
Investigate using Bazel toolchain support to avoid forking rules_go
Today, we fork https://github.com/bazelbuild/rules_go to add our own variant of go_proto_library with the ability to use the PGV plugin for code generation, see:
- https://github.com/lyft/protoc-gen-validate/blob/master/bazel/go_proto_library.bzl
- https://github.com/lyft/protoc-gen-validate/blob/master/bazel/go_proto_library.bzl.diff
rules_go recently gained the ability to work with proto_library and custom toolchains, see https://github.com/bazelbuild/rules_go/blob/master/proto/toolchain.bzl. We might be able to avoid forking as a result and have a more maintainable solution going forward if we switch to this model.
In trying to compile Envoy for aarch64 I attempted to upgrade the rules_go dependency to https://github.com/bazelbuild/rules_go/releases/tag/0.12.0. This generates the following error which is caused by lyft/protoc-gen-validate. You can replicate the exact error in building this library with the following change to WORKSPACE and building with bazel build //:protoc-gen-validate
- commit = "cdaa8e35cf53ba539ebe5bf6a4a407f91a284594",
+ commit = "167cb55932c4a415edf839f750bdd7366f2f1613", # v0.12.0
INFO: Build options have changed, discarding analysis cache.
ERROR: ~/.cache/bazel/_bazel_account/4c51eed5966769432404e0913d9d9631/external/com_github_golang_protobuf/protoc-gen-go/BUILD.bazel:18:1: in go_binary rule @com_github_golang_protobuf//protoc-gen-go:protoc-gen-go: cycle in dependency graph:
//:protoc-gen-validate
//:go_default_library
//module:go_default_library
//vendor/github.com/lyft/protoc-gen-star:go_default_library
//vendor/github.com/golang/protobuf/protoc-gen-go/descriptor:go_default_library
//vendor/github.com/golang/protobuf/protoc-gen-go/descriptor:descriptor_go_proto
@io_bazel_rules_go//proto:go_grpc
@io_bazel_rules_go//proto/wkt:timestamp_go_proto
@io_bazel_rules_go//proto:go_proto_bootstrap
.-> @com_github_golang_protobuf//protoc-gen-go:protoc-gen-go (host)
| @com_github_golang_protobuf//protoc-gen-go:go_default_library (host)
| @com_github_golang_protobuf//protoc-gen-go/generator:go_default_library (host)
| @io_bazel_rules_go//proto/wkt:compiler_plugin_go_proto (host)
| @io_bazel_rules_go//proto/wkt:descriptor_go_proto (host)
| @io_bazel_rules_go//proto:go_proto_bootstrap (host)
`-- @com_github_golang_protobuf//protoc-gen-go:protoc-gen-go (host)
This cycle occurred because of a configuration option
ERROR: Analysis of target '//:protoc-gen-validate' failed; build aborted
INFO: Elapsed time: 2.926s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (44 packages loaded)
This error is a blocker to upgrading the Envoy rules_go dependency at https://github.com/envoyproxy/envoy/blob/master/bazel/repository_locations.bzl#L93-L96 I tried to work out the code and the dependency error but the fork is fairly hard to follow for the Bazel novice. /cc @htuch
The fork is based on proto/go_proto_library.bzl which was deprecated in 0.12.0 of rules_go. New proto rules are at https://github.com/bazelbuild/rules_go/blob/master/proto/def.bzl
@htuch this is resolved, right?