-
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
Runfiles should include aliases under the aliased label #18477
Comments
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
Runfiles manifest entries are for files (potentially multiple per target) and the runfiles returned by a single rule may come from various different on-disk directories, whereas aliases operate on the target level. I don't see what "referencing the alias label" would mean in this context. |
I believe the idea is you have outputs that are declared relative to some source target, and you want to re-root them relative to the alias target. For example:
If you have a runtime dependency on this target, then you can retrieve the file using a runfiles library by looking up e.g. rlocation("some/source/path/libfoo.a") If you aliased this target as e.g.
I think the desired behavior would be to re-root those outputs by changing the package prefix of the actual target to that of the alias. E.g. with the above alias you'd be able to lookup A potential use case that made me subscribe to this issue was really around using aliases to select over the same output for multiple platforms, and then hoping to unify the path at runtime. E.g. imagine if we have two http_archive repos that download a tool, one for linux (
It'd be nice to be able to query a runfiles library with "path/to/alias/tool" to get the tool path, rather than have to have the binary itself e.g. conditionally compiled to lookup This also makes sense in the way that a common use of alias is to provide a stable target path while the actual target is moved around. This works for targets in build land, but not for files in runtime land. |
Since Have you considered making your own custom rule that picks out the executable and symlinks it under its own package's output directory via With the ability to ask for all Starlark providers to be forwarded unchanged, which has been asked for in other issues, that could even gain parity with |
I added my own custom For posterity, I ended up doing something like: def _alias_executable_impl(ctx):
output = ctx.actions.declare_file(ctx.attr.name)
ctx.actions.symlink(output = output, target_file = ctx.executable.actual)
return [DefaultInfo(files = depset([output]), executable = output)]
alias_executable = rule(
implementation = _alias_executable_impl,
executable = True,
attrs = {
"actual": attr.label(
allow_files = True,
executable = True,
cfg = "target",
),
},
) Thanks for the guidance! |
If I have a target which depends on a label, the runfiles should reference that label, regardless of whether it is an alias (of any depth). However, the current code in
SourceManifestAction.writeEntry
only sees the list of artifacts with the actual underlying paths, and has lost the original aliased label.See katre@afe4d9d for a test demonstrating the issue.
The text was updated successfully, but these errors were encountered: