Skip to content

Commit 4692ae4

Browse files
aherrmannmergify-bot
authored and
mergify-bot
committed
Add data runfiles for haskell_repl data attr
#1381 added a dedicated `data` attribute to `haskell_repl` which needs to be tracked correctly when data runfiles are constructed explicitly.
1 parent fdd0121 commit 4692ae4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

haskell/repl.bzl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ def _merge_runfiles(runfiles_list):
9797
result = result.merge(runfiles)
9898
return result
9999

100+
def _data_runfiles(ctx, rule, attr):
101+
"""Generate runfiles for a data attribute.
102+
103+
Attrs:
104+
ctx: The rule context.
105+
rule: The rule object, `ctx` for a rule, `ctx.rule` for an aspect.
106+
attr: The attribute name of the data attribute.
107+
108+
Returns:
109+
A runfiles object capturing data files and data runfiles.
110+
"""
111+
return _merge_runfiles(
112+
[ctx.runfiles(files = getattr(rule.files, attr, []))] +
113+
[data[DefaultInfo].default_runfiles for data in getattr(rule.attr, attr, [])],
114+
)
115+
100116
def _merge_HaskellReplLoadInfo(load_infos):
101117
source_files = depset()
102118
import_dirs = depset()
@@ -173,10 +189,7 @@ def _create_HaskellReplCollectInfo(target, ctx):
173189
]),
174190
compiler_flags = hs_info.user_compile_flags,
175191
repl_ghci_args = hs_info.user_repl_flags,
176-
data_runfiles = _merge_runfiles(
177-
[ctx.runfiles(files = getattr(ctx.rule.files, "data", []))] +
178-
[data[DefaultInfo].default_runfiles for data in getattr(ctx.rule.attr, "data", [])],
179-
),
192+
data_runfiles = _data_runfiles(ctx, ctx.rule, "data"),
180193
)
181194
if HaskellLibraryInfo in target:
182195
lib_info = target[HaskellLibraryInfo]
@@ -425,6 +438,7 @@ def _create_repl(hs, posix, ctx, repl_info, output):
425438
if ctx.attr.collect_data:
426439
runfiles.append(repl_info.load_info.data_runfiles)
427440
runfiles.append(repl_info.dep_info.runfiles)
441+
runfiles.append(_data_runfiles(ctx, ctx, "data"))
428442

429443
return [DefaultInfo(
430444
executable = output,

0 commit comments

Comments
 (0)