Skip to content

Commit

Permalink
Move java_deps attribute to HaskellReplLoadInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
facundominguez authored and mergify-bot committed Jul 28, 2021
1 parent eff9773 commit d543c21
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions haskell/repl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ HaskellReplLoadInfo = provider(
"compiler_flags": "Flags to pass to the Haskell compiler.",
"repl_ghci_args": "Arbitrary extra arguments to pass to GHCi. This extends `compiler_flags` and `repl_ghci_args` from the toolchain",
"data_runfiles": "Runtime data dependencies of this target, i.e. the files and runfiles of the `data` attribute.",
"java_deps": "depset of Files to jars needed for building.",
},
)

Expand Down Expand Up @@ -75,7 +76,6 @@ HaskellReplCollectInfo = provider(
fields = {
"load_infos": "Dictionary from labels to HaskellReplLoadInfo.",
"dep_infos": "Dictionary from labels to HaskellReplDepInfo.",
"java_deps": "depset of Files to jars needed for building.",
},
)

Expand All @@ -88,7 +88,6 @@ HaskellReplInfo = provider(
fields = {
"load_info": "Combined HaskellReplLoadInfo.",
"dep_info": "Combined HaskellReplDepInfo.",
"java_deps": "depset of Files to jars needed for building.",
},
)

Expand Down Expand Up @@ -126,6 +125,7 @@ def _merge_HaskellReplLoadInfo(load_infos):
compiler_flags = []
repl_ghci_args = []
data_runfiles = []
java_deps = []

for load_info in load_infos:
source_files = depset(transitive = [source_files, load_info.source_files])
Expand All @@ -136,6 +136,7 @@ def _merge_HaskellReplLoadInfo(load_infos):
compiler_flags += load_info.compiler_flags
repl_ghci_args += load_info.repl_ghci_args
data_runfiles.append(load_info.data_runfiles)
java_deps.append(load_info.java_deps)

return HaskellReplLoadInfo(
source_files = source_files,
Expand All @@ -146,6 +147,7 @@ def _merge_HaskellReplLoadInfo(load_infos):
compiler_flags = compiler_flags,
repl_ghci_args = repl_ghci_args,
data_runfiles = _merge_runfiles(data_runfiles),
java_deps = depset(transitive = java_deps),
)

def _merge_HaskellReplDepInfo(dep_infos):
Expand Down Expand Up @@ -180,6 +182,10 @@ def _create_HaskellReplCollectInfo(target, ctx):
hs_info = target[HaskellInfo]

if not HaskellToolchainLibraryInfo in target:
if hasattr(ctx.rule.attr, "deps"):
java_deps = java_interop_info(ctx.rule.attr.deps).inputs
else:
java_deps = depset()
load_infos[target.label] = HaskellReplLoadInfo(
source_files = hs_info.source_files,
boot_files = hs_info.boot_files,
Expand All @@ -198,6 +204,7 @@ def _create_HaskellReplCollectInfo(target, ctx):
compiler_flags = hs_info.user_compile_flags,
repl_ghci_args = hs_info.user_repl_flags,
data_runfiles = _data_runfiles(ctx, ctx.rule, "data"),
java_deps = java_deps,
)
if HaskellLibraryInfo in target:
lib_info = target[HaskellLibraryInfo]
Expand All @@ -209,30 +216,22 @@ def _create_HaskellReplCollectInfo(target, ctx):
cc_info = target[CcInfo],
runfiles = target[DefaultInfo].default_runfiles,
)
if hasattr(ctx.rule.attr, "deps"):
java_deps = java_interop_info(ctx.rule.attr.deps).inputs
else:
java_deps = depset()

return HaskellReplCollectInfo(
load_infos = load_infos,
dep_infos = dep_infos,
java_deps = java_deps,
)

def _merge_HaskellReplCollectInfo(args):
load_infos = {}
dep_infos = {}
java_deps = []
for arg in args:
load_infos.update(arg.load_infos)
dep_infos.update(arg.dep_infos)
java_deps.append(arg.java_deps)

return HaskellReplCollectInfo(
load_infos = load_infos,
dep_infos = dep_infos,
java_deps = depset(transitive = java_deps),
)

def _load_as_source(from_source, from_binary, lbl):
Expand Down Expand Up @@ -278,7 +277,6 @@ def _create_HaskellReplInfo(from_source, from_binary, collect_info):
return HaskellReplInfo(
load_info = load_info,
dep_info = dep_info,
java_deps = collect_info.java_deps,
)

def _concat(lists):
Expand Down Expand Up @@ -446,7 +444,7 @@ def _create_repl(hs, posix, ctx, repl_info, output):

classpath_inputs = [
paths.join("$RULES_HASKELL_EXEC_ROOT", f.path)
for f in repl_info.java_deps.to_list()
for f in repl_info.load_info.java_deps.to_list()
]
if len(classpath_inputs) > 0:
env["CLASSPATH"] = ":".join(classpath_inputs)
Expand Down

0 comments on commit d543c21

Please sign in to comment.