Skip to content

Commit

Permalink
Remove HaskellBinaryInfo
Browse files Browse the repository at this point in the history
It has no fields by now, so conveys no useful information.
  • Loading branch information
mboes committed Apr 27, 2019
1 parent e0b4556 commit 6a34786
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 57 deletions.
11 changes: 2 additions & 9 deletions haskell/cc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
load(":private/set.bzl", "set")
load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"HaskellBinaryInfo",
"HaskellInfo",
)

Expand Down Expand Up @@ -287,12 +286,6 @@ def _cc_haskell_import(ctx):
else:
fail("{0} has to provide `HaskellInfo`".format(ctx.attr.dep.label.name))

if HaskellBinaryInfo in ctx.attr.dep:
bin = ctx.attr.dep[HaskellBinaryInfo].binary
dyn_lib = ctx.actions.declare_file("lib{0}.so".format(bin.basename))
ln(ctx, bin, dyn_lib)
set.mutable_insert(dyn_libs, dyn_lib)

return [
DefaultInfo(
files = set.to_depset(dyn_libs),
Expand All @@ -312,8 +305,8 @@ cc_haskell_import = rule(
attrs = {
"dep": attr.label(
doc = """
Target providing a `HaskellLibraryInfo` or `HaskellBinaryInfo`, such as
`haskell_library` or `haskell_binary`.
Target providing a `HaskellLiInfo` such as `haskell_library` or
`haskell_binary`.
""",
),
},
Expand Down
2 changes: 0 additions & 2 deletions haskell/doctest.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ load(":providers.bzl", "get_libs_for_ghc_linker")
load(":private/set.bzl", "set")
load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"HaskellBinaryInfo",
"HaskellInfo",
"HaskellLibraryInfo",
)
Expand Down Expand Up @@ -89,7 +88,6 @@ def _haskell_doctest_single(target, ctx):
hs_info = target[HaskellInfo]
cc_info = target[CcInfo]
lib_info = target[HaskellLibraryInfo] if HaskellLibraryInfo in target else None
bin_info = target[HaskellBinaryInfo] if HaskellBinaryInfo in target else None

args = ctx.actions.args()
args.add("--no-magic")
Expand Down
2 changes: 0 additions & 2 deletions haskell/lint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"HaskellBinaryInfo",
"HaskellInfo",
"HaskellLibraryInfo",
"HaskellLintInfo",
Expand Down Expand Up @@ -36,7 +35,6 @@ def _haskell_lint_aspect_impl(target, ctx):

hs_info = target[HaskellInfo]
lib_info = target[HaskellLibraryInfo] if HaskellLibraryInfo in target else None
bin_info = target[HaskellBinaryInfo] if HaskellBinaryInfo in target else None

args = ctx.actions.args()

Expand Down
5 changes: 1 addition & 4 deletions haskell/private/actions/repl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def build_haskell_repl(
output,
package_databases,
version,
lib_info = None,
bin_info = None):
lib_info = None):
"""Build REPL script.
Args:
Expand All @@ -40,8 +39,6 @@ def build_haskell_repl(
we're creating a REPL for.
lib_info: If we're building REPL for a library target, pass
HaskellLibraryInfo here, otherwise it should be None.
bin_info: If we're building REPL for a binary target, pass
HaskellBinaryInfo here, otherwise it should be None.
Returns:
None.
Expand Down
5 changes: 1 addition & 4 deletions haskell/private/actions/runghc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def build_haskell_runghc(
output,
package_databases,
version,
lib_info = None,
bin_info = None):
lib_info = None):
"""Build runghc script.
Args:
Expand All @@ -38,8 +37,6 @@ def build_haskell_runghc(
we're creating a runghc for.
lib_info: If we're building runghc for a library target, pass
HaskellLibraryInfo here, otherwise it should be None.
bin_info: If we're building runghc for a binary target, pass
HaskellBinaryInfo here, otherwise it should be None.
Returns:
None.
Expand Down
3 changes: 1 addition & 2 deletions haskell/private/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:paths.bzl", "paths")
load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"HaskellBinaryInfo",
"HaskellCcInfo",
"HaskellInfo",
"HaskellLibraryInfo",
Expand Down Expand Up @@ -162,7 +161,7 @@ def gather_dep_info(ctx, deps):
if HaskellInfo in dep:
binfo = dep[HaskellInfo]
package_ids = acc.package_ids
if HaskellBinaryInfo in dep:
if HaskellLibraryInfo not in dep:
fail("Target {0} cannot depend on binary".format(ctx.attr.name))
if HaskellLibraryInfo in dep:
set.mutable_insert(package_ids, dep[HaskellLibraryInfo].package_id)
Expand Down
6 changes: 0 additions & 6 deletions haskell/private/haskell_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"C2hsLibraryInfo",
"HaskellBinaryInfo",
"HaskellInfo",
"HaskellLibraryInfo",
"HaskellPrebuiltPackageInfo",
Expand Down Expand Up @@ -170,8 +169,6 @@ def _haskell_binary_common_impl(ctx, is_test):
cc_dependencies = dep_info.cc_dependencies,
transitive_cc_dependencies = dep_info.transitive_cc_dependencies,
)
bin_info = HaskellBinaryInfo(
)
cc_info = cc_common.merge_cc_infos(
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep],
)
Expand All @@ -188,7 +185,6 @@ def _haskell_binary_common_impl(ctx, is_test):
package_databases = dep_info.package_databases,
version = ctx.attr.version,
hs_info = hs_info,
bin_info = bin_info,
)

# XXX Temporary backwards compatibility hack. Remove eventually.
Expand All @@ -204,7 +200,6 @@ def _haskell_binary_common_impl(ctx, is_test):
package_databases = dep_info.package_databases,
version = ctx.attr.version,
hs_info = hs_info,
bin_info = bin_info,
)

executable = binary
Expand Down Expand Up @@ -260,7 +255,6 @@ def _haskell_binary_common_impl(ctx, is_test):

return [
hs_info,
bin_info,
cc_info,
DefaultInfo(
executable = executable,
Expand Down
4 changes: 0 additions & 4 deletions haskell/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ HaskellLibraryInfo = provider(
},
)

HaskellBinaryInfo = provider(
doc = "Binary-specific information.",
)

HaskellCoverageInfo = provider(
doc = "Information about coverage instrumentation for Haskell files.",
fields = {
Expand Down
31 changes: 7 additions & 24 deletions haskell/repl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ load(
)
load(
"@io_tweag_rules_haskell//haskell:providers.bzl",
"HaskellBinaryInfo",
"HaskellInfo",
"HaskellLibraryInfo",
"empty_HaskellCcInfo",
Expand Down Expand Up @@ -116,28 +115,18 @@ def _create_HaskellReplCollectInfo(target, ctx):
prebuilt_dependencies = hs_info.prebuilt_dependencies
transitive_cc_dependencies = hs_info.transitive_cc_dependencies

load_infos[target.label] = HaskellReplLoadInfo(
source_files = hs_info.source_files,
cc_dependencies = hs_info.cc_dependencies,
compiler_flags = getattr(ctx.rule.attr, "compiler_flags", []),
repl_ghci_args = getattr(ctx.rule.attr, "repl_ghci_args", []),
)
if HaskellLibraryInfo in target:
lib_info = target[HaskellLibraryInfo]
load_infos[target.label] = HaskellReplLoadInfo(
source_files = hs_info.source_files,
cc_dependencies = hs_info.cc_dependencies,
compiler_flags = getattr(ctx.rule.attr, "compiler_flags", []),
repl_ghci_args = getattr(ctx.rule.attr, "repl_ghci_args", []),
)
dep_infos[target.label] = HaskellReplDepInfo(
package_ids = set.singleton(lib_info.package_id),
package_databases = hs_info.package_databases,
)
elif HaskellBinaryInfo in target:
bin_info = target[HaskellBinaryInfo]
load_infos[target.label] = HaskellReplLoadInfo(
source_files = hs_info.source_files,
cc_dependencies = hs_info.cc_dependencies,
compiler_flags = ctx.rule.attr.compiler_flags,
repl_ghci_args = ctx.rule.attr.repl_ghci_args,
)
else:
fail("Missing HaskellLibraryInfo or HaskellBinaryInfo.")

return HaskellReplCollectInfo(
load_infos = load_infos,
Expand Down Expand Up @@ -338,13 +327,7 @@ def _create_repl(hs, ctx, repl_info, output):
)]

def _haskell_repl_aspect_impl(target, ctx):
is_eligible = (
HaskellInfo in target and (
HaskellLibraryInfo in target or
HaskellBinaryInfo in target
)
)
if not is_eligible:
if not HaskellInfo in target:
return []

target_info = _create_HaskellReplCollectInfo(target, ctx)
Expand Down

0 comments on commit 6a34786

Please sign in to comment.