-
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
Feature request: Allow generated files to be used in repository rules #4069
Comments
TL;DR: I think this is something we might do at some point but it is complex and other projects have priority over it. |
This is very involved. It is unlikely we can get to it before Bazel 1.0 |
It would be lovely to be able to repository_ctx.symlink(repository_ctx.attr.foo, 'foo') where repository_ctx.attr.foo was a pkg_tar target. |
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 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
@bazelbuild/triage Not stale. While this is likely difficult to implement and even difficult to design in the first place, I would consider this worth tracking. |
Description of the problem / feature request / question:
Repository rules can execute various actions, and are generally quite powerful for dealing with resources outside of Bazel and the workspace. However, repository rules are restricted to only using source files from inside the workspace, and cannot use generated files from the workspace. This is implemented via
repository_ctx.path
, the docs for which include: "Note that remote repositories are executed during the analysis phase and thus cannot depends on a target result (the label should point to a non-generated file)."This limitation is frustrating for implementing reliable, consistent repository rules. In many cases, a repository rule needs to execute utilities to download or process external repositories (e.g. maven, gazelle, python). Because repository rules are limited to source files only, authors have to rely on pre-installed executables on the system and/or jump through hoops to use generated files (e.g. executing
go build
directly as rules_go does). That makes the rule's behavior hard to predict, and doesn't allow the rule to take advantage of the build language, cache, or sandbox.Repository rules should be able to execute build steps and use the generated files. The
repository_ctx.path
method should be extended to allow generated files, specified with the usual build rules. Bazel would execute the build steps as needed, so the repository rule would have consistent inputs.Environment info
bazel info release
): 0.7.0 (and many earlier versions)The text was updated successfully, but these errors were encountered: