@@ -753,7 +753,7 @@ toActions installedMap runInBase ee (mbuild, mfinal) =
753753getConfigCache :: (StackM env m , HasEnvConfig env )
754754 => ExecuteEnv m -> Task -> InstalledMap -> Bool -> Bool
755755 -> m (Map PackageIdentifier GhcPkgId , ConfigCache )
756- getConfigCache ExecuteEnv {.. } Task {.. } installedMap enableTest enableBench = do
756+ getConfigCache ExecuteEnv {.. } task @ Task {.. } installedMap enableTest enableBench = do
757757 useExactConf <- view $ configL. to configAllowNewer
758758 let extra =
759759 -- We enable tests if the test suite dependencies are already
@@ -772,9 +772,16 @@ getConfigCache ExecuteEnv {..} Task {..} installedMap enableTest enableBench = d
772772 idMap <- liftIO $ readTVarIO eeGhcPkgIds
773773 let getMissing ident =
774774 case Map. lookup ident idMap of
775- Nothing -> error " singleBuild: invariant violated, missing package ID missing"
776- Just (Library ident' x) -> assert (ident == ident') $ Just (ident, x)
777- Just (Executable _) -> Nothing
775+ Nothing
776+ -- Expect to instead find it in installedMap if it's
777+ -- an initialBuildSteps target.
778+ | boptsCLIInitialBuildSteps eeBuildOptsCLI && taskIsTarget task,
779+ Just (_, installed) <- Map. lookup (packageIdentifierName ident) installedMap
780+ -> installedToGhcPkgId ident installed
781+ Just installed -> installedToGhcPkgId ident installed
782+ _ -> error " singleBuild: invariant violated, missing package ID missing"
783+ installedToGhcPkgId ident (Library ident' x) = assert (ident == ident') $ Just (ident, x)
784+ installedToGhcPkgId _ (Executable _) = Nothing
778785 missing' = Map. fromList $ mapMaybe getMissing $ Set. toList missing
779786 TaskConfigOpts missing mkOpts = taskConfigOpts
780787 opts = mkOpts missing'
@@ -1294,23 +1301,25 @@ singleBuild runInBase ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} in
12941301 $ \ package cabalfp pkgDir cabal announce _console _mlogFile -> do
12951302 _neededConfig <- ensureConfig cache pkgDir ee (announce (" configure" <> annSuffix)) cabal cabalfp
12961303
1304+ let installedMapHasThisPkg :: Bool
1305+ installedMapHasThisPkg =
1306+ case Map. lookup (packageName package) installedMap of
1307+ Just (_, Library ident _) -> ident == taskProvides
1308+ Just (_, Executable _) -> True
1309+ _ -> False
1310+
12971311 case ( boptsCLIOnlyConfigure eeBuildOptsCLI
1298- , boptsCLIInitialBuildSteps eeBuildOptsCLI && isTarget
1299- , acDownstream) of
1312+ , boptsCLIInitialBuildSteps eeBuildOptsCLI && taskIsTarget task) of
13001313 -- A full build is done if there are downstream actions,
13011314 -- because their configure step will require that this
13021315 -- package is built. See
13031316 -- https://github.com/commercialhaskell/stack/issues/2787
1304- (True , _, [] ) -> return Nothing
1305- (_, True , [] ) -> do
1317+ (True , _) | null acDownstream -> return Nothing
1318+ (_, True ) | null acDownstream || installedMapHasThisPkg -> do
13061319 initialBuildSteps cabal announce
13071320 return Nothing
13081321 _ -> liftM Just $ realBuild cache package pkgDir cabal announce
13091322
1310- isTarget = case taskType of
1311- TTLocal lp -> lpWanted lp
1312- _ -> False
1313-
13141323 initialBuildSteps cabal announce = do
13151324 () <- announce (" initial-build-steps" <> annSuffix)
13161325 cabal False [" repl" , " stack-initial-build-steps" ]
0 commit comments