@@ -43,9 +43,9 @@ import Data.Time.Clock (getCurrentTime)
43
43
import Data.Time.Format (formatTime , defaultTimeLocale )
44
44
import Data.Traversable (for )
45
45
import Debug.Trace (trace )
46
- import Distribution.Compiler (CompilerFlavor (.. ))
47
- import Distribution.PackageDescription.Parsec (parseGenericPackageDescription )
48
- import Distribution.Parsec.ParseResult ( runParseResult )
46
+ import Distribution.Compiler (CompilerFlavor (.. ), PerCompilerFlavor )
47
+ import Distribution.PackageDescription.Parsec (parseGenericPackageDescription , runParseResult )
48
+ import Distribution.Parsec.Warning ( PWarning )
49
49
import Distribution.Pretty (prettyShow )
50
50
import Distribution.Simple.Compiler (PackageDB (GlobalPackageDB ))
51
51
import Distribution.Simple.Configure (configCompilerEx , getInstalledPackages )
@@ -54,14 +54,15 @@ import Distribution.Simple.Program.Db (defaultProgramDb)
54
54
import qualified Distribution.System as Dist
55
55
import Distribution.Types.BuildInfo (buildable , cppOptions , defaultExtensions , defaultLanguage , hsSourceDirs , options , targetBuildDepends )
56
56
import Distribution.Types.CondTree (simplifyCondTree )
57
- import Distribution.Types.Dependency (Dependency (.. ), depPkgName )
58
- import Distribution.Types.GenericPackageDescription (ConfVar (Arch , Impl , OS ), condLibrary )
57
+ import Distribution.Types.ConfVar (ConfVar (Arch , Impl , OS ))
58
+ import Distribution.Types.Dependency (Dependency (.. ), depPkgName , depVerRange )
59
+ import Distribution.Types.GenericPackageDescription (condLibrary )
59
60
import Distribution.Types.InstalledPackageInfo (compatPackageKey )
60
61
import Distribution.Types.Library (libBuildInfo )
62
+ import Distribution.Types.LibraryName (LibraryName (.. ))
61
63
import Distribution.Types.PackageName (mkPackageName )
62
64
import Distribution.Types.VersionRange (anyVersion )
63
65
import Distribution.Utils.Generic (toUTF8BS , readUTF8File )
64
- import qualified Distribution.Parsec.Common as Dist
65
66
import qualified Distribution.Verbosity as Verbosity (silent )
66
67
import qualified Hpack.Config as Hpack
67
68
import qualified Hpack.Render as Hpack
@@ -103,7 +104,7 @@ data CabalPackageInfo = CabalPackageInfo
103
104
-- ^ List of globally enable extensions of the library component
104
105
, _cabalPackageInfo_defaultLanguage :: Maybe Language
105
106
-- ^ List of globally set languages of the library component
106
- , _cabalPackageInfo_compilerOptions :: [( CompilerFlavor , [String ]) ]
107
+ , _cabalPackageInfo_compilerOptions :: PerCompilerFlavor [String ]
107
108
-- ^ List of compiler-specific options (e.g., the "ghc-options" field of the cabal file)
108
109
, _cabalPackageInfo_cppOptions :: [String ]
109
110
-- ^ List of CPP (C Preprocessor) options (e.g. the "cpp-options" field of the cabal file)
@@ -338,7 +339,7 @@ parseCabalPackage dir = parseCabalPackage' dir >>= \case
338
339
parseCabalPackage'
339
340
:: (MonadIO m )
340
341
=> FilePath -- ^ Package directory
341
- -> m (Either T. Text (Maybe ([Dist. PWarning ], CabalPackageInfo )))
342
+ -> m (Either T. Text (Maybe ([PWarning ], CabalPackageInfo )))
342
343
parseCabalPackage' pkg = runExceptT $ do
343
344
(cabalContents, packageFile, packageName) <- guessCabalPackageFile pkg >>= \ case
344
345
Left GuessPackageFileError_NotFound -> throwError $ " No .cabal or package.yaml file found in " <> T. pack pkg
@@ -383,7 +384,7 @@ parseCabalPackage' pkg = runExceptT $ do
383
384
}
384
385
Right Nothing -> pure Nothing
385
386
Left (_, errors) ->
386
- throwError $ T. pack $ " Failed to parse " <> packageFile <> " :\n " <> unlines (map show errors)
387
+ throwError $ T. pack $ " Failed to parse " <> packageFile <> " :\n " <> unlines (map show $ toList errors)
387
388
388
389
parsePackagesOrFail :: (MonadObelisk m , Foldable f ) => f FilePath -> m (NE. NonEmpty CabalPackageInfo )
389
390
parsePackagesOrFail dirs' = do
@@ -502,9 +503,9 @@ getGhciSessionSettings (toList -> packageInfos) pathBase useRelativePaths = do
502
503
map (dependencyPackageId installedPackageIndex) $
503
504
filter ((`notElem` packageNames) . depPkgName) $
504
505
concatMap _cabalPackageInfo_buildDepends packageInfos <>
505
- [Dependency (mkPackageName " obelisk-run" ) anyVersion]
506
+ [Dependency (mkPackageName " obelisk-run" ) anyVersion ( Set. singleton LMainLibName ) ]
506
507
dependencyPackageId installedPackageIndex dep =
507
- case lookupDependency installedPackageIndex dep of
508
+ case lookupDependency installedPackageIndex (depPkgName dep) (depVerRange dep) of
508
509
((_version,installedPackageInfo: _) : _) ->
509
510
compatPackageKey installedPackageInfo
510
511
_ -> error $ " Couldn't resolve dependency for " <> prettyShow dep
0 commit comments