Skip to content
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

Open
kevingessner opened this issue Nov 10, 2017 · 5 comments
Open
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request

Comments

@kevingessner
Copy link
Contributor

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 version (output of bazel info release): 0.7.0 (and many earlier versions)
@damienmg damienmg added category: extensibility > external repositories P2 We'll consider working on this in future. (Assignee optional) type: feature request labels Nov 11, 2017
@damienmg
Copy link
Contributor

TL;DR: I think this is something we might do at some point but it is complex and other projects have priority over it.

@dslomov dslomov added P3 We're not considering working on this, but happy to review a PR. (No assignee) external-repos-triaged and removed P2 We'll consider working on this in future. (Assignee optional) labels Jan 9, 2018
@dslomov
Copy link
Contributor

dslomov commented Jan 9, 2018

This is very involved. It is unlikely we can get to it before Bazel 1.0

@dslomov dslomov added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. and removed category: extensibility > external repositories labels Mar 21, 2019
@ccate
Copy link

ccate commented Jan 16, 2020

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.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@github-actions
Copy link

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) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label May 24, 2023
@fmeum
Copy link
Collaborator

fmeum commented May 24, 2023

@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.

@sgowroji sgowroji added not stale Issues or PRs that are inactive but not considered stale and removed stale Issues or PRs that are stale (no activity for 30 days) labels May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: feature request
Projects
None yet
Development

No branches or pull requests

7 participants