Fix Cabal >= 1.18

This commit is contained in:
Daniel Gröber 2014-05-09 21:12:52 +02:00
parent 175635505d
commit 13930a9d7d
2 changed files with 15 additions and 12 deletions

View File

@ -57,18 +57,25 @@ configDependencies thisPkg config = map fromInstalledPackageId deps
Right ps -> ps
Left msg -> error msg
-- errorExtract = error $
-- "cabalConfigDependencies: Error extracting dependencies from setup-config"
-- True if this dependency is an internal one (depends on the library
-- defined in the same package).
internal pkgid = pkgid == thisPkg
-- Cabal >= 1.18
deps18 :: Either String [InstalledPackageId]
deps18 =
concatMap (map fst . C18.componentPackageDeps . lbi)
map fst
<$> filterInternal
<$> (readEither =<< extractField config "componentsConfigs")
lbi :: (ComponentName, C18.ComponentLocalBuildInfo, [ComponentName])
-> C18.ComponentLocalBuildInfo
lbi (_,i,_) = i
filterInternal
:: [(ComponentName, C18.ComponentLocalBuildInfo, [ComponentName])]
-> [(InstalledPackageId, PackageIdentifier)]
filterInternal ccfg = [ (ipkgid, pkgid)
| (_,clbi,_) <- ccfg
, (ipkgid, pkgid) <- C18.componentPackageDeps clbi
, not (internal pkgid) ]
-- Cabal 1.16 and below
deps16 :: Either String [InstalledPackageId]
@ -81,10 +88,6 @@ configDependencies thisPkg config = map fromInstalledPackageId deps
return $ maybe [] C16.componentPackageDeps libraryConfig
++ concatMap (C16.componentPackageDeps . snd) cbi
where
-- True if this dependency is an internal one (depends on the library
-- defined in the same package).
internal pkgid = pkgid == thisPkg
libraryConfig :: Maybe C16.ComponentLocalBuildInfo
libraryConfig = do
field <- find ("libraryConfig" `isPrefixOf`) (tails config)

View File

@ -13,7 +13,7 @@ module Language.Haskell.GhcMod.GhcPkg (
import Config (cProjectVersionInt)
import Control.Applicative ((<$>))
#if MIN_VERSION_Cabal(1,18,0)
import Control.Exception (SomeException(..))
import qualified Control.Exception as E
#endif
import Data.Char (isSpace)
import Data.List (isPrefixOf, intercalate)
@ -54,7 +54,7 @@ getPackageDbStack :: FilePath -- ^ Project Directory (where the
#if MIN_VERSION_Cabal(1,18,0)
getPackageDbStack cdir =
(getSandboxDb cdir >>= \db -> return [GlobalDb, PackageDb db])
`E.catch` \(_ :: SomeException) -> return [GlobalDb, UserDb]
`E.catch` \(_ :: E.SomeException) -> return [GlobalDb, UserDb]
#else
getPackageDbStack _ =
return [GlobalDb, UserDb]