Running Gazelle on Gazelle

Gazelle is a tool to automate Bazel BUILD file management. Initially, it was built for managing Go projects via Bazel, but it is extensible to other languages via implementing a few interfaces, or via protobuf.

I am building some extensions for it, which means using Go. After learning a bit about the language, I'm structuring the code in submodules, and as both extensions and Gazelle itself are compiled via Bazel, this implies that you need to keep up to date BUILD files for the main module and each of the submodules.

Gazelle's original purpose is precisely for Go projects, so it should be able to help here. And indeed, Running bazel run //:gazelle from the extension source code root folder, it works nicely, rebuilding and updating all BUILD files as needed, and bazel test //... keeps all nice and green.

I also add a # gazelle:myExtension disabled directive to the root BUILD file, but Gazelle tests don't interfere with execution-time crawling so initially shouldn't be needed.

While a small dogfooding example, it is an excellent showcase about how useful this tool can be.

Tags: Development

Running Gazelle on Gazelle published @ . Author: