issue with cabal behavior with a custom Setup.hs
tom.lippincott at gmail.com
Sat Nov 28 15:23:54 UTC 2015
I'm seeing what I think is some strange (or at least, non-intuitive)
behavior in a custom package, and was wondering if someone could point
me in the right direction. Basically, I need the build process to
generate some additional exposed modules, i.e. add them to the
"exposed-modules" variable, and create the corresponding source files.
It's easy to get the list of modules and produce the source files at any
point in the build process (I know this is a questionable design, trying
to do this as part of Cabal, but suffice it to say there are good
arguments on both sides for our particular situation).
I'm *so* close to having it working perfectly: in fact, if I run "cabal
repl", I get a shell with all the right modules compiled and exposed,
so, it should work the same way if it's installed and imported in ghci,
right? Well, when I do that, the auto-generated modules are *not*
exposed. It's clearly generating the source files and compiling them,
maybe "cabal install" isn't getting the updated module list or
something? Here's what I'm doing:
I override "confHook" to call the original configure function, but then
get the list of auto-generated modules and add them to the
exposedModules field in the Library structure nested in the
LocalBuildInfo structure before returning it. The idea is that I've
intercepted the list of exposed modules as early as possible, and so
it's as though the Cabal file had the auto-generated modules listed from
the start. I generate the actual source files by overriding "preBuild".
Nothing else is modified from the default simpleUserHooks.
This probably isn't the place for "how do I..." questions, so I'll frame
it as: why would "cabal repl" work, and "cabal install" and ghci+import
not work? I apologize if this is an inappropriate place to ask, but
there aren't exactly a ton of Cabal experts floating around!
Thanks for any help,
More information about the cabal-devel