bazel-skylib icon indicating copy to clipboard operation
bazel-skylib copied to clipboard

Search runfiles in `select_file` rule

Open kpark-hrp opened this issue 2 years ago • 1 comments
trafficstars

select_file rule currently only searches within DefaultInfo.files.

I was wondering if we can add an argument to select_file to optionally expand the search criteria to include DefaultInfo.default_runfiles

It would look something like this.

select_file(
    name = "selected",
    srcs = ":files",
    subpath = "foo/bar.py",
    include_runfiles = True,
)

kpark-hrp avatar Oct 09 '23 17:10 kpark-hrp

This is an antipattern, because it's flattening a potentially large depset in order to search for a file. Skylib should not support such antipatterns or suggest people use them.

What to do instead? It's hard to suggest alternative without a specific example at hand.

comius avatar Oct 31 '23 07:10 comius