Return correct values for cabalAllTargets.

This commit is contained in:
Alan Zimmerman 2013-09-21 14:01:43 +02:00
parent c570c5b689
commit 93195cb780

View File

@ -13,7 +13,7 @@ import Control.Applicative ((<$>))
import Control.Exception (throwIO) import Control.Exception (throwIO)
import Data.Maybe (maybeToList) import Data.Maybe (maybeToList)
import Data.Set (fromList, toList) import Data.Set (fromList, toList)
import Distribution.ModuleName (toFilePath) import Distribution.ModuleName (ModuleName,toFilePath)
import Distribution.Package (Dependency(Dependency) import Distribution.Package (Dependency(Dependency)
, PackageName(PackageName) , PackageName(PackageName)
, PackageIdentifier(pkgName)) , PackageIdentifier(pkgName))
@ -165,14 +165,26 @@ getGHC = do
-- | Extracting all 'Module' 'FilePath's for libraries, executables, -- | Extracting all 'Module' 'FilePath's for libraries, executables,
-- tests and benchmarks. -- tests and benchmarks.
cabalAllTargets :: PackageDescription -> ([FilePath],[FilePath],[FilePath],[FilePath]) cabalAllTargets :: PackageDescription -> ([String],[String],[String],[String])
cabalAllTargets pd = targets cabalAllTargets pd = targets
where where
lib = case library pd of lib = case library pd of
Nothing -> [] Nothing -> []
Just l -> libModules l Just l -> libModules l
targets = (map toFilePath $ lib, targets = (map toModuleString $ lib,
map modulePath $ executables pd, map (fromFilePath . modulePath) $ executables pd,
map toFilePath $ concatMap testModules $ testSuites pd, -- map toModuleString $ concatMap testModules $ testSuites pd,
map toFilePath $ concatMap benchmarkModules $ benchmarks pd) concatMap getTestTargets $ map testInterface $ testSuites pd,
map toModuleString $ concatMap benchmarkModules $ benchmarks pd)
toModuleString :: ModuleName -> String
toModuleString mn = fromFilePath $ toFilePath mn
fromFilePath :: FilePath -> String
fromFilePath fp = map (\c -> if c=='/' then '.' else c) fp
getTestTargets :: TestSuiteInterface -> [String]
getTestTargets (TestSuiteExeV10 _ filePath) = [fromFilePath filePath]
getTestTargets (TestSuiteLibV09 _ moduleName) = [toModuleString moduleName]
getTestTargets (TestSuiteUnsupported _) = []