[Print '[ X of N ] name' for each module.
Lemmih <lemmih@gmail.com>**20080319154602] {
hunk ./Ho/Build.hs 12
+import Control.Concurrent
hunk ./Ho/Build.hs 396
-compileCompNode ifunc func cn = f cn where
-    f (CompNode hh deps ref) = readIORef ref >>= \cn -> case cn of
+compileCompNode ifunc func cn = do ns <- countNodes cn
+                                   cur <- newMVar (1::Int)
+                                   f (Set.size ns) cur cn where
+    countNodes (CompNode hh deps ref) = readIORef ref >>= worker
+        where worker (CompCollected _ _) = return Set.empty
+              worker (CompPhony) = mconcat `fmap` mapM countNodes deps
+              worker (CompHo _ hoh _) = do ds <- mconcat `fmap` mapM countNodes deps
+                                           return $ ds `Set.union` Set.fromList (map (show.fst) (hohDepends hoh))
+              worker (CompSources sc) = do ds <- mconcat `fmap` mapM countNodes deps
+                                           return $ ds `Set.union` Set.fromList (map sourceIdent sc)
+    tickProgress cur
+        = modifyMVar cur $ \val -> return (val+1,val)
+    showProgress maxModules cur ms
+        = forM_ ms $ \modName ->
+          do curModule <- tickProgress cur
+             let l = ceiling (logBase 10 (fromIntegral maxModules+1)) :: Int
+             printf "[%*d of %*d] %s\n" l curModule l maxModules (show $ hsModuleName modName)
+    f n cur (CompNode hh deps ref) = readIORef ref >>= \cn -> case cn of
hunk ./Ho/Build.hs 416
-            xs <- mconcat `fmap` mapM f deps
+            xs <- mconcat `fmap` mapM (f n cur) deps
hunk ./Ho/Build.hs 419
-        CompHo _ _ ho -> do
-            cho <- mconcat `fmap` mapM f deps
+        CompHo _ hoh ho -> do
+            cho <- mconcat `fmap` mapM (f n cur) deps
+            forM_ (hohDepends hoh) $ \_ -> tickProgress cur
hunk ./Ho/Build.hs 427
-            cho <- mconcat `fmap` mapM f deps
+            cho <- mconcat `fmap` mapM (f n cur) deps
hunk ./Ho/Build.hs 433
+            showProgress n cur (snds modules)
}
