[enable the ho cache, start using it by default.
John Meacham <john@repetae.net>**20090812060012
 Ignore-this: a0d4d4afae50f05d5ce16f5b654d2072
] hunk ./Makefile.am 42
-	src/Support/IniParse.hs src/E/Lint.hs
+	src/Support/IniParse.hs src/E/Lint.hs src/Util/Progress.hs
hunk ./src/Ho/Build.hs 122
+    hoCache         :: Maybe FilePath,
hunk ./src/Ho/Build.hs 129
-    {-! derive: Monoid, update !-}
+    {-! derive: update !-}
hunk ./src/Ho/Build.hs 139
-hoFile :: FilePath -> Maybe Module -> SourceHash -> FilePath
-hoFile fp mm sh = case optHoDir options of
-    Nothing -> replaceSuffix "ho" fp
-    Just hdir -> case mm of
+hoFile :: Maybe FilePath -> FilePath -> Maybe Module -> SourceHash -> FilePath
+hoFile cacheDir fp mm sh = case (cacheDir,optHoDir options) of
+    (Nothing,Nothing) -> replaceSuffix "ho" fp
+    (Nothing,Just hdir) -> case mm of
hunk ./src/Ho/Build.hs 147
+    (Just hdir,_) -> hdir ++ "/" ++ show sh ++ ".ho"
hunk ./src/Ho/Build.hs 152
-    let honame = hoFile fp mm sh
+    let honame = hoFile (hoCache done) fp mm sh
hunk ./src/Ho/Build.hs 387
+libName (Library HoHeader { hohName = Right (name,vers) } _ _ _) = unpackPS name ++ "-" ++ showVersion vers
hunk ./src/Ho/Build.hs 412
-    done_ref <- newIORef mempty
+    theCache <- findHoCache
+    case theCache of
+        Just s -> putProgressLn $ printf "Using Ho Cache: '%s'" s
+        Nothing -> return ()
+    done_ref <- newIORef Done {
+        hoCache = theCache,
+        knownSourceMap = Map.empty,
+        validSources = Set.empty,
+        loadedLibraries = Map.empty,
+        hosEncountered = Map.empty,
+        modEncountered = Map.empty
+        }
hunk ./src/Ho/Build.hs 433
+    done <- readIORef done_ref
+    forM_ (Map.elems $ loadedLibraries done) $ \ lib@(Library hoh  _ _ _) -> do
+        let libsBad = filter (\ (p,h) -> fmap (libHash) (Map.lookup p (loadedLibraries done)) /= Just h) (hohLibDeps hoh)
+        unless (null libsBad) $ do
+            putErr $ printf "Library Dependencies not met. %s needs\n" (libName lib)
+            forM_ libsBad $ \ (p,h) -> putErr $ printf "    %s (hash:%s)\n" (unpackPS p) (show h)
+            putErrDie "\n"
hunk ./src/Ho/Build.hs 581
-                        writeIORef ref (CompCollected (choLibDeps_u (Map.insert ln lh) cho) cu)
-                        return cho
+                            cho' = (choLibDeps_u (Map.insert ln lh) cho)
+                        writeIORef ref (CompCollected cho' cu)
+                        return cho'
hunk ./src/Options.hs 12
+    findHoCache,
hunk ./src/Options.hs 34
-import qualified Data.Set as S
-import qualified Data.Map as M
hunk ./src/Options.hs 35
+import Data.Maybe
hunk ./src/Options.hs 38
+import System.Directory
hunk ./src/Options.hs 40
+import qualified Data.Map as M
+import qualified Data.Set as S
hunk ./src/Options.hs 46
-import qualified FlagDump
-import qualified FlagOpts
hunk ./src/Options.hs 48
+import qualified FlagDump
+import qualified FlagOpts
hunk ./src/Options.hs 329
+findHoCache :: IO (Maybe FilePath)
+findHoCache = do
+    cd <- lookupEnv "HOCACHEDIR"
+    case optHoCache options `mplus` cd of
+        Just s -> do return (Just s)
+        Just "-" -> do return Nothing
+        Nothing | isNothing (optHoDir options) -> do
+            Just home <- fmap (`mplus` Just "/") $ lookupEnv "HOME"
+            let cd = home ++ "/.jhc/cache"
+            createDirectoryIfMissing True cd
+            return (Just cd)
+        _  -> return Nothing
+
+
+