Motivation: I have a project which has a library component and a pre-processor which generates some code, in this case it dumps out the generated code for a bunch of lenses. The generator needs to get built independently of the library.
Solution: Have an option to do an equivalent tocabal build generate which only builds the generate target in the cabal file.
For now my work around is to use a combination of
mafia lock # Generate the build env / sandbox
cabal build generate
# nasty shell manipulation to copy generated code into library src
mafia build # Build the actual library