-
Notifications
You must be signed in to change notification settings - Fork 379
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
fileinfo: fix not detecting 'unix' files to be OS specific #1554
Conversation
358806b
to
1d43efc
Compare
The build file generation logic works like this today: ``` GenerateRules() package.go->*goTarget.addFiles package.go->getPlatformStringsAddFunction() fileinfo.go->isOSArchSpecific() ``` Depending on whether the file has special Go build directives, Gazelle would use a different logic to include/exclude the file into the 'srcs' attribute of the Go targets. In bazel-contrib#1512, we added support for 'unix' build directive but did not tell Gazelle to treat files with 'unix' file as OS specific file. This caused Gazelle to mismatch the OS in a later stage and exclude the needed file instead. Fix that logic and provide some additional tests to reinforce the fileinfo logic. Also added a small knob to print stdout of Gazelle when it's run under go_repository with `debug_mode` attribute set to True. Most Gazelle's logs are printed to stdout and not stderr.
1d43efc
to
01dcee8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the detective work!
👍 This patch is working for my usage - sorry for the fire drill! |
@fmeum could we do a v0.31.1 release with this PR to provide folks with a saner default? The error is pretty hard to track down for newer folks. |
CC @linzhp |
another ping to request for a minor release |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | patch | `v0.31.0` -> `v0.31.1` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>bazelbuild/bazel-gazelle</summary> ### [`v0.31.1`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.31.1) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.31.0...v0.31.1) #### What's Changed - point sync.Once in walkConfig by [@​jmhodges](https://togithub.com/jmhodges) in [https://github.com/bazelbuild/bazel-gazelle/pull/1532](https://togithub.com/bazelbuild/bazel-gazelle/pull/1532) - add copylock vet to nogo by [@​jmhodges](https://togithub.com/jmhodges) in [https://github.com/bazelbuild/bazel-gazelle/pull/1534](https://togithub.com/bazelbuild/bazel-gazelle/pull/1534) - bzlmod: Remove deprecated override attributes on `go_deps.module` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1548](https://togithub.com/bazelbuild/bazel-gazelle/pull/1548) - Add default directives for github.com/envoyproxy/protoc-gen-validate by [@​mortenmj](https://togithub.com/mortenmj) in [https://github.com/bazelbuild/bazel-gazelle/pull/1553](https://togithub.com/bazelbuild/bazel-gazelle/pull/1553) - cmd/gazelle: do not use the epoch as timestamp in diff output by [@​siddharthab](https://togithub.com/siddharthab) in [https://github.com/bazelbuild/bazel-gazelle/pull/1552](https://togithub.com/bazelbuild/bazel-gazelle/pull/1552) - fileinfo: fix not detecting 'unix' files to be OS specific by [@​sluongng](https://togithub.com/sluongng) in [https://github.com/bazelbuild/bazel-gazelle/pull/1554](https://togithub.com/bazelbuild/bazel-gazelle/pull/1554) - language/go: Emit apparent repo name of rules_go in select keys by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1555](https://togithub.com/bazelbuild/bazel-gazelle/pull/1555) - Let `bazel_dep`s replace Go deps by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1526](https://togithub.com/bazelbuild/bazel-gazelle/pull/1526) #### New Contributors - [@​mortenmj](https://togithub.com/mortenmj) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1553](https://togithub.com/bazelbuild/bazel-gazelle/pull/1553) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.31.0...v0.31.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/kreempuff/rules_unreal_engine). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTAuMCIsInVwZGF0ZWRJblZlciI6IjM1LjExMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | patch | `v0.31.0` -> `v0.31.1` | --- ### Release Notes <details> <summary>bazelbuild/bazel-gazelle</summary> ### [`v0.31.1`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.31.1) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.31.0...v0.31.1) #### What's Changed - point sync.Once in walkConfig by [@​jmhodges](https://togithub.com/jmhodges) in [https://github.com/bazelbuild/bazel-gazelle/pull/1532](https://togithub.com/bazelbuild/bazel-gazelle/pull/1532) - add copylock vet to nogo by [@​jmhodges](https://togithub.com/jmhodges) in [https://github.com/bazelbuild/bazel-gazelle/pull/1534](https://togithub.com/bazelbuild/bazel-gazelle/pull/1534) - bzlmod: Remove deprecated override attributes on `go_deps.module` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1548](https://togithub.com/bazelbuild/bazel-gazelle/pull/1548) - Add default directives for github.com/envoyproxy/protoc-gen-validate by [@​mortenmj](https://togithub.com/mortenmj) in [https://github.com/bazelbuild/bazel-gazelle/pull/1553](https://togithub.com/bazelbuild/bazel-gazelle/pull/1553) - cmd/gazelle: do not use the epoch as timestamp in diff output by [@​siddharthab](https://togithub.com/siddharthab) in [https://github.com/bazelbuild/bazel-gazelle/pull/1552](https://togithub.com/bazelbuild/bazel-gazelle/pull/1552) - fileinfo: fix not detecting 'unix' files to be OS specific by [@​sluongng](https://togithub.com/sluongng) in [https://github.com/bazelbuild/bazel-gazelle/pull/1554](https://togithub.com/bazelbuild/bazel-gazelle/pull/1554) - language/go: Emit apparent repo name of rules_go in select keys by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1555](https://togithub.com/bazelbuild/bazel-gazelle/pull/1555) - Let `bazel_dep`s replace Go deps by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1526](https://togithub.com/bazelbuild/bazel-gazelle/pull/1526) #### New Contributors - [@​mortenmj](https://togithub.com/mortenmj) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1553](https://togithub.com/bazelbuild/bazel-gazelle/pull/1553) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.31.0...v0.31.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/cgrindel/rules_swift_package_manager). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTAuMCIsInVwZGF0ZWRJblZlciI6IjM1LjExMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | patch | `v0.31.0` -> `v0.31.1` | --- ### Release Notes <details> <summary>bazelbuild/bazel-gazelle</summary> ### [`v0.31.1`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.31.1) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.31.0...v0.31.1) #### What's Changed - point sync.Once in walkConfig by [@​jmhodges](https://togithub.com/jmhodges) in [https://github.com/bazelbuild/bazel-gazelle/pull/1532](https://togithub.com/bazelbuild/bazel-gazelle/pull/1532) - add copylock vet to nogo by [@​jmhodges](https://togithub.com/jmhodges) in [https://github.com/bazelbuild/bazel-gazelle/pull/1534](https://togithub.com/bazelbuild/bazel-gazelle/pull/1534) - bzlmod: Remove deprecated override attributes on `go_deps.module` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1548](https://togithub.com/bazelbuild/bazel-gazelle/pull/1548) - Add default directives for github.com/envoyproxy/protoc-gen-validate by [@​mortenmj](https://togithub.com/mortenmj) in [https://github.com/bazelbuild/bazel-gazelle/pull/1553](https://togithub.com/bazelbuild/bazel-gazelle/pull/1553) - cmd/gazelle: do not use the epoch as timestamp in diff output by [@​siddharthab](https://togithub.com/siddharthab) in [https://github.com/bazelbuild/bazel-gazelle/pull/1552](https://togithub.com/bazelbuild/bazel-gazelle/pull/1552) - fileinfo: fix not detecting 'unix' files to be OS specific by [@​sluongng](https://togithub.com/sluongng) in [https://github.com/bazelbuild/bazel-gazelle/pull/1554](https://togithub.com/bazelbuild/bazel-gazelle/pull/1554) - language/go: Emit apparent repo name of rules_go in select keys by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1555](https://togithub.com/bazelbuild/bazel-gazelle/pull/1555) - Let `bazel_dep`s replace Go deps by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1526](https://togithub.com/bazelbuild/bazel-gazelle/pull/1526) #### New Contributors - [@​mortenmj](https://togithub.com/mortenmj) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1553](https://togithub.com/bazelbuild/bazel-gazelle/pull/1553) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.31.0...v0.31.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/cgrindel/bazel-starlib). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMTAuMCIsInVwZGF0ZWRJblZlciI6IjM1LjExMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
The build file generation logic works like this today:
Depending on whether the file has special Go build directives, Gazelle
would use a different logic to include/exclude the file into the 'srcs'
attribute of the Go targets.
In #1512, we added support for 'unix' build directive but did not tell
Gazelle to treat files with 'unix' file as OS specific file. This caused
Gazelle to mismatch the OS in a later stage and exclude the needed file
instead.
Fix that logic and provide some additional tests to reinforce the
fileinfo logic.
Also added a small knob to print stdout of Gazelle when it's run under
go_repository with
debug_mode
attribute set to True. Most Gazelle'slogs are printed to stdout and not stderr.
What type of PR is this?
Bug fix
What package or component does this PR mostly affect?
language/go
go_repository
What does this PR do? Why is it needed?
Which issues(s) does this PR fix?
Replaces #1551
Fix #1512
Other notes for review