-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Make the attr new_local_repository.build_file
label-typed
#19992
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,25 @@ if "$is_windows"; then | |
export MSYS2_ARG_CONV_EXCL="*" | ||
fi | ||
|
||
function test_build_file_label_repo_mapping() { | ||
mkdir subdir | ||
cat > WORKSPACE <<'eof' | ||
workspace(name='myws') | ||
# add a `load` to force a new workspace chunk, adding "myws" to the mapping | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx, makes total sense :) |
||
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') | ||
Wyverald marked this conversation as resolved.
Show resolved
Hide resolved
|
||
new_local_repository( | ||
name = "heh", | ||
path = "subdir", | ||
build_file = "@myws//:thing", | ||
) | ||
eof | ||
touch BUILD | ||
echo 'filegroup(name="a-ma-bob")' > thing | ||
write_default_lockfile MODULE.bazel.lock | ||
|
||
bazel build @heh//:a-ma-bob &> $TEST_log || fail "don't fail!" | ||
} | ||
|
||
# Regression test for GitHub issue #6351, see | ||
# https://github.com/bazelbuild/bazel/issues/6351#issuecomment-465488344 | ||
function test_glob_in_synthesized_build_file() { | ||
|
@@ -127,9 +146,10 @@ function test_recursive_glob_in_new_local_repository() { | |
new_local_repository( | ||
name = "myext", | ||
path = "../B", | ||
build_file = "BUILD.myext", | ||
build_file = "//:BUILD.myext", | ||
) | ||
eof | ||
touch "$pkg/A/BUILD.bazel" | ||
cat >"$pkg/A/BUILD.myext" <<eof | ||
filegroup(name = "all_files", srcs = glob(["**"])) | ||
eof | ||
|
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
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.
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.
Why not
WorkspaceAttributeMapper.of(rule).get("build_file", Type.NODEP_LABEL)
?That seems to be the canonical way to access attributes in the (few) native implementations of workspace rules.
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.
I honestly don't think that class needs to exist. Maybe it did at one point but right now it just doesn't do anything. (One extra reason is that WAM.get throws an EvalException which is annoying...)
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.
At least you get a more reasonable exception than
ClassCastException
if you do this. I won't insist, though, it's not a big difference.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.
thing is, you won't get an exception at all; it's impossible for a label-typed attribute to have a non-label value.