summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2020-03-27 14:06:39 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2020-03-31 11:54:19 -0400
commit394c9c4b2a338663656e054767c3f0205732dfcb (patch)
treee1fda5f90433ae8e05d68ac9b8f4aa676a1e3502
parent4b9c586472bf99425f7bbcf346472d7c54f05028 (diff)
downloadhaskell-wip/hadrian-8.10.tar.gz
Make Hadrian build with Cabal-3.2wip/hadrian-8.10
GHC 8.10 ships with `Cabal-3.2.0.0`, so it would be convenient to make Hadrian supporting building against 3.2.* instead of having to rebuild the entirety of `Cabal-3.0.0.0`. There is one API change in `Cabal-3.2.*` that affects Hadrian: the `synopsis` and `description` functions now return `ShortText` instead of `String`. Since Hadrian manipulates these `String`s in various places, I found that the simplest fix was to use CPP to convert `ShortText` to `String`s where appropriate.
-rw-r--r--hadrian/hadrian.cabal2
-rw-r--r--hadrian/src/Hadrian/Haskell/Cabal/Parse.hs17
-rw-r--r--hadrian/src/Rules/Library.hs2
3 files changed, 18 insertions, 3 deletions
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index dd95e88299..8e3a9289d4 100644
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -133,7 +133,7 @@ executable hadrian
other-extensions: MultiParamTypeClasses
, TypeFamilies
build-depends: base >= 4.8 && < 5
- , Cabal >= 3.0 && < 3.1
+ , Cabal >= 3.0 && < 3.3
, containers >= 0.5 && < 0.7
, directory >= 1.3.1.0 && < 1.4
, extra >= 1.4.7
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
diff --git a/hadrian/src/Rules/Library.hs b/hadrian/src/Rules/Library.hs
index 5f839215dc..066f609a49 100644
--- a/hadrian/src/Rules/Library.hs
+++ b/hadrian/src/Rules/Library.hs
@@ -140,7 +140,7 @@ extraObjects context
-- | Return all the object files to be put into the library we're building for
-- the given 'Context'.
libraryObjects :: Context -> Action [FilePath]
-libraryObjects context@Context{..} = do
+libraryObjects context = do
hsObjs <- hsObjects context
noHsObjs <- nonHsObjects context
need $ noHsObjs ++ hsObjs