Skip to content

Do not remove generated files from existing rules - #214

Merged
jayconrod merged 7 commits into
EngFlow:mainfrom
gg-sr:gg-sr/fix-generated-files
Apr 29, 2026
Merged

Do not remove generated files from existing rules#214
jayconrod merged 7 commits into
EngFlow:mainfrom
gg-sr:gg-sr/fix-generated-files

Conversation

@gg-sr

@gg-sr gg-sr commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Before, generated sources were removed from srcs and hdrs; rules with only generated sources would be removed as well.

With this PR, srcs and hdrs keep their generated sources, and rules with only generated sources are kept.

This also seems enough for Gazelle to add dependencies to targets when generated headers are included (e.g. in the example added in this PR, a dependency from test to alone is correctly added based on #include "generated/alone.h").

I decided to only preserve existing srcs and hdrs, rather than adding new ones (e.g. by adding generated sources to fileInfos). I figured treating generated files as sources files would be nice, but would likely have more edge cases.

I cooked this up pretty quickly. I guess there are better ways to add tests than modifying example/bzlmod, but this was the fastest way to test things (and worked with the debugger).

@jayconrod jayconrod left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sending this fix.

A few comments. Please also add Signed-off-by: Your Name <your@email.com> to all commit messages (use git commit -s).

Comment thread language/cc/generate.go Outdated
Comment thread language/cc/generate.go Outdated
Comment thread language/cc/testdata/generated_files/BUILD.in
gg-sr added 5 commits April 22, 2026 13:21
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
@gg-sr
gg-sr force-pushed the gg-sr/fix-generated-files branch from 7b9d556 to 61ac7d3 Compare April 22, 2026 04:26
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
@gg-sr

gg-sr commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review!

I had to force push to change the commit message with --signoff. I made commits for subsequent changes with the expectation that they'd all be squashed before merging into main.

Notably I added helpers to debug tests, similar to how we can debug examples. I can revert them, but I figure they could be useful to others.

Btw, I tried to add support for :generated_file.h syntax as well, but it seems non-trivial (removing the : prefix is part of the solution, but not enough) so I just dropped it.

Comment thread language/cc/testdata/.gitignore
Comment thread language/cc/testdata/.gitignore
Comment thread .vscode/launch.json Outdated
Signed-off-by: Grégoire Geis <gregoire@seoulrobotics.org>
@gg-sr
gg-sr force-pushed the gg-sr/fix-generated-files branch from a934c0c to d1fbf2f Compare April 27, 2026 01:54
@gg-sr
gg-sr requested a review from jayconrod April 27, 2026 01:55
@jayconrod

Copy link
Copy Markdown
Collaborator

As mentioned in the other PR, CI is failing because of a misconfiguration on my side: we enabled remote caching, but the secret needed to make that work isn't available on PRs from external contributors.

I've verified tests pass locally, so that's good enough for now.

@jayconrod
jayconrod merged commit 254e465 into EngFlow:main Apr 29, 2026
3 of 16 checks passed
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 this pull request may close these issues.

2 participants