Skip to content

Commit

Permalink
Only add import-dirs for hs library
Browse files Browse the repository at this point in the history
If a package has no haskell library, there are no interface files either.

On Windows, ghc-pkg failed if the import-dir did not exist:

```
bytestring-builder-0.10.8.2.0: import-dirs:
C:\_bzl\ptbwskyc\execroot\rules_haskell_examples\bazel-out\x64_windows-fastbuild\bin\external\stackage/externalZSstackageZSbytestring-builder/_iface
doesn't exist or isn't a directory (use --force to override)
```
  • Loading branch information
avdv committed Mar 10, 2025
1 parent bb707c7 commit 64e2f99
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions haskell/private/actions/package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ def package(
paths.join(pkg_db_dir + empty_libs_suffix, "{0}.conf".format(pkg_db_dir)),
)

import_dir = paths.join(
"${pkgroot}",
paths.join(pkg_db_dir, "_iface"),
)

(extra_lib_dirs, extra_libs) = _get_extra_libraries(hs, cc, with_shared)
if with_shared:
(extra_dynamic_lib_dirs, _) = _get_extra_libraries(hs, cc, with_shared, dynamic = True)
Expand All @@ -98,7 +93,6 @@ def package(
"key": pkg_id.to_string(my_pkg_id),
"exposed": "True",
"hidden-modules": other_modules,
"import-dirs": [import_dir],
"library-dirs": [pkgroot_lib_path] + extra_lib_dirs,
"dynamic-library-dirs": [pkgroot_lib_path] + extra_dynamic_lib_dirs,
"extra-libraries": extra_libs,
Expand All @@ -108,7 +102,13 @@ def package(
}

if has_hs_library:
import_dir = paths.join(
"${pkgroot}",
paths.join(pkg_db_dir, "_iface"),
)

config.update({
"import-dirs": [import_dir],
"hs-libraries": [pkg_id.library_name(hs, my_pkg_id)],
})

Expand Down

0 comments on commit 64e2f99

Please sign in to comment.