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

Glob for Repository Rules #16887

Open
cpsauer opened this issue Nov 30, 2022 · 3 comments
Open

Glob for Repository Rules #16887

cpsauer opened this issue Nov 30, 2022 · 3 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request

Comments

@cpsauer
Copy link
Contributor

cpsauer commented Nov 30, 2022

Hi wonderful Bazelers,

Description of the feature request:

It'd be handy if there were a glob function on repository_ctx and/or path--similar semantically to the glob functions otherwise, but runnable in repository rules and returning paths.

What underlying problem are you trying to solve with this feature?

As in BUILD files, glob is often ergonomically nice and encourages simple code, especially because of the prohibition on recursion. The path API does exist, as does the ability to exec arbitrary programs, but I'm filing this because I'd seen a couple places in a row where more complex code was written (in the recently released Blaze ndk rules, for example) because this didn't exist.

Thanks!
Chris
(ex-Googler)

@sgowroji sgowroji added team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request untriaged labels Nov 30, 2022
@comius
Copy link
Contributor

comius commented Jan 16, 2023

cc @meteorcloudy @Wyverald

glob is a rather complex function, and I don't see it immediately how it would work with repository rules. Also wouldn't like to make repository rules over complex.

I think that repository rules should be whenever possible avoided in favour of producing "pure" bzlmod modules.

Extending repository rules with a function that does dir listing might be a better option if the uses are really that complex.
@cpsauer would you mind providing some links to the complex code you're referring to?

P4 for now, possibly P3 if we come up with a viable design.

@comius comius added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged labels Jan 16, 2023
@mvgijssel
Copy link

I’m also interested in this to be able to do Bazel integration testing, globing all files inside a directory using a repository rule and using that workspace to run tests in using Bazel itself.

@mvgijssel
Copy link

And now a second use case came up for building a docker image using a Docker file and wanting to glob all the files necessary for the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants