foreign-libraries + getDynLibDir
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
It would be nice if cabal made foreign-libraries available at `cabal run` time. There are various ways this *could* work, and I freely admit that what I describe below is just one idea for this.
I am developing an application with three components: a Haskell executable, a third-party executable (not controlled by cabal), and a shared library which will be loaded by the third-party executable to facilitate communication with the Haskell executable. I'd like cabal to be in charge of building the shared library and making it available to the third-party executable.
I have found I can get cabal to build the library by making a `foreign-library` stanza. This results in a suitable `.so` file being created inside `dist-newstyle`; if I `cabal install`, I expect that `.so` would even be placed somewhere reasonably discoverable (I haven't tested this). But I don't see a (robust) way of finding that file from within either my Haskell executable or the third-party executable during development.
It would be nice if `cabal` created a directory inside `dist-newstyle` with links to the `foreign-library` build products, then set the appropriate environment variable so that `Paths_foo.getDynLibDir` returned that directory. Bonus points if I can add `foo:bar` to the build-depends field to tell cabal that I depend on package `foo`'s `foreign-library bar` and ensure that the appropriate link/build product is up-to-date when calling `cabal run`.
Contributor guide
Research direction
Start by tracing how `cabal run` builds and exposes `foreign-library` products in `dist-newstyle`, and how `Paths_foo.getDynLibDir` is generated. Compare the proposed runtime directory links and environment-variable behavior with the requested `foo:bar` build-depends support; done means foreign libraries are discoverable and kept up to date during development.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100