module Distribution.Simple.Program.Hpc
( markup
, union
) where
import Prelude ()
import Distribution.Compat.Prelude
import Control.Monad (mapM)
import System.Directory (makeRelativeToCurrentDirectory)
import Distribution.ModuleName
import Distribution.Simple.Program.Run
import Distribution.Simple.Program.Types
import Distribution.Text
import Distribution.Simple.Utils
import Distribution.Verbosity
import Distribution.Version
markup :: ConfiguredProgram
-> Version
-> Verbosity
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> IO ()
markup hpc hpcVer verbosity tixFile hpcDirs destDir excluded = do
hpcDirs' <- if withinRange hpcVer (orLaterVersion version07)
then return hpcDirs
else do
warn verbosity $ "Your version of HPC (" ++ display hpcVer
++ ") does not properly handle multiple search paths. "
++ "Coverage report generation may fail unexpectedly. These "
++ "issues are addressed in version 0.7 or later (GHC 7.8 or "
++ "later)."
++ if null droppedDirs
then ""
else " The following search paths have been abandoned: "
++ show droppedDirs
return passedDirs
hpcDirs'' <- mapM makeRelativeToCurrentDirectory hpcDirs'
runProgramInvocation verbosity
(markupInvocation hpc tixFile hpcDirs'' destDir excluded)
where
version07 = mkVersion [0, 7]
(passedDirs, droppedDirs) = splitAt 1 hpcDirs
markupInvocation :: ConfiguredProgram
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> ProgramInvocation
markupInvocation hpc tixFile hpcDirs destDir excluded =
let args = [ "markup", tixFile
, "--destdir=" ++ destDir
]
++ map ("--hpcdir=" ++) hpcDirs
++ ["--exclude=" ++ display moduleName
| moduleName <- excluded ]
in programInvocation hpc args
union :: ConfiguredProgram
-> Verbosity
-> [FilePath]
-> FilePath
-> [ModuleName]
-> IO ()
union hpc verbosity tixFiles outFile excluded =
runProgramInvocation verbosity
(unionInvocation hpc tixFiles outFile excluded)
unionInvocation :: ConfiguredProgram
-> [FilePath]
-> FilePath
-> [ModuleName]
-> ProgramInvocation
unionInvocation hpc tixFiles outFile excluded =
programInvocation hpc $ concat
[ ["sum", "--union"]
, tixFiles
, ["--output=" ++ outFile]
, ["--exclude=" ++ display moduleName
| moduleName <- excluded ]
]