Skip to content

Commit

Permalink
Do not -package transitive dependencies.
Browse files Browse the repository at this point in the history
If A depends on B and B depends on C, previously A could import
directly from C without listing C in dependencies. It should not.

Fixes #72.
  • Loading branch information
Mateusz Kowalczyk committed Jan 4, 2018
1 parent 350a169 commit fbc9479
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions haskell/actions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ load(":java_interop.bzl",
"java_interop_info",
)

load("@bazel_skylib//:lib.bzl", "paths", "dicts")
load("@bazel_skylib//:lib.bzl", "paths", "dicts", "collections")

HaskellPackageInfo = provider(
doc = "Package information exposed by Haskell libraries.",
Expand Down Expand Up @@ -259,7 +259,7 @@ def create_dynamic_library(ctx, object_files):

dep_info = gather_dependency_information(ctx)

for n in depset(transitive = [dep_info.names, depset(ctx.attr.prebuilt_dependencies)]).to_list():
for n in collections.uniq(dep_info.names + ctx.attr.prebuilt_dependencies):
args.extend(["-package", n])

for c in dep_info.caches.to_list():
Expand Down Expand Up @@ -503,7 +503,7 @@ def gather_dependency_information(ctx):
new_external_libraries = new_external_libraries.union(pkg.external_libraries)
hpi = HaskellPackageInfo(
name = hpi.name,
names = hpi.names + pkg.names,
names = hpi.names + [pkg.name],
confs = hpi.confs + pkg.confs,
caches = hpi.caches + pkg.caches,
static_libraries = hpi.static_libraries + pkg.static_libraries,
Expand Down
5 changes: 5 additions & 0 deletions haskell/haskell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ def _haskell_library_impl(ctx):
dep_info = gather_dependency_information(ctx)
return [HaskellPackageInfo(
name = dep_info.name,
# TODO this is somewhat useless now, we shouldn't be abusing
# HaskellPackageInfo to carry information only relevant during
# build just to throw it away later as upstream doesn't need this.
# Technically Haddock rule relies on this but it should gather its
# own info.
names = depset(transitive = [dep_info.names, depset([get_pkg_id(ctx)])]),
confs = depset(transitive = [dep_info.confs, depset([conf_file])]),
caches = depset(transitive = [dep_info.caches, depset([cache_file])]),
Expand Down

0 comments on commit fbc9479

Please sign in to comment.