Defining cabalAllTargets.

This is from @alanz (#151).
This commit is contained in:
Kazu Yamamoto 2013-09-20 17:25:28 +09:00
parent 668e9e4771
commit 4426f7fd0f
2 changed files with 19 additions and 0 deletions

View File

@ -6,12 +6,14 @@ module Language.Haskell.GhcMod.CabalApi (
, cabalAllBuildInfo
, cabalDependPackages
, cabalSourceDirs
, cabalAllTargets
) where
import Control.Applicative ((<$>))
import Control.Exception (throwIO)
import Data.Maybe (maybeToList)
import Data.Set (fromList, toList)
import Distribution.ModuleName (toFilePath)
import Distribution.Package (Dependency(Dependency)
, PackageName(PackageName)
, PackageIdentifier(pkgName))
@ -158,3 +160,19 @@ getGHC = do
case mv of
Nothing -> throwIO $ userError "ghc not found"
Just v -> return $ v
----------------------------------------------------------------
-- | Extracting all 'Module' 'FilePath's for libraries, executables,
-- tests and benchmarks.
cabalAllTargets :: PackageDescription -> ([FilePath],[FilePath],[FilePath],[FilePath])
cabalAllTargets pd = targets
where
lib = case library pd of
Nothing -> []
Just l -> libModules l
targets = (map toFilePath $ lib,
map modulePath $ executables pd,
map toFilePath $ concatMap testModules $ testSuites pd,
map toFilePath $ concatMap benchmarkModules $ benchmarks pd)

View File

@ -13,6 +13,7 @@ module Language.Haskell.GhcMod.Internal (
, cabalAllBuildInfo
, cabalDependPackages
, cabalSourceDirs
, cabalAllTargets
-- * GHC API
, canCheckFast
-- * Getting 'DynFlags'