{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.Simple.Program.Hpc
( markup
, union
) where
import Prelude ()
import Distribution.Compat.Prelude
import System.Directory (makeRelativeToCurrentDirectory)
import Distribution.ModuleName
import Distribution.Simple.Program.Run
import Distribution.Simple.Program.Types
import Distribution.Pretty
import Distribution.Simple.Utils
import Distribution.Verbosity
import Distribution.Version
markup :: ConfiguredProgram
-> Version
-> Verbosity
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> IO ()
markup :: ConfiguredProgram
-> Version
-> Verbosity
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> IO ()
markup ConfiguredProgram
hpc Version
hpcVer Verbosity
verbosity FilePath
tixFile [FilePath]
hpcDirs FilePath
destDir [ModuleName]
included = do
[FilePath]
hpcDirs' <- if Version -> VersionRange -> Bool
withinRange Version
hpcVer (Version -> VersionRange
orLaterVersion Version
version07)
then forall (m :: * -> *) a. Monad m => a -> m a
return [FilePath]
hpcDirs
else do
Verbosity -> FilePath -> IO ()
warn Verbosity
verbosity forall a b. (a -> b) -> a -> b
$ FilePath
"Your version of HPC (" forall a. [a] -> [a] -> [a]
++ forall a. Pretty a => a -> FilePath
prettyShow Version
hpcVer
forall a. [a] -> [a] -> [a]
++ FilePath
") does not properly handle multiple search paths. "
forall a. [a] -> [a] -> [a]
++ FilePath
"Coverage report generation may fail unexpectedly. These "
forall a. [a] -> [a] -> [a]
++ FilePath
"issues are addressed in version 0.7 or later (GHC 7.8 or "
forall a. [a] -> [a] -> [a]
++ FilePath
"later)."
forall a. [a] -> [a] -> [a]
++ if forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FilePath]
droppedDirs
then FilePath
""
else FilePath
" The following search paths have been abandoned: "
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> FilePath
show [FilePath]
droppedDirs
forall (m :: * -> *) a. Monad m => a -> m a
return [FilePath]
passedDirs
[FilePath]
hpcDirs'' <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse FilePath -> IO FilePath
makeRelativeToCurrentDirectory [FilePath]
hpcDirs'
Verbosity -> ProgramInvocation -> IO ()
runProgramInvocation Verbosity
verbosity
(ConfiguredProgram
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> ProgramInvocation
markupInvocation ConfiguredProgram
hpc FilePath
tixFile [FilePath]
hpcDirs'' FilePath
destDir [ModuleName]
included)
where
version07 :: Version
version07 = [Int] -> Version
mkVersion [Int
0, Int
7]
([FilePath]
passedDirs, [FilePath]
droppedDirs) = forall a. Int -> [a] -> ([a], [a])
splitAt Int
1 [FilePath]
hpcDirs
markupInvocation :: ConfiguredProgram
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> ProgramInvocation
markupInvocation :: ConfiguredProgram
-> FilePath
-> [FilePath]
-> FilePath
-> [ModuleName]
-> ProgramInvocation
markupInvocation ConfiguredProgram
hpc FilePath
tixFile [FilePath]
hpcDirs FilePath
destDir [ModuleName]
included =
let args :: [FilePath]
args = [ FilePath
"markup", FilePath
tixFile
, FilePath
"--destdir=" forall a. [a] -> [a] -> [a]
++ FilePath
destDir
]
forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map (FilePath
"--hpcdir=" forall a. [a] -> [a] -> [a]
++) [FilePath]
hpcDirs
forall a. [a] -> [a] -> [a]
++ [FilePath
"--include=" forall a. [a] -> [a] -> [a]
++ forall a. Pretty a => a -> FilePath
prettyShow ModuleName
moduleName
| ModuleName
moduleName <- [ModuleName]
included ]
in ConfiguredProgram -> [FilePath] -> ProgramInvocation
programInvocation ConfiguredProgram
hpc [FilePath]
args
union :: ConfiguredProgram
-> Verbosity
-> [FilePath]
-> FilePath
-> [ModuleName]
-> IO ()
union :: ConfiguredProgram
-> Verbosity -> [FilePath] -> FilePath -> [ModuleName] -> IO ()
union ConfiguredProgram
hpc Verbosity
verbosity [FilePath]
tixFiles FilePath
outFile [ModuleName]
excluded =
Verbosity -> ProgramInvocation -> IO ()
runProgramInvocation Verbosity
verbosity
(ConfiguredProgram
-> [FilePath] -> FilePath -> [ModuleName] -> ProgramInvocation
unionInvocation ConfiguredProgram
hpc [FilePath]
tixFiles FilePath
outFile [ModuleName]
excluded)
unionInvocation :: ConfiguredProgram
-> [FilePath]
-> FilePath
-> [ModuleName]
-> ProgramInvocation
unionInvocation :: ConfiguredProgram
-> [FilePath] -> FilePath -> [ModuleName] -> ProgramInvocation
unionInvocation ConfiguredProgram
hpc [FilePath]
tixFiles FilePath
outFile [ModuleName]
excluded =
ConfiguredProgram -> [FilePath] -> ProgramInvocation
programInvocation ConfiguredProgram
hpc forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ [FilePath
"sum", FilePath
"--union"]
, [FilePath]
tixFiles
, [FilePath
"--output=" forall a. [a] -> [a] -> [a]
++ FilePath
outFile]
, [FilePath
"--exclude=" forall a. [a] -> [a] -> [a]
++ forall a. Pretty a => a -> FilePath
prettyShow ModuleName
moduleName
| ModuleName
moduleName <- [ModuleName]
excluded ]
]