bazelbuild / bazel-skylib

Common useful functions and rules for Bazel
https://bazel.build/
Apache License 2.0
391 stars 178 forks source link

Search runfiles in `select_file` rule #466

Open kpark-hrp opened 12 months ago

kpark-hrp commented 12 months ago

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,
)
comius commented 11 months ago

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.