@@ -14,6 +14,7 @@ module Stack.Solver
1414 , mergeConstraints
1515 , solveExtraDeps
1616 , solveResolverSpec
17+ , checkSnapBuildPlanActual
1718 -- * Internal - for tests
1819 , parseCabalOutputLine
1920 ) where
@@ -647,7 +648,7 @@ solveExtraDeps modStackYaml = do
647648 srcConstraints = mergeConstraints oldSrcs oldSrcFlags
648649 extraConstraints = mergeConstraints oldExtraVersions oldExtraFlags
649650
650- resolverResult <- checkSnapBuildPlan (parent stackYaml) gpds (Just oldSrcFlags) sd
651+ resolverResult <- checkSnapBuildPlanActual (parent stackYaml) gpds (Just oldSrcFlags) sd
651652 resultSpecs <- case resolverResult of
652653 BuildPlanCheckOk flags ->
653654 return $ Just (mergeConstraints oldSrcs flags, Map. empty)
@@ -753,6 +754,31 @@ solveExtraDeps modStackYaml = do
753754 , " - Adjust resolver.\n "
754755 ]
755756
757+ -- | Same as 'checkSnapBuildPLan', but set up a real GHC if needed.
758+ --
759+ -- If we're using a Stackage snapshot, we can use the snapshot hints
760+ -- to determine global library information. This will not be available
761+ -- for custom and GHC resolvers, however. Therefore, we insist that it
762+ -- be installed first. Fortunately, the standard `stack solver`
763+ -- behavior only chooses Stackage snapshots, so the common case will
764+ -- not force the installation of a bunch of GHC versions.
765+ checkSnapBuildPlanActual
766+ :: (HasConfig env , HasGHCVariant env )
767+ => Path Abs Dir -- ^ project root, used for checking out necessary files
768+ -> [C. GenericPackageDescription ]
769+ -> Maybe (Map PackageName (Map FlagName Bool ))
770+ -> SnapshotDef
771+ -> RIO env BuildPlanCheck
772+ checkSnapBuildPlanActual root gpds flags sd = do
773+ let forNonSnapshot = (Just . snd ) <$> setupCabalEnv (sdWantedCompilerVersion sd)
774+ mactualCompiler <-
775+ case sdResolver sd of
776+ ResolverSnapshot _ -> return Nothing
777+ ResolverCompiler _ -> forNonSnapshot
778+ ResolverCustom _ _ -> forNonSnapshot
779+
780+ checkSnapBuildPlan root gpds flags sd mactualCompiler
781+
756782prettyPath
757783 :: forall r t m . (MonadIO m , RelPath (Path r t ) ~ Path Rel t , AnyPath (Path r t ))
758784 => Path r t -> m String
0 commit comments