Google's build system Bazel is what you describe.
Gazelle, the BUILD file generator for Go, now supports plugins and several other languages have Gazelle plugins.
I’ve used AI to generate BUILD file generators before, though. I had good luck getting it to write a script that would analyze a Java project with circular dependencies and aggregate the cycle participants into a single target.
I don’t like generative AI for rote tasks like this, but I’ve had good luck using generative AI to write deterministic code generators that I can commit to a project and reuse.