buildifier: decouple runner scripts from binaries (#1398)

This change aims at making `buildtools/buildifier` more modular and
easier to consume by enabling use of prebuilt binaries without pulling
in unnecessary dependencies - while strengthening upstream as the
authoritative home for runner script templates.

Today, `buildifier/BUILD.bazel` exposes two different sets of rules:
- exports for runner script templates (`runner.bash.template`,
  `runner.bat.template`) as well as `README.md`,
- `go` build & `sh` test rules which require external repos (`rules_go`,
  `rules_shell`) even for consumers who don't need to build the
  `buildifier` binary.

It is worth noticing there are two distinct community efforts on runner
scripts, the present/upstream `bazelbuild/buildtools` and the derived
`keith/buildifier-prebuilt` (Bazel Central Registry module).
These drift apart over time, leading to unsynchronized contents
(`factory.bzl`, `runner.bash.template`) and efforts, e.g. on Windows
support:
- https://github.com/bazelbuild/buildtools/pull/1230
- https://github.com/keith/buildifier-prebuilt/pull/89 (open for a year)

Intended benefits of this change:
- decoupling: by moving `go_binary` and `sh_test` targets into
  `buildifier/cmd`, the top-level `buildifier/BUILD.bazel` no longer
  requires `rules_go` nor `rules_shell`,
- flexibility: users can either build binaries from source (via
  `//buildifier/cmd`) or configure rules to use prebuilt binaries (e.g.
  via `multitool`) while still consuming the same upstream runner script
  templates,
- backward compatibility: aliases keep `//buildifier:buildifier*`
  working by delegating to `//buildifier/cmd:buildifier*`.
7 files changed
tree: a1a65b649fc93258be12e8964f9be9d4a0f23391
  1. .bazelci/
  2. api_proto/
  3. build/
  4. build_proto/
  5. buildifier/
  6. buildozer/
  7. bzlenv/
  8. config/
  9. convertast/
  10. deps_proto/
  11. differ/
  12. edit/
  13. extra_actions_base_proto/
  14. file/
  15. generatetables/
  16. labels/
  17. lang/
  18. release/
  19. tables/
  20. testutils/
  21. unused_deps/
  22. warn/
  23. wspace/
  24. .bazelrc
  25. .bazelversion
  26. .gitignore
  27. .mailmap
  28. .pre-commit-config.yaml
  29. BUILD.bazel
  30. CODEOWNERS
  31. CONTRIBUTING.md
  32. CONTRIBUTORS
  33. go.mod
  34. go.sum
  35. launcher.js
  36. LICENSE
  37. MODULE.bazel
  38. README.md
  39. status.py
  40. update_generated.sh
  41. WARNINGS.md
  42. WORKSPACE
  43. WORKSPACE.bzlmod
README.md

Buildtools for bazel

This repository contains developer tools for working with Google's bazel buildtool.

Build status

Setup

See instructions in each tool's directory.