-
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
Find runfiles in directories that are themselves runfiles #14335
Conversation
@mai93 Would you be able to take a look? You reviewed and worked on the last fixes to the runfiles libraries. |
@meteorcloudy Could you review this PR in case @mai93 is busy? |
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.
Thanks for fixing this use case!
b79a5f0
to
d18c4ee
Compare
tools/cpp/runfiles/runfiles_src.cc
Outdated
@@ -48,6 +49,12 @@ using std::vector; | |||
|
|||
namespace { | |||
|
|||
#ifdef _WIN32 |
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.
Do we still need this if we always use /
?
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.
Yes, I got rid of it.
d18c4ee
to
7d6de06
Compare
@meteorcloudy I pushed the fixes, thanks for the comments. Would it be okay to leave bash for a follow-up PR? I'm not too familiar with shell scripts and would probably need more time to fix the lookup logic there. |
67a6c85
to
c6cea90
Compare
I gave the Bash implementation a try and it wasn't that bad. This PR now includes fixes for all runfiles libraries shipped with Bazel. Let me know if you would prefer me to squash the four commits in case you want to import them together. |
tools/bash/runfiles/runfiles.bash
Outdated
echo "$candidate" | ||
return 0 | ||
fi | ||
# There is only ever one matching prefix in the runfiles manifest. |
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.
Shouldn't this break
statement be inside the if statement?
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 actually think it's correct as is, but agree this is confusing and thus added an extensive comment. Let me know what you think.
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.
Thanks! I missed the continue statement in the middle and thought the while loop would never run a second time. Thanks for the explanation!
c6cea90
to
2c004f4
Compare
I squashed the commits and added a descriptive message. |
When a target has a runfile that is contained in a directory that is itself one of its runfiles, the runfile will be shadowed by the SymlinkEntry for the directory. While this still allows to resolve the file in the runfiles symlink tree, a manifest-based lookup will fail. Since the manifest is used to create the symlink tree for which it is important that no path is a prefix of another, this can only be fixed in the runfiles libraries. This commit extends the lookup logic of the Bash, C++, Java, and Python runfiles libraries to also find runfiles contained within directories that are themselves runfiles. It does so by searching the manifest not only for the exact provided rlocation path, but also for all path prefixes. If a prefix is looked up successfully, the corresponding suffix is resolved relative to the looked up path.
2c004f4
to
2b91de0
Compare
When a target has a runfile that is contained in a directory that is itself one of its runfiles, the runfile will be shadowed by the `SymlinkEntry` for the directory. While this still allows to resolve the file in the runfiles symlink tree, a manifest-based lookup will fail. Since the manifest is used to create the symlink tree for which it is important that no path is a prefix of another, this can only be fixed in the runfiles libraries. This PR extends the lookup logic of the Bash, C++, Java, and Python runfiles libraries to also find runfiles contained within directories that are themselves runfiles. It does so by searching the manifest not only for the exact provided rlocation path, but also for all path prefixes. If a prefix is looked up successfully, the corresponding suffix is resolved relative to the looked up path. Fixes bazelbuild#14336. Closes bazelbuild#14335. PiperOrigin-RevId: 426894517
When a target has a runfile that is contained in a directory that is itself one of its runfiles, the runfile will be shadowed by the `SymlinkEntry` for the directory. While this still allows to resolve the file in the runfiles symlink tree, a manifest-based lookup will fail. Since the manifest is used to create the symlink tree for which it is important that no path is a prefix of another, this can only be fixed in the runfiles libraries. This PR extends the lookup logic of the Bash, C++, Java, and Python runfiles libraries to also find runfiles contained within directories that are themselves runfiles. It does so by searching the manifest not only for the exact provided rlocation path, but also for all path prefixes. If a prefix is looked up successfully, the corresponding suffix is resolved relative to the looked up path. Fixes #14336. Closes #14335. PiperOrigin-RevId: 426894517
When a target has a runfile that is contained in a directory that is itself one of its runfiles, the runfile will be shadowed by the
SymlinkEntry
for the directory. While this still allows to resolve the file in the runfiles symlink tree, a manifest-based lookup will fail. Since the manifest is used to create the symlink tree for which it is important that no path is a prefix of another, this can only be fixed in the runfiles libraries.This PR extends the lookup logic of the Bash, C++, Java, and Python runfiles libraries to also find runfiles contained within directories that are themselves runfiles. It does so by searching the manifest not only for the exact provided rlocation path, but also for all path prefixes. If a prefix is looked up successfully, the corresponding suffix is resolved relative to the looked up path.
Fixes #14336.