request: option to not generate in all directories
Request
Provide a way to only invoke language callbacks on directories that already have a BUILD. Include subdirectory content in language.GenerateArgs.{Subdirs, RegularFiles, GenFiles} for subdirectories without a BUILD.
Background
In rules_go and other rulesets it seems normal to generate BUILD in every directory. In a lot of languages/rulesets this is not always ideal and sometimes impossible (circular deps across directories is way too common in some ecosystems...).
In multiple gazelle languages now I've added directives such as generation_mode: create|update where "update" means only existing BUILDs are updated and no new BUILDs are created. This requires hacks because language.GenerateArgs only provides the list of direct child file/subdirs and not nested ones. The Configure and GenerateRules calls are then still called for every single directory and we must noop if there is no BUILD there, this causes extra overhead, extra fs walking overhead etc.
Proposal
A cross-language directive to enable "update-only" mode, where no new BUILDs are created. When enabled:
-
Configure.Configureis only be invoked on directories that have a BUILD -
language.GenerateRulesis only be invoked on directories that have a BUILD -
GenerateArgs.{RegularFiles, GenFiles}includes files in subdirs that do not have BUILDs -
GenerateArgs.Subdirsonly includes subdirs that do have BUILDs