Ticket #290 (new defect)

Opened 6 months ago

Last modified 6 months ago

Cabal does some work behind the back of hooks

Reported by: igloo Assigned to:
Priority: normal Milestone:
Component: Cabal library Version: 1.2.3.0
Severity: normal Keywords:
Cc: Difficulty: normal
GHC Version: 6.8.2 Platform:

Description

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.

Change History

06/08/08 05:05:47 changed 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?

06/08/08 05:19:59 changed 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.