Skip to content

Commit

Permalink
Merge pull request #352 from tweag/repls-depend-on-their-targets
Browse files Browse the repository at this point in the history
Make REPLs not to depend on their targets
  • Loading branch information
mboes authored Jul 20, 2018
2 parents 2efb1e2 + 1fb3967 commit 125acf8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 33 deletions.
11 changes: 0 additions & 11 deletions haskell/haskell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ _haskell_common_attrs = {
"prebuilt_dependencies": attr.string_list(
doc = "Non-Bazel supplied Cabal dependencies.",
),
"repl_interpreted": attr.bool(
default = True,
doc = """
Whether source files should be interpreted rather than compiled. This allows
for e.g. reloading of sources on editing, but in this case we don't handle
boot files and hsc processing.
For `haskell_binary` targets, `repl_interpreted` must be set to `True` for
REPL to work.
""",
),
"repl_ghci_args": attr.string_list(
doc = "Arbitrary extra arguments to pass to GHCi. This extends `compiler_flags` and `repl_ghci_args` from the toolchain",
),
Expand Down
23 changes: 5 additions & 18 deletions haskell/private/actions/repl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def build_haskell_repl(
compiler_flags,
repl_ghci_args,
build_info,
target_files,
interpreted,
output,
lib_info = None,
bin_info = None):
Expand All @@ -46,10 +44,6 @@ def build_haskell_repl(
bin_info: If we're building REPL for a binary target, pass
HaskellBinaryInfo here, otherwise it should be None.
target_files: Output files of the target we're generating REPL for.
These are passed so we can force their building on REPL
building.
Returns:
None.
"""
Expand All @@ -59,13 +53,12 @@ def build_haskell_repl(
for dep in set.to_list(build_info.prebuilt_dependencies):
args += ["-package ", dep]
for package in set.to_list(build_info.package_ids):
if not (interpreted and lib_info != None and package == lib_info.package_id):
if not (lib_info != None and package == lib_info.package_id):
args += ["-package-id", package]
for cache in set.to_list(build_info.package_caches):
args += ["-package-db", cache.dirname]

# Specify import directory for library in interpreted mode.
if interpreted and lib_info != None:
if lib_info != None:
for idir in set.to_list(lib_info.import_dirs):
args += ["-i{0}".format(idir)]

Expand All @@ -82,10 +75,9 @@ def build_haskell_repl(

add_modules = []
if lib_info != None:
# If we have a library, we put names of its exposed modules here but
# only if we're in interpreted mode.
# If we have a library, we put names of its exposed modules here.
add_modules = set.to_list(
lib_info.exposed_modules if interpreted else set.empty(),
lib_info.exposed_modules,
)
elif bin_info != None:
# Otherwise we put paths to module files, mostly because it also works
Expand Down Expand Up @@ -148,10 +140,5 @@ def build_haskell_repl(
# hs.tools.ghci and ghci_script and the best way to do that is
# to use hs.actions.run. That action, it turn must produce
# a result, so using ln seems to be the only sane choice.
extra_inputs = depset(
transitive = [
depset([hs.tools.ghci, ghci_repl_script, repl_file]),
target_files,
],
)
extra_inputs = depset([hs.tools.ghci, ghci_repl_script, repl_file])
ln(hs, repl_file, output, extra_inputs)
4 changes: 0 additions & 4 deletions haskell/private/haskell_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ def haskell_binary_impl(ctx):
compiler_flags = ctx.attr.compiler_flags,
repl_ghci_args = ctx.attr.repl_ghci_args,
output = ctx.outputs.repl,
interpreted = ctx.attr.repl_interpreted,
build_info = build_info,
target_files = target_files,
bin_info = bin_info,
)

Expand Down Expand Up @@ -294,9 +292,7 @@ def haskell_library_impl(ctx):
repl_ghci_args = ctx.attr.repl_ghci_args,
compiler_flags = ctx.attr.compiler_flags,
output = ctx.outputs.repl,
interpreted = ctx.attr.repl_interpreted,
build_info = build_info,
target_files = target_files,
lib_info = lib_info,
)

Expand Down

0 comments on commit 125acf8

Please sign in to comment.