From 4e4d27e62d5bad13255bee8e86e7fc03dfb267ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Sun, 4 May 2014 04:56:07 +0200 Subject: [PATCH] Use `componentsConfigs` instead of `configDependencies` `configDependencies` was added in Cabal-1.20 but we're using 1.18 on travis. --- Language/Haskell/GhcMod/CabalApi.hs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Language/Haskell/GhcMod/CabalApi.hs b/Language/Haskell/GhcMod/CabalApi.hs index da438b9..50b6759 100644 --- a/Language/Haskell/GhcMod/CabalApi.hs +++ b/Language/Haskell/GhcMod/CabalApi.hs @@ -37,6 +37,7 @@ import Distribution.Simple.Program (ghcProgram) import Distribution.Simple.Program.Types (programName, programFindVersion) import Distribution.Simple.BuildPaths (defaultDistPref) import Distribution.Simple.Configure (localBuildInfoFile) +import Distribution.Simple.LocalBuildInfo (ComponentName(..),ComponentLocalBuildInfo(..)) import Distribution.System (buildPlatform) import Distribution.Text (display) import Distribution.Verbosity (silent) @@ -226,17 +227,22 @@ cabalConfigPath :: FilePath cabalConfigPath = localBuildInfoFile defaultDistPref cabalConfigDependencies :: CabalConfig -> [Package] -cabalConfigDependencies config = - (fromInstalledPackageId . snd) <$> cfgDepends +cabalConfigDependencies config = cfgDepends where - cfgDepends :: [(PackageName, InstalledPackageId)] - cfgDepends = - case extractCabalSetupConfig "configDependencies" config of - Just x -> x + lbi :: (ComponentName, ComponentLocalBuildInfo, [ComponentName]) + -> ComponentLocalBuildInfo + lbi (_,i,_) = i + components = case extractCabalSetupConfig "componentsConfigs" config of + Just comps -> lbi <$> comps Nothing -> error $ - "cabalConfigDependencies: Extracting field `configDependencies' from" + "cabalConfigDependencies: Extracting field `componentsConfigs' from" ++ " setup-config failed" + pids :: [InstalledPackageId] + pids = fst <$> componentPackageDeps `concatMap` components + cfgDepends = filter (("inplace" /=) . pkgId) + $ fromInstalledPackageId <$> pids + -- | Extract part of cabal's @setup-config@, this is done with a mix of manual -- string processing and use of 'read'. This way we can extract a field from @@ -244,7 +250,7 @@ cabalConfigDependencies config = -- depending on the exact version of Cabal used to configure the project as it -- is rather likley that some part of 'LocalBuildInfo' changed. -- --- Right now 'extractCabalSetupConfig' can only deal with Lists and Tupels in +-- Right now 'extractCabalSetupConfig' can only deal with Lists and Tuples in -- the field! extractCabalSetupConfig :: (Read r) => String -> CabalConfig -> Maybe r extractCabalSetupConfig field config = do