diff options
author | Julian Ospald <hasufell@posteo.de> | 2018-04-05 10:48:31 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2018-04-05 10:48:31 +0200 |
commit | ae568d1008e2dc9980cef86e8a18c7dfaf25fc8d (patch) | |
tree | 62fc443ae4c809c5de3f655dabfa9ba1d92cf1de | |
parent | 0b49461766119598e1ca0721d73e12920a413eaf (diff) |
Fix building with Cabal 2.2 (#53)
-rw-r--r-- | cabal-helper.cabal | 10 | ||||
-rw-r--r-- | src/CabalHelper/Compiletime/Wrapper.hs | 1 | ||||
-rw-r--r-- | src/CabalHelper/Runtime/Main.hs | 25 | ||||
-rw-r--r-- | src/CabalHelper/Shared/Common.hs | 19 |
4 files changed, 43 insertions, 12 deletions
diff --git a/cabal-helper.cabal b/cabal-helper.cabal index 2643295..98e227c 100644 --- a/cabal-helper.cabal +++ b/cabal-helper.cabal @@ -64,7 +64,7 @@ source-repository head custom-setup setup-depends: base - , Cabal < 2.1 && >= 2.0 || < 1.25 && >= 1.14 + , Cabal < 2.3 && >= 2.0 || < 1.25 && >= 1.14 , filepath < 1.5 , directory < 1.4 @@ -101,7 +101,7 @@ library build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 - build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14 + build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14 , directory < 1.4 && >= 1.1.0.2 , filepath < 1.5 && >= 1.3.0.0 , transformers < 0.6 && >= 0.3.0.0 @@ -145,7 +145,7 @@ executable cabal-helper-wrapper build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 - build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14 + build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.1.0.2 , exceptions < 0.9 && >= 0.8.3 @@ -191,7 +191,7 @@ test-suite compile-test build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 - build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14 + build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.1.0.2 , exceptions < 0.9 && >= 0.8.3 @@ -240,7 +240,7 @@ test-suite ghc-session build-depends: base < 5 && >= 4.5 if os(windows) build-depends: base >= 4.7 - build-depends: Cabal < 2.1 && >= 2.0 || < 1.26 && >= 1.14 + build-depends: Cabal < 2.3 && >= 2.0 || < 1.26 && >= 1.14 , bytestring < 0.11 && >= 0.9.2.1 , directory < 1.4 && >= 1.1.0.2 , exceptions < 0.9 && >= 0.8.3 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 |