[Hackage] #290: Cabal does some work behind the back of hooks

#290: Cabal does some work behind the back of hooks ----------------------------+----------------------------------------------- Reporter: igloo | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.2.3.0 Severity: normal | Keywords: Difficulty: normal | Ghcversion: 6.8.2 Platform: | ----------------------------+----------------------------------------------- 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. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/290 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#290: Cabal does some work behind the back of hooks ----------------------------+----------------------------------------------- Reporter: igloo | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.2.3.0 Severity: normal | Resolution: Keywords: | Difficulty: normal Ghcversion: 6.8.2 | Platform: ----------------------------+----------------------------------------------- Comment (by duncan): This is the bit: {{{ localbuildinfo0 <- confHook hooks epkg_descr flags let localbuildinfo = localbuildinfo0{ pkgDescrFile = mb_pd_file } writePersistBuildConfig distPref localbuildinfo let pkg_descr = localPkgDescr localbuildinfo postConf hooks args flags pkg_descr localbuildinfo }}} `writePersistBuildConfig` writes the configuration file which creates the dist dir. To be honest, I'm not so sure Setup.hs itself should be building in multiple ways and changing the dist dir. It'll make for a very weird package that's not installable in the standard way. Can't you do it externally? That is have the external script build the package multiple times with different dist dirs and config options? -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/290#comment:1 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#290: Cabal does some work behind the back of hooks ----------------------------+----------------------------------------------- Reporter: igloo | Owner: Type: defect | Status: new Priority: normal | Milestone: Component: Cabal library | Version: 1.2.3.0 Severity: normal | Resolution: Keywords: | Difficulty: normal Ghcversion: 6.8.2 | Platform: ----------------------------+----------------------------------------------- Comment (by igloo): Why not make the default `postConf` do the `writePersistBuildConfig`? And I don't know what's going on with `mb_pd_file` in that snippet, but could that be moved into a hook too? I'm sure that anything happening outside of a hook is going to bite us at some point. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/290#comment:2 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects

#290: Cabal does some work behind the back of hooks ----------------------------+----------------------------------------------- Reporter: igloo | Owner: Type: defect | Status: new Priority: normal | Milestone: Cabal-2.0 Component: Cabal library | Version: 1.2.3.0 Severity: normal | Resolution: Keywords: | Difficulty: very hard (<1 week) Ghcversion: 6.8.2 | Platform: ----------------------------+----------------------------------------------- Changes (by duncan): * difficulty: normal => very hard (<1 week) * milestone: => Cabal-2.0 Comment: The hooks needs replacing. I don't particularly plan to change anything before then. Adding important code to `postConf` is a bit dodgy since old `Setup.hs` scripts do not know that if they override it they have to call the old one. While I admit that I've recently added code to `postConf` so it's no longer `return ()`, that is only checking code, so it's no great loss if it is not run. It doesn't break anything. -- Ticket URL: http://hackage.haskell.org/trac/hackage/ticket/290#comment:3 Hackage http://haskell.org/cabal/ Hackage: Cabal and related projects
participants (1)
-
Hackage