aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Ospald <hasufell@posteo.de>2018-04-05 10:48:31 +0200
committerDaniel Gröber <dxld@darkboxed.org>2018-04-05 10:48:31 +0200
commitae568d1008e2dc9980cef86e8a18c7dfaf25fc8d (patch)
tree62fc443ae4c809c5de3f655dabfa9ba1d92cf1de /src
parent0b49461766119598e1ca0721d73e12920a413eaf (diff)
Fix building with Cabal 2.2 (#53)
Diffstat (limited to 'src')
-rw-r--r--src/CabalHelper/Compiletime/Wrapper.hs1
-rw-r--r--src/CabalHelper/Runtime/Main.hs25
-rw-r--r--src/CabalHelper/Shared/Common.hs19
3 files changed, 38 insertions, 7 deletions
diff --git a/src/CabalHelper/Compiletime/Wrapper.hs b/src/CabalHelper/Compiletime/Wrapper.hs
index c667f7d..bee64ee 100644
--- a/src/CabalHelper/Compiletime/Wrapper.hs
+++ b/src/CabalHelper/Compiletime/Wrapper.hs
@@ -35,7 +35,6 @@ import Prelude
import Distribution.System (buildPlatform)
import Distribution.Text (display)
import Distribution.Verbosity (silent, deafening)
-import Distribution.PackageDescription.Parse (readPackageDescription)
import Distribution.Package (packageName, packageVersion)
import Paths_cabal_helper (version)
diff --git a/src/CabalHelper/Runtime/Main.hs b/src/CabalHelper/Runtime/Main.hs
index 48d134a..f46b1d8 100644
--- a/src/CabalHelper/Runtime/Main.hs
+++ b/src/CabalHelper/Runtime/Main.hs
@@ -44,9 +44,6 @@ import Distribution.PackageDescription
, BenchmarkInterface(..)
, withLib
)
-import Distribution.PackageDescription.Parse
- ( readPackageDescription
- )
import Distribution.PackageDescription.Configuration
( flattenPackageDescription
)
@@ -195,6 +192,12 @@ import Distribution.Version
import qualified Distribution.InstalledPackageInfo as Installed
#endif
+#if CH_MIN_VERSION_Cabal(2,2,0)
+import Distribution.Types.GenericPackageDescription
+ ( unFlagAssignment
+ )
+#endif
+
import Control.Applicative ((<$>))
import Control.Arrow (first, second, (&&&))
import Control.Monad
@@ -314,11 +317,23 @@ main = do
"config-flags":[] -> do
return $ Just $ ChResponseFlags $ sort $
- map (first unFlagName) $ configConfigurationsFlags $ configFlags lbi
+ map (first unFlagName)
+#if CH_MIN_VERSION_Cabal(2,2,0)
+ $ unFlagAssignment $ configConfigurationsFlags
+#else
+ $ configConfigurationsFlags
+#endif
+ $ configFlags lbi
"non-default-config-flags":[] -> do
let flagDefinitons = genPackageFlags gpd
- flagAssgnments = configConfigurationsFlags $ configFlags lbi
+ flagAssgnments =
+#if CH_MIN_VERSION_Cabal(2,2,0)
+ unFlagAssignment $ configConfigurationsFlags
+#else
+ configConfigurationsFlags
+#endif
+ $ configFlags lbi
nonDefaultFlags =
[ (flag_name, val)
| MkFlag {flagName=(unFlagName -> flag_name'), flagDefault=def_val} <- flagDefinitons
diff --git a/src/CabalHelper/Shared/Common.hs b/src/CabalHelper/Shared/Common.hs
index 6a12d86..2699496 100644
--- a/src/CabalHelper/Shared/Common.hs
+++ b/src/CabalHelper/Shared/Common.hs
@@ -19,9 +19,14 @@ Description : Shared utility functions
License : AGPL-3
-}
-{-# LANGUAGE DeriveDataTypeable, OverloadedStrings #-}
+{-# LANGUAGE CPP, DeriveDataTypeable, OverloadedStrings #-}
module CabalHelper.Shared.Common where
+#ifdef MIN_VERSION_Cabal
+#undef CH_MIN_VERSION_Cabal
+#define CH_MIN_VERSION_Cabal MIN_VERSION_Cabal
+#endif
+
import Control.Applicative
import Control.Exception as E
import Control.Monad
@@ -33,6 +38,11 @@ import Data.Typeable
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
+#if CH_MIN_VERSION_Cabal(2,2,0)
+import qualified Distribution.PackageDescription.Parsec as P
+#else
+import qualified Distribution.PackageDescription.Parse as P
+#endif
import System.Environment
import System.IO
import qualified System.Info
@@ -130,3 +140,10 @@ replace n r hs' = go "" hs'
reverse acc ++ r ++ drop (length n) h
go acc (h:hs) = go (h:acc) hs
go acc [] = reverse acc
+
+
+#if CH_MIN_VERSION_Cabal(2,2,0)
+readPackageDescription = P.readGenericPackageDescription
+#else
+readPackageDescription = P.readPackageDescription
+#endif