Skip to content

Commit

Permalink
Add option to include runfiles in the select_file search
Browse files Browse the repository at this point in the history
  • Loading branch information
kpark-hrp committed Oct 9, 2023
1 parent 652c8f0 commit 3f238fb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rules/select_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def _impl(ctx):

out = None
canonical = ctx.attr.subpath.replace("\\", "/")
for file_ in ctx.attr.srcs.files.to_list():
files_ = ctx.attr.srcs.files.to_list()
if ctx.attr.include_runfiles:
files_ += ctx.attr.srcs.default_runfiles.files.to_list()
for file_ in files_:
if file_.path.replace("\\", "/").endswith(canonical):
out = file_
break
Expand All @@ -49,5 +52,9 @@ select_file = rule(
mandatory = True,
doc = "Relative path to the file",
),
"include_runfiles": attr.bool(
default=False,
doc = "Whether to include the runfiles in the search",
),
},
)

0 comments on commit 3f238fb

Please sign in to comment.