-
Notifications
You must be signed in to change notification settings - Fork 393
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
Support macros/rules packed within bazel struct
#1524
Merged
Merged
+113
−11
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c2b442a
to
188f5f9
Compare
fmeum
reviewed
May 9, 2023
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.
This looks solid, just left a single comment.
This change adds test for handling macros/rules which are packed into the struct e.g.: `selects.config_setting_group`
Bazel allows to pack rules or macros within a struct, e.g. convenience interfaces for `select()` (see https://github.com/bazelbuild/bazel-skylib/blob/main/lib/selects.bzl) Currently Gazelle is not able to recognize of rules which consist of: `struct_name.rule_name` e.g. `selects.config_setting_group`. When such rule is present inside BUILD.bazel file, parsing is not able to recognize it and is simply ignored like it was never present. Thus merging mechanizm won't work for it and duplicated rule will be created (assuming thus rule was creaded before). All above highly prevents of using and creating such rules like `selects.config_setting_group`. This change adds support for recognizing macros packed within struct correctly.
fmeum
approved these changes
May 11, 2023
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.
This looks solid, just left a single comment.
renovate bot
referenced
this pull request
in kreempuff/rules_unreal_engine
May 27, 2023
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | minor | `v0.30.0` -> `v0.31.0` | --- ### ⚠ 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.0`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.31.0) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.30.0...v0.31.0) #### What's Changed - feat: allow passing GIT_CONFIG_COUNT and it's related configs by [@​manuelnaranjo](https://togithub.com/manuelnaranjo) in [https://github.com/bazelbuild/bazel-gazelle/pull/1462](https://togithub.com/bazelbuild/bazel-gazelle/pull/1462) - feat(bzlmod): add `module_override` tag to allow patching in go_deps by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1500](https://togithub.com/bazelbuild/bazel-gazelle/pull/1500) - fix typo `build_proto_file_mode` in message by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1504](https://togithub.com/bazelbuild/bazel-gazelle/pull/1504) - fix: support running within a dir named workspace by [@​jbedard](https://togithub.com/jbedard) in [https://github.com/bazelbuild/bazel-gazelle/pull/1498](https://togithub.com/bazelbuild/bazel-gazelle/pull/1498) - fix: check for gazelle command before adding -repo_config flag by [@​cgrindel](https://togithub.com/cgrindel) in [https://github.com/bazelbuild/bazel-gazelle/pull/1501](https://togithub.com/bazelbuild/bazel-gazelle/pull/1501) - language/go: Infer prefix from go.mod by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1497](https://togithub.com/bazelbuild/bazel-gazelle/pull/1497) - don't overwrite directives by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1503](https://togithub.com/bazelbuild/bazel-gazelle/pull/1503) - Support Bzlmod for gazelle itself by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1509](https://togithub.com/bazelbuild/bazel-gazelle/pull/1509) - language/go: Add windows arm64 as a known platform. by [@​connyay](https://togithub.com/connyay) in [https://github.com/bazelbuild/bazel-gazelle/pull/1507](https://togithub.com/bazelbuild/bazel-gazelle/pull/1507) - Adding lifecycle manager by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1475](https://togithub.com/bazelbuild/bazel-gazelle/pull/1475) - Disable protobuf generation for more modules by [@​seh](https://togithub.com/seh) in [https://github.com/bazelbuild/bazel-gazelle/pull/1514](https://togithub.com/bazelbuild/bazel-gazelle/pull/1514) - Support '~' in label repo by [@​mark-thm](https://togithub.com/mark-thm) in [https://github.com/bazelbuild/bazel-gazelle/pull/1518](https://togithub.com/bazelbuild/bazel-gazelle/pull/1518) - language/go: Handle `unix` build tag. by [@​connyay](https://togithub.com/connyay) in [https://github.com/bazelbuild/bazel-gazelle/pull/1512](https://togithub.com/bazelbuild/bazel-gazelle/pull/1512) - Pass data arg through to sh_binary if defined by [@​Preston4tw](https://togithub.com/Preston4tw) in [https://github.com/bazelbuild/bazel-gazelle/pull/1483](https://togithub.com/bazelbuild/bazel-gazelle/pull/1483) - remove circular override hack by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1515](https://togithub.com/bazelbuild/bazel-gazelle/pull/1515) - Add major version suffix download example by [@​kriswuollett](https://togithub.com/kriswuollett) in [https://github.com/bazelbuild/bazel-gazelle/pull/1453](https://togithub.com/bazelbuild/bazel-gazelle/pull/1453) - Relax parsing of labels by [@​purkhusid](https://togithub.com/purkhusid) in [https://github.com/bazelbuild/bazel-gazelle/pull/1508](https://togithub.com/bazelbuild/bazel-gazelle/pull/1508) - bzlmod: Add `build_file_generation` to `gazelle_override` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1522](https://togithub.com/bazelbuild/bazel-gazelle/pull/1522) - Fix incremental build of to bootstrap Gazelle by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1529](https://togithub.com/bazelbuild/bazel-gazelle/pull/1529) - Support macros/rules packed within bazel `struct` by [@​birunts](https://togithub.com/birunts) in [https://github.com/bazelbuild/bazel-gazelle/pull/1524](https://togithub.com/bazelbuild/bazel-gazelle/pull/1524) - Prefer non-proto over proto deps in external repos by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1537](https://togithub.com/bazelbuild/bazel-gazelle/pull/1537) - bzlmod: Return `extension_metadata` to automate `use_repo` fixes by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1511](https://togithub.com/bazelbuild/bazel-gazelle/pull/1511) - Fix `go:embed` failing to add `embedsrcs` for subdirectories named build by [@​sgavinio](https://togithub.com/sgavinio) in [https://github.com/bazelbuild/bazel-gazelle/pull/1539](https://togithub.com/bazelbuild/bazel-gazelle/pull/1539) - Remove support for godep and dep by [@​sluongng](https://togithub.com/sluongng) in [https://github.com/bazelbuild/bazel-gazelle/pull/1541](https://togithub.com/bazelbuild/bazel-gazelle/pull/1541) - Avoid putting -repo_config after directories by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1544](https://togithub.com/bazelbuild/bazel-gazelle/pull/1544) - Dropping -args by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1546](https://togithub.com/bazelbuild/bazel-gazelle/pull/1546) #### New Contributors - [@​connyay](https://togithub.com/connyay) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1507](https://togithub.com/bazelbuild/bazel-gazelle/pull/1507) - [@​mark-thm](https://togithub.com/mark-thm) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1518](https://togithub.com/bazelbuild/bazel-gazelle/pull/1518) - [@​Preston4tw](https://togithub.com/Preston4tw) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1483](https://togithub.com/bazelbuild/bazel-gazelle/pull/1483) - [@​kriswuollett](https://togithub.com/kriswuollett) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1453](https://togithub.com/bazelbuild/bazel-gazelle/pull/1453) - [@​purkhusid](https://togithub.com/purkhusid) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1508](https://togithub.com/bazelbuild/bazel-gazelle/pull/1508) - [@​birunts](https://togithub.com/birunts) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1524](https://togithub.com/bazelbuild/bazel-gazelle/pull/1524) - [@​sgavinio](https://togithub.com/sgavinio) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1539](https://togithub.com/bazelbuild/bazel-gazelle/pull/1539) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.30.0...v0.31.0 </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:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMDIuNCIsInVwZGF0ZWRJblZlciI6IjM1LjEwMi40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
renovate bot
referenced
this pull request
in cgrindel/bazel-starlib
May 27, 2023
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [bazel_gazelle](https://togithub.com/bazelbuild/bazel-gazelle) | http_archive | minor | `v0.30.0` -> `v0.31.0` | --- ### Release Notes <details> <summary>bazelbuild/bazel-gazelle</summary> ### [`v0.31.0`](https://togithub.com/bazelbuild/bazel-gazelle/releases/tag/v0.31.0) [Compare Source](https://togithub.com/bazelbuild/bazel-gazelle/compare/v0.30.0...v0.31.0) #### What's Changed - feat: allow passing GIT_CONFIG_COUNT and it's related configs by [@​manuelnaranjo](https://togithub.com/manuelnaranjo) in [https://github.com/bazelbuild/bazel-gazelle/pull/1462](https://togithub.com/bazelbuild/bazel-gazelle/pull/1462) - feat(bzlmod): add `module_override` tag to allow patching in go_deps by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1500](https://togithub.com/bazelbuild/bazel-gazelle/pull/1500) - fix typo `build_proto_file_mode` in message by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1504](https://togithub.com/bazelbuild/bazel-gazelle/pull/1504) - fix: support running within a dir named workspace by [@​jbedard](https://togithub.com/jbedard) in [https://github.com/bazelbuild/bazel-gazelle/pull/1498](https://togithub.com/bazelbuild/bazel-gazelle/pull/1498) - fix: check for gazelle command before adding -repo_config flag by [@​cgrindel](https://togithub.com/cgrindel) in [https://github.com/bazelbuild/bazel-gazelle/pull/1501](https://togithub.com/bazelbuild/bazel-gazelle/pull/1501) - language/go: Infer prefix from go.mod by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1497](https://togithub.com/bazelbuild/bazel-gazelle/pull/1497) - don't overwrite directives by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1503](https://togithub.com/bazelbuild/bazel-gazelle/pull/1503) - Support Bzlmod for gazelle itself by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1509](https://togithub.com/bazelbuild/bazel-gazelle/pull/1509) - language/go: Add windows arm64 as a known platform. by [@​connyay](https://togithub.com/connyay) in [https://github.com/bazelbuild/bazel-gazelle/pull/1507](https://togithub.com/bazelbuild/bazel-gazelle/pull/1507) - Adding lifecycle manager by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1475](https://togithub.com/bazelbuild/bazel-gazelle/pull/1475) - Disable protobuf generation for more modules by [@​seh](https://togithub.com/seh) in [https://github.com/bazelbuild/bazel-gazelle/pull/1514](https://togithub.com/bazelbuild/bazel-gazelle/pull/1514) - Support '~' in label repo by [@​mark-thm](https://togithub.com/mark-thm) in [https://github.com/bazelbuild/bazel-gazelle/pull/1518](https://togithub.com/bazelbuild/bazel-gazelle/pull/1518) - language/go: Handle `unix` build tag. by [@​connyay](https://togithub.com/connyay) in [https://github.com/bazelbuild/bazel-gazelle/pull/1512](https://togithub.com/bazelbuild/bazel-gazelle/pull/1512) - Pass data arg through to sh_binary if defined by [@​Preston4tw](https://togithub.com/Preston4tw) in [https://github.com/bazelbuild/bazel-gazelle/pull/1483](https://togithub.com/bazelbuild/bazel-gazelle/pull/1483) - remove circular override hack by [@​tyler-french](https://togithub.com/tyler-french) in [https://github.com/bazelbuild/bazel-gazelle/pull/1515](https://togithub.com/bazelbuild/bazel-gazelle/pull/1515) - Add major version suffix download example by [@​kriswuollett](https://togithub.com/kriswuollett) in [https://github.com/bazelbuild/bazel-gazelle/pull/1453](https://togithub.com/bazelbuild/bazel-gazelle/pull/1453) - Relax parsing of labels by [@​purkhusid](https://togithub.com/purkhusid) in [https://github.com/bazelbuild/bazel-gazelle/pull/1508](https://togithub.com/bazelbuild/bazel-gazelle/pull/1508) - bzlmod: Add `build_file_generation` to `gazelle_override` by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1522](https://togithub.com/bazelbuild/bazel-gazelle/pull/1522) - Fix incremental build of to bootstrap Gazelle by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1529](https://togithub.com/bazelbuild/bazel-gazelle/pull/1529) - Support macros/rules packed within bazel `struct` by [@​birunts](https://togithub.com/birunts) in [https://github.com/bazelbuild/bazel-gazelle/pull/1524](https://togithub.com/bazelbuild/bazel-gazelle/pull/1524) - Prefer non-proto over proto deps in external repos by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1537](https://togithub.com/bazelbuild/bazel-gazelle/pull/1537) - bzlmod: Return `extension_metadata` to automate `use_repo` fixes by [@​fmeum](https://togithub.com/fmeum) in [https://github.com/bazelbuild/bazel-gazelle/pull/1511](https://togithub.com/bazelbuild/bazel-gazelle/pull/1511) - Fix `go:embed` failing to add `embedsrcs` for subdirectories named build by [@​sgavinio](https://togithub.com/sgavinio) in [https://github.com/bazelbuild/bazel-gazelle/pull/1539](https://togithub.com/bazelbuild/bazel-gazelle/pull/1539) - Remove support for godep and dep by [@​sluongng](https://togithub.com/sluongng) in [https://github.com/bazelbuild/bazel-gazelle/pull/1541](https://togithub.com/bazelbuild/bazel-gazelle/pull/1541) - Avoid putting -repo_config after directories by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1544](https://togithub.com/bazelbuild/bazel-gazelle/pull/1544) - Dropping -args by [@​linzhp](https://togithub.com/linzhp) in [https://github.com/bazelbuild/bazel-gazelle/pull/1546](https://togithub.com/bazelbuild/bazel-gazelle/pull/1546) #### New Contributors - [@​connyay](https://togithub.com/connyay) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1507](https://togithub.com/bazelbuild/bazel-gazelle/pull/1507) - [@​mark-thm](https://togithub.com/mark-thm) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1518](https://togithub.com/bazelbuild/bazel-gazelle/pull/1518) - [@​Preston4tw](https://togithub.com/Preston4tw) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1483](https://togithub.com/bazelbuild/bazel-gazelle/pull/1483) - [@​kriswuollett](https://togithub.com/kriswuollett) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1453](https://togithub.com/bazelbuild/bazel-gazelle/pull/1453) - [@​purkhusid](https://togithub.com/purkhusid) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1508](https://togithub.com/bazelbuild/bazel-gazelle/pull/1508) - [@​birunts](https://togithub.com/birunts) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1524](https://togithub.com/bazelbuild/bazel-gazelle/pull/1524) - [@​sgavinio](https://togithub.com/sgavinio) made their first contribution in [https://github.com/bazelbuild/bazel-gazelle/pull/1539](https://togithub.com/bazelbuild/bazel-gazelle/pull/1539) **Full Changelog**: bazel-contrib/bazel-gazelle@v0.30.0...v0.31.0 </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:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMDIuNCIsInVwZGF0ZWRJblZlciI6IjM1LjEwMi40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Feature
What package or component does this PR mostly affect?
cmd/gazelle
What does this PR do? Why is it needed?
Bazel allows to pack rules or macros within a struct, e.g. convenience interfaces for
select()
(see https://github.com/bazelbuild/bazel-skylib/blob/main/lib/selects.bzl)
Changes adds support for macros/rules packed within bazel struct.
Load statements are not able to insert struct symbols. This is needed in case some macros are packaged into a struct like
selects.config_setting_group
(see https://github.com/bazelbuild/bazel-skylib/blob/main/lib/selects.bzl#L245).
Any would like to generate
selects.config_setting_group
rule withrule.LoadInfo
:needs a load statement in
BUILD.bazel
of:but NOT
Which issues(s) does this PR fix?
Fixes #1523
Other notes for review