bazel-gazelle
bazel-gazelle copied to clipboard
Calling buildozer to modify build files in go_repository
Currently, to modify the generated BUILD files in go_repository
, people would have to create a patch, which is hard to review and maintain. We can potentially add a buildozer_args
to go_repository
, so if it is set, go_repository
will call buildozer to modify the build files, like "add tags no-remote //:go-sqlite3".
We can potentially introduce a breaking change to address #1064 by applying the patches before calling Gazelle, and only allow to modify build files using the buildozer_args
.
My main concern is that to run buildozer
as part of go_repository
we would need to vendor all of its code and compile it with go
, similar to what we do for other go_repository_tools. I also assume running buildozer
would be much slower than applying patches, but that concern is minor.
We can potentially introduce a breaking change to address https://github.com/bazelbuild/bazel-gazelle/issues/1064 by applying the patches before calling Gazelle, and only allow to modify build files using the buildozer_args.
I do not think we should do this. Requiring everyone to convert their patches to buildozer_args
would be quite the pain. It also makes us entirely dependent on the buildozer
command's functionality for modifying BUILD files, and we can never 100% guarantee that it covers every case.
With these points in mind, I think it would be fine to introduce this as an optional feature, but we should not enforce this requirement on consumers.
We can download the released binary for buildozer to avoid the compiling issue.
It wouldn't need to actually run buildozer
as a separate binary. gazelle
is already linking in buildtools for formatting BUILD files; it can link against and call the code necessary for processing buildozer directives directly.