Replace go_name_hack with a usage of Label#3035
Merged
achew22 merged 1 commit intobazel-contrib:masterfrom Dec 28, 2021
Merged
Conversation
b26e0a8 to
c536218
Compare
c536218 to
be988df
Compare
Member
Author
|
@robfig Would you be interested in getting rules_go into the Bazel Central Registry as a Bazel module? I could work on it using only patches at first, but of course would prefer to upstream (backwards compatible) changes at some point. This is one of them which I found to be generally useful. |
achew22
suggested changes
Dec 20, 2021
go/private/rules/transition.bzl
Outdated
| return label[len("@io_bazel_rules_go"):] | ||
| else: | ||
| if label.startswith("//command_line_option:"): | ||
| # This is a special label used to refer to Bazel command-line options in |
Member
There was a problem hiding this comment.
Can you add a note about why are these special and when it could be removed? My experience is that hacks like this get put in place and I forget to write down the condition where it can be removed safely so I carry forward scar tissue.
Member
Author
There was a problem hiding this comment.
Good point, I expanded the comment. Could you give it another read?
The Label constructor can be used to transform a label string such as
@io_bazel_rules_go//foo:bar into the canonical label referencing this
target from the repository in which it is called.
For example, `str(Label("@io_bazel_rules_go//foo:bar"))` returns
`"@io_bazel_rules_go//foo:bar"` if rules_go is used as an external
repository from another main workspace, but returns `"//foo:bar"` when
rules_go is the main repository (e.g., when running the tests in the
CI).
This requires raising the minimum version of Bazel from 4.2.0 to 4.2.1
due to bazelbuild/bazel#13890.
be988df to
4f0fcbd
Compare
Member
|
Thanks @fmeum! |
This was referenced Jan 18, 2022
This file contains hidden or 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
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?
Other
What does this PR do? Why is it needed?
The Label constructor can be used to transform a label string such as @io_bazel_rules_go//foo:bar into the canonical label referencing this target from the repository in which it is called.
For example,
str(Label("@io_bazel_rules_go//foo:bar"))returns"@io_bazel_rules_go//foo:bar"if rules_go is used as an external repository from another main workspace, but returns"//foo:bar"when rules_go is the main repository (e.g., when running the tests in the CI).Which issues(s) does this PR fix?
It doesn't resolve a bug, but simplifies the rules_go repository setup. This simplification will be especially useful when converting
rules_goto a Bazel module in the future.Other notes for review