Skip to content

Commit 8211672

Browse files
committed
Re #6540 Work around Cabal-3.12.0.0 in StackSetupShim.hs
Also accommodates Cabal >= 1.24 and < 2.2 (unlike the current master branch version of Stack).
1 parent 12095c8 commit 8211672

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Release notes:
88

99
Major changes:
1010

11+
* Stack 2.15.5 and earlier cannot build with Cabal (the library) version
12+
`3.12.0.0`. Stack can now build with that Cabal version.
13+
1114
Behaviour changes:
1215

1316
* Stack's `StackSetupShim` executable, when called with `repl` and

src/setup-shim/StackSetupShim.hs

+29-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
module StackSetupShim where
55

6-
-- | Stack no longer supports Cabal < 2.2 and, consequently, GHC versions before
7-
-- GHC 8.4 or base < 4.11.0.0. Consequently, we do not need to test for the
8-
-- existence of the MIN_VERSION_Cabal macro (provided from GHC 8.0).
6+
-- | Stack no longer supports Cabal < 1.24 and, consequently, GHC versions
7+
-- before GHC 8.0 or base < 4.9.0.0. Consequently, we do not need to test for
8+
-- the existence of the MIN_VERSION_Cabal macro (provided from GHC 8.0).
99

1010
import Data.List ( stripPrefix )
1111
import Distribution.ReadE ( ReadE (..) )
@@ -26,20 +26,32 @@ import Distribution.Simple.LocalBuildInfo
2626
#endif
2727
#if MIN_VERSION_Cabal(3,8,1)
2828
import Distribution.Simple.PackageDescription ( readGenericPackageDescription )
29-
#else
30-
-- Avoid confusion with Cabal-syntax module of same name
29+
#elif MIN_VERSION_Cabal(2,2,0)
30+
-- Avoid confusion with Cabal-syntax module of same name.
31+
-- readGenericPackageDescription was exported from module
32+
-- Distribution.PackageDescription.Parsec in Cabal-2.2.0.0.
3133
import "Cabal" Distribution.PackageDescription.Parsec
3234
( readGenericPackageDescription )
35+
#elif MIN_VERSION_Cabal(2,0,0)
36+
-- readPackageDescription was renamed readGenericPackageDescription in
37+
-- Cabal-2.0.0.2.
38+
import Distribution.PackageDescription.Parse ( readGenericPackageDescription )
39+
#else
40+
import Distribution.PackageDescription.Parse ( readPackageDescription )
3341
#endif
3442
import Distribution.Simple.Utils
3543
( createDirectoryIfMissingVerbose, findPackageDesc )
3644
#if MIN_VERSION_Cabal(3,8,1)
3745
import Distribution.Types.GenericPackageDescription
3846
( GenericPackageDescription (..) )
39-
#else
40-
-- Avoid confusion with Cabal-syntax module of same name
47+
#elif MIN_VERSION_Cabal(2,0,0)
48+
-- Avoid confusion with Cabal-syntax module of same name.
49+
-- GenericPackageDescription was exported from module
50+
-- Distribution.Types.GenericPackageDescription in Cabal-2.0.0.2.
4151
import "Cabal" Distribution.Types.GenericPackageDescription
4252
( GenericPackageDescription (..) )
53+
#else
54+
import Distribution.PackageDescription ( GenericPackageDescription (..) )
4355
#endif
4456
-- | Temporary, can be removed if initialBuildSteps restored to Cabal's API.
4557
#if MIN_VERSION_Cabal(3,11,0)
@@ -50,6 +62,10 @@ import Distribution.Verbosity ( Verbosity )
5062
#endif
5163
import Distribution.Verbosity ( flagToVerbosity )
5264
import Main
65+
-- Before base-4.11.0.0 (GHC 8.4.1), <> was not exported by Prelude.
66+
#if !MIN_VERSION_base(4,11,0)
67+
import Data.Semigroup ( (<>) )
68+
#endif
5369
import System.Environment ( getArgs )
5470

5571
mainOverride :: IO ()
@@ -99,7 +115,12 @@ stackReplHook arg1 arg2 = do
99115
msg2 = err
100116
#endif
101117
Right fp -> do
102-
gpd <- readGenericPackageDescription verbosity fp
118+
gpd <-
119+
#if MIN_VERSION_Cabal(2,0,0)
120+
readGenericPackageDescription verbosity fp
121+
#else
122+
readPackageDescription verbosity fp
123+
#endif
103124
let pd = packageDescription gpd
104125
lbi <- getPersistBuildConfig rawBuildDir
105126
initialBuildSteps rawBuildDir pd lbi verbosity

0 commit comments

Comments
 (0)