Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request: option to not generate in all directories #1832

Open
jbedard opened this issue Jun 21, 2024 · 0 comments · May be fixed by #1921
Open

request: option to not generate in all directories #1832

jbedard opened this issue Jun 21, 2024 · 0 comments · May be fixed by #1921

Comments

@jbedard
Copy link
Contributor

jbedard commented Jun 21, 2024

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.Configure is only be invoked on directories that have a BUILD
  • language.GenerateRules is only be invoked on directories that have a BUILD
  • GenerateArgs.{RegularFiles, GenFiles} includes files in subdirs that do not have BUILDs
  • GenerateArgs.Subdirs only includes subdirs that do have BUILDs
jbedard added a commit to jbedard/bazel-gazelle that referenced this issue Sep 12, 2024
@jbedard jbedard linked a pull request Sep 12, 2024 that will close this issue
jbedard added a commit to jbedard/bazel-gazelle that referenced this issue Sep 14, 2024
jbedard added a commit to jbedard/bazel-gazelle that referenced this issue Sep 16, 2024
jbedard added a commit to jbedard/bazel-gazelle that referenced this issue Sep 16, 2024
jbedard added a commit to jbedard/bazel-gazelle that referenced this issue Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant