33
44module 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
1010import Data.List ( stripPrefix )
1111import Distribution.ReadE ( ReadE (.. ) )
@@ -26,20 +26,32 @@ import Distribution.Simple.LocalBuildInfo
2626#endif
2727#if MIN_VERSION_Cabal(3,8,1)
2828import 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.
3133import "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
3442import Distribution.Simple.Utils
3543 ( createDirectoryIfMissingVerbose , findPackageDesc )
3644#if MIN_VERSION_Cabal(3,8,1)
3745import 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.
4151import "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
5163import Distribution.Verbosity ( flagToVerbosity )
5264import 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
5369import System.Environment ( getArgs )
5470
5571mainOverride :: 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