diff options
Diffstat (limited to 'hadrian/src/Hadrian/Haskell/Cabal/Parse.hs')
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs index 12e654cee3..ace24dc87d 100644 --- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs +++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Hadrian.Haskell.Cabal.Parse @@ -38,6 +39,9 @@ import qualified Distribution.Text as C import qualified Distribution.Types.LocalBuildInfo as C import qualified Distribution.Types.CondTree as C import qualified Distribution.Types.MungedPackageId as C +#if MIN_VERSION_Cabal(3,2,0) +import qualified Distribution.Utils.ShortText as C +#endif import qualified Distribution.Verbosity as C import Hadrian.Expression import Hadrian.Haskell.Cabal @@ -69,7 +73,10 @@ parsePackageData pkg = do sorted = sort [ C.unPackageName p | C.Dependency p _ _ <- allDeps ] deps = nubOrd sorted \\ [name] depPkgs = catMaybes $ map findPackageByName deps - return $ PackageData name version (C.synopsis pd) (C.description pd) depPkgs gpd + return $ PackageData name version + (shortTextToString (C.synopsis pd)) + (shortTextToString (C.description pd)) + depPkgs gpd where -- Collect an overapproximation of dependencies by ignoring conditionals collectDeps :: Maybe (C.CondTree v [C.Dependency] a) -> [C.Dependency] @@ -78,6 +85,14 @@ parsePackageData pkg = do where f (C.CondBranch _ t mt) = collectDeps (Just t) ++ collectDeps mt +#if MIN_VERSION_Cabal(3,2,0) + shortTextToString :: C.ShortText -> String + shortTextToString = C.fromShortText +#else + shortTextToString :: String -> String + shortTextToString = id +#endif + -- | Parse the package identifier from a Cabal file. parseCabalPkgId :: FilePath -> IO String parseCabalPkgId file = C.display . C.package . C.packageDescription <$> C.readGenericPackageDescription C.silent file |