Cabal does some work behind the back of hooks, e.g. with q.cabal:
name: q
version: 1
exposed-modules: Bar
build-type: Custom
and Setup.hs:
module Main (main) where
import Distribution.Simple
import Distribution.Simple.Setup
import System.Cmd
main :: IO ()
main = defaultMainWithHooks myHooks
myHooks :: UserHooks
myHooks = simpleUserHooks {
confHook = \x flags -> do
let flags' = flags { configDistPref = Flag "foo" }
lbi <- (confHook simpleUserHooks) x flags'
system "ls"
return lbi,
postConf = \args flags pd lbi -> do
system "ls"
let flags' = flags { configDistPref = Flag "foo" }
(postConf simpleUserHooks) args flags' pd lbi
return ()
}
a dist directory magically appears between the configure hook and the postconf hook:
$ ./Setup configure
Configuring q-1...
Setup Setup.hi Setup.hs Setup.o foo q.cabal
Setup Setup.hi Setup.hs Setup.o dist foo q.cabal
$ ls -l dist
-rw-r--r-- 1 ian ian 6411 Jun 8 12:02 setup-config
The reason I want to do this is so that Setup.hs can take care of building itself in multiple ways, using different dist directories.