[Haskell-cafe] Cabal rebuilding all of the C++ code for wxHaskell

DukeDave dukedave at gmail.com
Fri Sep 30 02:15:41 CEST 2011

Hi all, I've been trying to resolve a compile time issue[1] with
wxHaskell, and I thought I'd throw it open to see if anyone on cafe
can help.
Here's the crux of the issue:

The Setup.hs for wxcore (the major component of wxHaskell) uses
"simpleUserHooks", overriding only "confHook".
However there is also "cleanHook", which is defined by simpleUserHooks to 
 cleanHook = \p _ _ f -> clean p f,

If you consult the source for clean[2] you'll see that it tries to
"remove the whole dist/ directory rather than tracking exactly what
files we created in there". I presume that's why we have to do a full
re-build every time?

To try and circumvent this I modified the definition of "main" in
Setup.hs to this:
main = defaultMainWithHooks simpleUserHooks { confHook = myConfHook,
cleanHook = (\_ _ _ _ -> return ())}

Unfortunately it still seems to re-build all the C++ on each 'install'
from cabal.
Not sure why?


[1] http://sourceforge.net/mailarchive/message.php?msg_id=28099997

[2] Taken from 
-- Cleaning

clean :: PackageDescription -> CleanFlags -> IO ()
clean pkg_descr flags = do
   let distPref = fromFlag $ cleanDistPref flags
   notice verbosity "cleaning..."

   maybeConfig <- if fromFlag (cleanSaveConf flags)
                    then maybeGetPersistBuildConfig distPref
                    else return Nothing

   -- remove the whole dist/ directory rather than tracking exactly what 
   -- we created in there.
   chattyTry "removing dist/" $ do
     exists <- doesDirectoryExist distPref
     when exists (removeDirectoryRecursive distPref)

   -- these live in the top level dir so must be removed separately

   -- Any extra files the user wants to remove
   mapM_ removeFileOrDirectory (extraTmpFiles pkg_descr)

   -- If the user wanted to save the config, write it back
   maybe (return ()) (writePersistBuildConfig distPref) maybeConfig

       removeFileOrDirectory :: FilePath -> IO ()
       removeFileOrDirectory fname = do
           isDir <- doesDirectoryExist fname
           isFile <- doesFileExist fname
           if isDir then removeDirectoryRecursive fname
             else if isFile then removeFile fname
             else return ()
       verbosity = fromFlag (cleanVerbosity flags)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110929/7a6ccfd5/attachment.htm>

More information about the Haskell-Cafe mailing list