<div dir="ltr"><div><div><div>Hi,<br><br></div>I'm writing a package which uses custom preprocessor for creating some of the source files. It takes one IDL file as input and writes several .hs modules, depending on IDL contents. I need to compile this modules with a few normal ones and link them as a library, preferably with generated modules exposed. It doesn't look like a complex task and never was in with make/etc, but I run into some problems now.<br><br></div>Obviously, cabal supports 1-to-1 preprocessors to create one Haskell module from one source file (alex, happy, etc), but I can't find anything for 1-to-many preprocessors. So, I decided to use hookedPrograms and hooks and do it myself. The call to preprocessor in the postConf hook worked just fine and created source files and module list.<br></div><div><br>Cabal pre-* hooks seems to be right place to read this module list and use it, but are presenting two problems: can only modify other-modules, not exposed-modules, which is tolerable, and there is no access to build configuration. The latter is fatal, I need to know build dir to read module list. So I have to change action hooks.<br>As the additional annoyance, there is absolutely no way to modify configuration once and for all, I have to override every single hook with the same "read module list and change config" wrapper.<br><br></div><div>So, I have buildHook, copyHook and regHook replaced with wrappers which change PackageDescription parameter and call original function. Library is built and installed, but somewhere between build and copy actions there is still a message "Warning: modules not listed in foo.cabal for library component (add to other-modules)". I can't identify where it comes from.<br></div><div><br><div>I'm using stack 1.0.4 to build this library, but all the problems seems to be cabal-related. Here is minimal example of what I ended up with: <a href="https://github.com/rblaze/cabal-hooks-sample">https://github.com/rblaze/cabal-hooks-sample</a><br><br></div></div><div>Now I wonder if I missed an easier way to handle this code generation. If not, at least how to get rid of warning about missing modules between build and copy actions?</div></div>