Skip to content

Commit

Permalink
support virtual_modules
Browse files Browse the repository at this point in the history
the same as Cabal virtual-modules. This is necessary to support ghc-prim compilation.
  • Loading branch information
wavewave committed Sep 27, 2024
1 parent c2198e3 commit b599821
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions decls/haskell_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ def _use_argsfile_at_link_arg():
"""),
}

def _virtual_modules_arg():
return {
"virtual_modules": attrs.named_set(attrs.string(), sorted = True, default = [], doc = """
A list of virtual Haskell modules. See Cabal virtual-modules.
"""),
}

haskell_common = struct(
srcs_arg = _srcs_arg,
deps_arg = _deps_arg,
Expand All @@ -85,4 +92,5 @@ haskell_common = struct(
external_tools_arg = _external_tools_arg,
srcs_envs_arg = _srcs_envs_arg,
use_argsfile_at_link_arg = _use_argsfile_at_link_arg,
virtual_modules_arg = _virtual_modules_arg,
)
1 change: 1 addition & 0 deletions decls/haskell_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ haskell_library = prelude_rule(
haskell_common.external_tools_arg() |
haskell_common.srcs_envs_arg() |
haskell_common.use_argsfile_at_link_arg() |
haskell_common.virtual_modules_arg() |
haskell_common.compiler_flags_arg() |
haskell_common.deps_arg() |
haskell_common.scripts_arg() |
Expand Down
3 changes: 2 additions & 1 deletion haskell/haskell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ def _make_package(
for module in md["module_graph"].keys()
if not module.endswith("-boot")
]
virtual_modules = ctx.attrs.virtual_modules

# XXX use a single import dir when this package db is used for resolving dependencies with ghc -M,
# which works around an issue with multiple import dirs resulting in GHC trying to locate interface files
Expand All @@ -469,7 +470,7 @@ def _make_package(
"id: " + pkgname,
"key: " + pkgname,
"exposed: False",
"exposed-modules: " + ", ".join(modules),
"exposed-modules: " + ", ".join(modules + virtual_modules),
"import-dirs:" + ", ".join(import_dirs),
"depends: " + ", ".join([lib.id for lib in hlis]),
]
Expand Down

0 comments on commit b599821

Please sign in to comment.