[Haskell-cafe] Building Binaries with Cabal

John Goerzen jgoerzen at complete.org
Thu Nov 30 14:46:05 EST 2006


Hi folks,

I'm in need of some Cabal assistance.

I want to build the unit tests for MissingH using Cabal.  According to the
docs, this should require me to list all of the exposed modules from the
library as other modules to the binary.  Since there are dozens of these, I
thought a simple hook could do the trick.

I tried hooking into the confHook (which I have already used successfully to
add "unix" as a build-dep on non-Windows platforms), and thought I could
just pull the exposedModules list from the package and add those as
otherModules to the executable.  But it had no effect.

So I tried hooking in to customBuildHook to do the same thing.  Again, no
effect.

Here's the code I've tried.  Suggestions appreciated.

import Distribution.Simple
import Distribution.PackageDescription
import Distribution.Version
import System.Info
import Data.Maybe

winHooks = defaultUserHooks {confHook = customConfHook}

customConfHook descrip flags =
    let mydescrip = case System.Info.os of
                      "mingw32" -> descrip
                      _ -> descrip {buildDepends = 
                                        (Dependency "unix" AnyVersion) :
                                        buildDepends descrip}
    in (confHook defaultUserHooks) mydescrip flags

customBuildHook descrip lbi uh flags =
    let myexecutables = map bdfix (executables descrip)
        bdfix exe = 
            exe {buildInfo = 
                     (buildInfo exe) 
                       {otherModules = 
                            exposedModules . fromJust . library $ descrip}}
        mydescrip = descrip {executables = myexecutables}
    in (buildHook defaultUserHooks) mydescrip flags
                                                          
main = defaultMainWithHooks winHooks





More information about the Haskell-Cafe mailing list