@@ -51,7 +51,6 @@ import qualified Data.Set as S
5151import qualified Data.Text as T
5252import Data.Text.Encoding (decodeUtf8 , decodeUtf8With )
5353import Data.Text.Encoding.Error (lenientDecode )
54- import Data.Version (showVersion )
5554import Distribution.Compiler
5655import Distribution.ModuleName (ModuleName )
5756import qualified Distribution.ModuleName as Cabal
@@ -65,7 +64,13 @@ import Distribution.ParseUtils
6564import Distribution.Simple.Utils
6665import Distribution.System (OS (.. ), Arch , Platform (.. ))
6766import qualified Distribution.Text as D
67+ import qualified Distribution.Types.CondTree as Cabal
68+ import qualified Distribution.Types.Dependency as Cabal
69+ import qualified Distribution.Types.ExeDependency as Cabal
70+ import qualified Distribution.Types.LegacyExeDependency as Cabal
71+ import qualified Distribution.Types.UnqualComponentName as Cabal
6872import qualified Distribution.Verbosity as D
73+ import Distribution.Version (showVersion )
6974import qualified Hpack
7075import qualified Hpack.Config as Hpack
7176import Path as FL
@@ -116,7 +121,7 @@ readPackageUnresolvedBS source bs =
116121rawParseGPD :: BS. ByteString
117122 -> Either PError ([PWarning ], GenericPackageDescription )
118123rawParseGPD bs =
119- case parsePackageDescription chars of
124+ case parseGenericPackageDescription chars of
120125 ParseFailed per -> Left per
121126 ParseOk warnings gpkg -> Right (warnings,gpkg)
122127 where
@@ -217,21 +222,24 @@ packageFromPackageDescription packageConfig pkgFlags pkg =
217222 , packageLicense = license pkg
218223 , packageDeps = deps
219224 , packageFiles = pkgFiles
220- , packageTools = packageDescTools pkg
225+ , packageTools = map
226+ (\ (Cabal. ExeDependency name' _ range) -> Cabal. Dependency name' range)
227+ (packageDescTools pkg)
221228 , packageGhcOptions = packageConfigGhcOptions packageConfig
222229 , packageFlags = packageConfigFlags packageConfig
223230 , packageDefaultFlags = M. fromList
224231 [(fromCabalFlagName (flagName flag), flagDefault flag) | flag <- pkgFlags]
225232 , packageAllDeps = S. fromList (M. keys deps)
226233 , packageHasLibrary = maybe False (buildable . libBuildInfo) (library pkg)
227234 , packageTests = M. fromList
228- [(T. pack (testName t), testInterface t) | t <- testSuites pkg
235+ [(T. pack (Cabal. unUnqualComponentName $ testName t), testInterface t) | t <- testSuites pkg
229236 , buildable (testBuildInfo t)]
230237 , packageBenchmarks = S. fromList
231- [T. pack (benchmarkName biBuildInfo) | biBuildInfo <- benchmarks pkg
238+ [T. pack (Cabal. unUnqualComponentName $ benchmarkName biBuildInfo) | biBuildInfo <- benchmarks pkg
232239 , buildable (benchmarkBuildInfo biBuildInfo)]
233240 , packageExes = S. fromList
234- [T. pack (exeName biBuildInfo) | biBuildInfo <- executables pkg
241+ [T. pack (Cabal. unUnqualComponentName $ exeName biBuildInfo)
242+ | biBuildInfo <- executables pkg
235243 , buildable (buildInfo biBuildInfo)]
236244 -- This is an action used to collect info needed for "stack ghci".
237245 -- This info isn't usually needed, so computation of it is deferred.
@@ -338,19 +346,19 @@ generatePkgDescOpts sourceMap installedMap omitPkgs addPkgs cabalfp pkg componen
338346 , fmap
339347 (\ exe ->
340348 generate
341- (CExe (T. pack (exeName exe)))
349+ (CExe (T. pack (Cabal. unUnqualComponentName ( exeName exe) )))
342350 (buildInfo exe))
343351 (executables pkg)
344352 , fmap
345353 (\ bench ->
346354 generate
347- (CBench (T. pack (benchmarkName bench)))
355+ (CBench (T. pack (Cabal. unUnqualComponentName ( benchmarkName bench) )))
348356 (benchmarkBuildInfo bench))
349357 (benchmarks pkg)
350358 , fmap
351359 (\ test ->
352360 generate
353- (CTest (T. pack (testName test)))
361+ (CTest (T. pack (Cabal. unUnqualComponentName ( testName test) )))
354362 (testBuildInfo test))
355363 (testSuites pkg)]))
356364 where
@@ -531,13 +539,13 @@ packageDependencies pkg =
531539packageToolDependencies :: PackageDescription -> Map Text VersionRange
532540packageToolDependencies =
533541 M. fromList .
534- concatMap (fmap (packageNameText . depName &&& depRange ) .
542+ concatMap (fmap (\ ( Cabal. LegacyExeDependency name range) -> ( T. pack name, range) ) .
535543 buildTools) .
536544 allBuildInfo'
537545
538546-- | Get all dependencies of the package (buildable targets only).
539- packageDescTools :: PackageDescription -> [Dependency ]
540- packageDescTools = concatMap buildTools . allBuildInfo'
547+ packageDescTools :: PackageDescription -> [Cabal. ExeDependency ]
548+ packageDescTools = concatMap buildToolDepends . allBuildInfo'
541549
542550-- | This is a copy-paste from Cabal's @allBuildInfo@ function, but with the
543551-- @buildable@ test removed. The implementation is broken.
@@ -551,12 +559,10 @@ allBuildInfo' pkg_descr = [ bi | Just lib <- [library pkg_descr]
551559 , True || buildable bi ]
552560 ++ [ bi | tst <- testSuites pkg_descr
553561 , let bi = testBuildInfo tst
554- , True || buildable bi
555- , testEnabled tst ]
562+ , True || buildable bi ]
556563 ++ [ bi | tst <- benchmarks pkg_descr
557564 , let bi = benchmarkBuildInfo tst
558- , True || buildable bi
559- , benchmarkEnabled tst ]
565+ , True || buildable bi ]
560566
561567-- | Get all files referenced by the package.
562568packageDescModulesAndFiles
@@ -596,9 +602,9 @@ packageDescModulesAndFiles pkg = do
596602 return (modules, files, dfiles, warnings)
597603 where
598604 libComponent = const CLib
599- exeComponent = CExe . T. pack . exeName
600- testComponent = CTest . T. pack . testName
601- benchComponent = CBench . T. pack . benchmarkName
605+ exeComponent = CExe . T. pack . Cabal. unUnqualComponentName . exeName
606+ testComponent = CTest . T. pack . Cabal. unUnqualComponentName . testName
607+ benchComponent = CBench . T. pack . Cabal. unUnqualComponentName . benchmarkName
602608 asModuleAndFileMap label f lib = do
603609 (a,b,c) <- f lib
604610 return (M. singleton (label lib) a, M. singleton (label lib) b, c)
@@ -651,7 +657,7 @@ resolveGlobFiles =
651657--
652658matchDirFileGlob_ :: (MonadLogger m , MonadIO m ) => String -> String -> m [String ]
653659matchDirFileGlob_ dir filepath = case parseFileGlob filepath of
654- Nothing -> liftIO $ die $
660+ Nothing -> liftIO $ throwString $
655661 " invalid file glob '" ++ filepath
656662 ++ " '. Wildcards '*' are only allowed in place of the file"
657663 ++ " name, not in the directory name or file extension."
@@ -681,7 +687,7 @@ benchmarkFiles bench = do
681687 dir <- asks (parent . fst )
682688 (modules,files,warnings) <-
683689 resolveFilesAndDeps
684- (Just $ benchmarkName bench)
690+ (Just $ Cabal. unUnqualComponentName $ benchmarkName bench)
685691 (dirs ++ [dir])
686692 (bnames <> exposed)
687693 haskellModuleExts
@@ -705,7 +711,7 @@ testFiles test = do
705711 dir <- asks (parent . fst )
706712 (modules,files,warnings) <-
707713 resolveFilesAndDeps
708- (Just $ testName test)
714+ (Just $ Cabal. unUnqualComponentName $ testName test)
709715 (dirs ++ [dir])
710716 (bnames <> exposed)
711717 haskellModuleExts
@@ -730,7 +736,7 @@ executableFiles exe = do
730736 dir <- asks (parent . fst )
731737 (modules,files,warnings) <-
732738 resolveFilesAndDeps
733- (Just $ exeName exe)
739+ (Just $ Cabal. unUnqualComponentName $ exeName exe)
734740 (dirs ++ [dir])
735741 (map DotCabalModule (otherModules build) ++
736742 [DotCabalMain (modulePath exe)])
@@ -782,7 +788,7 @@ targetJsSources = jsSources
782788resolvePackageDescription :: PackageConfig
783789 -> GenericPackageDescription
784790 -> PackageDescription
785- resolvePackageDescription packageConfig (GenericPackageDescription desc defaultFlags mlib exes tests benches) =
791+ resolvePackageDescription packageConfig (GenericPackageDescription desc defaultFlags mlib _subLibs _foreignLibs exes tests benches) =
786792 desc {library =
787793 fmap (resolveConditions rc updateLibDeps) mlib
788794 ,executables =
@@ -811,12 +817,18 @@ resolvePackageDescription packageConfig (GenericPackageDescription desc defaultF
811817 (buildInfo exe) {targetBuildDepends = deps}}
812818 updateTestDeps test deps =
813819 test {testBuildInfo =
814- (testBuildInfo test) {targetBuildDepends = deps}
815- ,testEnabled = packageConfigEnableTests packageConfig}
820+ (testBuildInfo test)
821+ { targetBuildDepends = deps
822+ , buildable = packageConfigEnableTests packageConfig
823+ }
824+ }
816825 updateBenchmarkDeps benchmark deps =
817826 benchmark {benchmarkBuildInfo =
818- (benchmarkBuildInfo benchmark) {targetBuildDepends = deps}
819- ,benchmarkEnabled = packageConfigEnableBenchmarks packageConfig}
827+ (benchmarkBuildInfo benchmark)
828+ { targetBuildDepends = deps
829+ , buildable = packageConfigEnableBenchmarks packageConfig
830+ }
831+ }
820832
821833-- | Make a map from a list of flag specifications.
822834--
@@ -854,7 +866,7 @@ resolveConditions :: (Monoid target,Show target)
854866resolveConditions rc addDeps (CondNode lib deps cs) = basic <> children
855867 where basic = addDeps lib deps
856868 children = mconcat (map apply cs)
857- where apply (cond, node, mcs) =
869+ where apply (Cabal. CondBranch cond node mcs) =
858870 if condSatisfied cond
859871 then resolveConditions rc addDeps node
860872 else maybe mempty (resolveConditions rc addDeps) mcs
@@ -1256,10 +1268,10 @@ cabalFilePackageId
12561268 :: (MonadIO m , MonadThrow m )
12571269 => Path Abs File -> m PackageIdentifier
12581270cabalFilePackageId fp = do
1259- pkgDescr <- liftIO (D. readPackageDescription D. silent $ toFilePath fp)
1271+ pkgDescr <- liftIO (D. readGenericPackageDescription D. silent $ toFilePath fp)
12601272 (toStackPI . D. package . D. packageDescription) pkgDescr
12611273 where
1262- toStackPI (D. PackageIdentifier (D. PackageName name) ver) = do
1274+ toStackPI (D. PackageIdentifier (D. unPackageName -> name) ver) = do
12631275 name' <- parsePackageNameFromString name
12641276 ver' <- parseVersionFromString (showVersion ver)
12651277 return (PackageIdentifier name' ver')
0 commit comments