Warning Police: Unused imports
[ghc-hetmet.git] / utils / hpc / HpcMarkup.hs
index 53eaf32..d4f4ee6 100644 (file)
@@ -11,18 +11,20 @@ import Trace.Hpc.Util
 
 import HpcFlags
 
-import System.Environment
+import System.Directory
 import Data.List
 import Data.Maybe(fromJust)
 import Data.Array
-import qualified Data.Set as Set
+import qualified HpcSet as Set
 
 ------------------------------------------------------------------------------
 
 markup_options = 
   [ excludeOpt,includeOpt,hpcDirOpt,hsDirOpt,funTotalsOpt
   , altHighlightOpt
+#if __GLASGOW_HASKELL__ >= 604 
   , destDirOpt
+#endif
   ]
                 
 markup_plugin = Plugin { name = "markup"
@@ -55,6 +57,11 @@ markup_main flags (prog:modNames) = do
     Nothing -> error $ "unable to find tix file for: " ++ prog
     Just a -> return a
 
+#if __GLASGOW_HASKELL__ >= 604 
+  -- create the dest_dir if needed
+  createDirectoryIfMissing True dest_dir
+#endif
+
   mods <-
      sequence [ genHtmlFromMod dest_dir hpcDirs tix theFunTotals theHsPath invertOutput
              | tix <- tixs
@@ -68,6 +75,9 @@ markup_main flags (prog:modNames) = do
 
   let writeSummary name cmp = do
         let mods' = sortBy cmp mods
+
+
+
    
         putStrLn $ "Writing: " ++ (name ++ ".html")
         writeFile (dest_dir ++ "/" ++ name ++ ".html") $ 
@@ -75,6 +85,7 @@ markup_main flags (prog:modNames) = do
            "<style type=\"text/css\">" ++
            "table.bar { background-color: #f25913; }\n" ++
            "td.bar { background-color: #60de51;  }\n" ++
+           "td.invbar { background-color: #f25913;  }\n" ++
            "table.dashboard { border-collapse: collapse  ; border: solid 1px black }\n" ++
            ".dashboard td { border: solid 1px black }\n" ++
            ".dashboard th { border: solid 1px black }\n" ++
@@ -411,14 +422,16 @@ showSummary ticked total =
                "<td width=100>" ++ 
                    (case percent ticked total of
                       Nothing -> "&nbsp;"
-                      Just w -> "<table cellpadding=0 cellspacing=0 width=\"100\" class=\"bar\">" ++
-                                    "<tr><td><table cellpadding=0 cellspacing=0 width=\"" ++ show w ++ "%\">" ++
-                             "<tr><td height=12 class=\"bar\"></td></tr>" ++
-                             "</table></td></tr></table>")
-                             ++ "</td>"
+                      Just w -> bar w "bar"
+                    )  ++ "</td>"
      where
         showP Nothing = "-&nbsp;"
         showP (Just x) = show x ++ "%"
+        bar 0 inner = bar 100 "invbar"
+        bar w inner = "<table cellpadding=0 cellspacing=0 width=\"100\" class=\"bar\">" ++
+                        "<tr><td><table cellpadding=0 cellspacing=0 width=\"" ++ show w ++ "%\">" ++
+                             "<tr><td height=12 class=" ++ show inner ++ "></td></tr>" ++
+                             "</table></td></tr></table>"
 
 percent :: (Integral a) => a -> a -> Maybe a
 percent ticked total = if total == 0 then Nothing else Just (ticked * 100 `div` total)