Bondage is difficult when it comes to such situations.
As you said, if you can squeeze everything into Setup.hs , you can minimize the amount of headaches.
If you have really complex preprocessors, I would suggest doing this:
Make one package for each preprocessor with its own dependencies, etc. Thus, for stage0 you will have a file-bondage:
Name: mypackage-stage0 Version: 0.1 -- ... Executable mpk-stage0 Default-language: Haskell2010 Main-is: Stage0.hs -- ...
For stage1 you need to generate the source code, so add a Setup.hs to Setup.hs for mypackage-stage1 that launches the mpk-stage0 :
main = defaultMainWithHooks simpleUserHooks { preBuild = -- ... something involving `system "mpk-stage1 Stage1.hs"` -- Note that shell redirection `> bla.hs` doesn't necessarily work -- on all platforms, so make your `mpk-stage1` executable take an -- output file argument }
Then you add the dependency based on the assembly in the previous step:
Executable mpk-stage1 -- ... Main-is: Stage1.hs Build-tools: mypackage-stage0
This should work in recent versions of cabal; otherwise, you may need to add a Build-depends: dependency.
You will need to rebuild each package in turn each time you perform a cascading change (this is necessary because cabal does not manage dependency changes between projects), so you need a script that does for project in mypackage-stage0 mypackage-stage1; do (cd $project; cabal install); done for project in mypackage-stage0 mypackage-stage1; do (cd $project; cabal install); done for project in mypackage-stage0 mypackage-stage1; do (cd $project; cabal install); done or something like that.
Cabal was never built for such a project, so it will be difficult if you want to do something like this. You should consider using the Haskell template instead if you want to generate code in a more consistent way.
dflemstr
source share