I have a package where most of the .hs
files are generated from some spec files by a Haskell processor (stored in a subdirectory).
At present this preprocessor is run manually, and so does not work particularly well with version control or when used as part of a larger stack.
I would like Cabal to run this processor, for example from Setup.hs, so that the package can be built using cabal build
or by stack
as part of a larger project without needing separate manual steps.
The input files are not 1-1 with the output .hs
files: instead, a pile of .csv
files are read in, and then a differently arranged pile of .hs
files are output. I think this means I can't use cabal's preprocessor support.
For my present development purposes I have bodged a call to stack build && stack exec gen-exe
at the start of Setup.hs. This runs sometimes too many times (for example it runs on register
at the end of a build; and sometimes not enough (for example, it does not run if one of the input .csv
files changes, so a manual clean is necessary).
Is this achieveable in cabal, and if so, what do I need to put where to run my build commands frequently enough and not too frequently?
(This is an inherited package... please don't blame me)