Fixing hpc tools for 6.2 and 6.4
authorandy@galois.com <unknown>
Fri, 29 Jun 2007 18:53:07 +0000 (18:53 +0000)
committerandy@galois.com <unknown>
Fri, 29 Jun 2007 18:53:07 +0000 (18:53 +0000)
utils/hpc/Hpc.hs
utils/hpc/HpcCombine.hs
utils/hpc/HpcFlags.hs
utils/hpc/HpcMap.hs [new file with mode: 0644]
utils/hpc/HpcMarkup.hs
utils/hpc/HpcReport.hs
utils/hpc/HpcSet.hs [new file with mode: 0644]
utils/hpc/Makefile

index 786323f..d567a0f 100644 (file)
@@ -116,4 +116,4 @@ version_plugin = Plugin { name = "version"
 version_main _ _ = putStrLn $ "hpc tools, version 0.5-dev"
 
 
-------------------------------------------------------------------------------
\ No newline at end of file
+------------------------------------------------------------------------------
index 193b03c..d16ace9 100644 (file)
@@ -11,9 +11,8 @@ import Trace.Hpc.Util
 import HpcFlags
 
 import Control.Monad
-import qualified Data.Map as Map
-import qualified Data.Set as Set
-
+import qualified HpcSet as Set
+import qualified HpcMap as Map
 import System.Environment
 
 ------------------------------------------------------------------------------
index cb561a6..607b1a8 100644 (file)
@@ -4,7 +4,7 @@ module HpcFlags where
 
 import System.Console.GetOpt
 import Data.Maybe ( fromMaybe )
-import qualified Data.Set as Set
+import qualified HpcSet as Set
 import Data.Char
 import Trace.Hpc.Tix
 
diff --git a/utils/hpc/HpcMap.hs b/utils/hpc/HpcMap.hs
new file mode 100644 (file)
index 0000000..adcc489
--- /dev/null
@@ -0,0 +1,27 @@
+module HpcMap ( module HpcMap ) where
+
+#if __GLASGOW_HASKELL__ < 604
+import qualified Data.FiniteMap as Map
+#else
+import qualified Data.Map as Map
+#endif
+
+
+lookup :: Ord key => key -> Map key elt -> Maybe elt
+fromList :: Ord key => [(key,elt)] -> Map key elt
+
+
+#if __GLASGOW_HASKELL__ < 604
+type Map key elt = Map.FiniteMap key elt
+
+lookup = flip Map.lookupFM
+fromList = Map.listToFM 
+
+#else
+
+type Map key elt = Map.Map key elt
+
+lookup = Map.lookup
+fromList = Map.fromList
+
+#endif
index a46fd79..001ec29 100644 (file)
@@ -16,14 +16,16 @@ 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"
@@ -56,8 +58,10 @@ 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
index 2c502f4..8f063f8 100644 (file)
@@ -13,7 +13,7 @@ import HpcFlags
 import Trace.Hpc.Mix
 import Trace.Hpc.Tix
 import Control.Monad hiding (guard)
-import qualified Data.Set as Set
+import qualified HpcSet as Set
 
 notExpecting :: String -> a
 notExpecting s = error ("not expecting "++s)
diff --git a/utils/hpc/HpcSet.hs b/utils/hpc/HpcSet.hs
new file mode 100644 (file)
index 0000000..d5dfe38
--- /dev/null
@@ -0,0 +1,39 @@
+module HpcSet (        module HpcSet ) where 
+
+import qualified Data.Set as Set
+
+type Set a = Set.Set a
+
+empty  :: Set a
+insert :: (Ord a) => a -> Set a -> Set a
+member :: (Ord a) => a -> Set a -> Bool
+null   :: Set a -> Bool
+intersection :: Ord a => Set a -> Set a -> Set a
+fromList :: Ord a => [a] -> Set a
+toList :: Set a -> [a]
+union :: Ord a => Set a -> Set a -> Set a
+
+#if __GLASGOW_HASKELL__ < 604
+
+empty  = Set.emptySet
+insert = flip Set.addToSet
+member = Set.elementOf
+null   = Set.isEmptySet
+intersection = Set.intersect
+fromList = Set.mkSet
+toList = Set.setToList
+union = Set.union
+
+#else
+
+empty  = Set.empty
+insert = Set.insert
+member = Set.member
+null   = Set.null
+intersection = Set.intersection
+fromList = Set.fromList
+toList = Set.toList
+union = Set.union
+
+#endif
+
index 12ad17e..affa240 100644 (file)
@@ -6,7 +6,7 @@ INSTALL_PROGS  += $(HS_PROG)
 HPC_LIB         = $(TOP)/libraries/hpc
 
 include $(GHC_COMPAT_DIR)/compat.mk
-SRC_HC_OPTS += $(PACKAGE_HPC)
+SRC_HC_OPTS += $(PACKAGE_HPC) -cpp 
 
 binary-dist:
        $(INSTALL_DIR)                $(BIN_DIST_DIR)/utils/hpc