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

2011-10-05 Thread Dave Tapley
On 30 September 2011 03:02, Claude Heiland-Allen cla...@goto10.org wrote:
 On 30/09/11 02:45, DukeDave wrote:

 1. Is there some reason (other than 'safety') that cabal install cleans
 everything up?

 As far as I've experienced and understand it, it doesn't - it's more that
 GHC can detect when Haskell modules don't need recompiling while the same is
 not true for C or C++ sources.  For example, I change one module and see GHC
 report only that module and its dependents being recompiled, while the other
 compiled modules are reused from previous 'cabal install' runs.  The
 C-sources: are recompiled every time even if unchanged, which I too find
 it somewhat annoying even with my small projects.

Excellent, that is consistent with what I'm seeing, and I'm glad I'm
not the only one who finds it annoying.
I have no familiarity with how cabal and GHC handle C-sources, but I
presume that the job of building them is handed off to a local C/C++
compiler (I presume g++ in my case).

Given this I can only assume that cabal is doing something:
1. Deleting the object files before calling the C compiler (and so
everything must be rebuilt)?
2. Touching the source C files in some way, before calling the C compiler?
3. Passing some argument to the compiler which is telling it to
rebuild everything?
4. Something else?


 2. Why does setting cleanHook to return () not have any effect?

 I think becausae the clean hook is probably not called by 'cabal install',
 but by 'cabal clean'.

Ah yes, that does make sense, my bad.



 Claude

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-09-29 Thread DukeDave
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 
be:
 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?

Dave,


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

[2] Taken from 
http://www.haskell.org/ghc/docs/6.10.4/html/libraries/Cabal/src/Distribution-Simple.html#simpleUserHooks
-- 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 
files
   -- 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
   removeRegScripts

   -- 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

 where
   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)___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-09-29 Thread Antoine Latter
On Thu, Sep 29, 2011 at 7:15 PM, DukeDave duked...@gmail.com wrote:
 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
 be:
  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:

Why do you want to change the behavior of the 'clean' hook? Most users
would expect it to clear out everything that 'configure', 'build' and
such have done.

I would be cautious about subverting user expectations like that.

Antoine

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-09-29 Thread DukeDave
On Friday, 30 September 2011 01:42:00 UTC+1, Antoine Latter wrote:

 Why do you want to change the behavior of the 'clean' hook? Most users
 would expect it to clear out everything that 'configure', 'build' and
 such have done.

 I would be cautious about subverting user expectations like that.

I'm only inquiring about changing the clean hook for this specific project, 
not cabal in general.

And the reason I'm looking to change it is that building the C++ component 
takes a long time (over five minutes on my fairly average laptop), so 
cleaning everything every time is an extremely annoying inconvenience.

My main questions are:
1. Is there some reason (other than 'safety') that cabal install cleans 
everything up?
2. Why does setting cleanHook to return () not have any effect?

Thanks,
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2011-09-29 Thread Claude Heiland-Allen

On 30/09/11 02:45, DukeDave wrote:

1. Is there some reason (other than 'safety') that cabal install cleans
everything up?


As far as I've experienced and understand it, it doesn't - it's more 
that GHC can detect when Haskell modules don't need recompiling while 
the same is not true for C or C++ sources.  For example, I change one 
module and see GHC report only that module and its dependents being 
recompiled, while the other compiled modules are reused from previous 
'cabal install' runs.  The C-sources: are recompiled every time even 
if unchanged, which I too find it somewhat annoying even with my small 
projects.



2. Why does setting cleanHook to return () not have any effect?


I think becausae the clean hook is probably not called by 'cabal 
install', but by 'cabal clean'.



Claude

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe