Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with Cabal-2.2.0.x #51

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cabal-helper.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cabal-helper
version: 0.8.0.2
version: 0.8.0.3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we ought to at least do a minor version bump for new Cabal version support. I'd actually prefer to bump the version myself since its part of the release process if you don't mind.

synopsis:
Simple interface to some of Cabal's configuration state, mainly used by ghc-mod
description:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/CabalHelper/Compiletime/Wrapper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 21 additions & 5 deletions src/CabalHelper/Runtime/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ import Distribution.PackageDescription
, BenchmarkInterface(..)
, withLib
)
import Distribution.PackageDescription.Parse
( readPackageDescription
)
import Distribution.PackageDescription.Configuration
( flattenPackageDescription
)
Expand Down Expand Up @@ -195,6 +192,13 @@ import Distribution.Version
import qualified Distribution.InstalledPackageInfo as Installed
#endif

#if CH_MIN_VERSION_Cabal(2,2,0)
import Distribution.Types.GenericPackageDescription
(
unFlagAssignment
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep to the surrounding code style.

#endif

import Control.Applicative ((<$>))
import Control.Arrow (first, second, (&&&))
import Control.Monad
Expand Down Expand Up @@ -314,11 +318,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
Expand Down
19 changes: 18 additions & 1 deletion src/CabalHelper/Shared/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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