@@ -280,15 +280,15 @@ toActions runInBase ee task@Task {..} =
280280 }
281281 ]
282282
283- singleBuild :: M env m
284- => ActionContext
285- -> ExecuteEnv
286- -> Task
287- -> m ()
288- singleBuild ActionContext { .. } ExecuteEnv { .. } task @ Task { .. } =
289- withPackage $ \ package cabalfp pkgDir ->
290- withLogFile package $ \ mlogFile ->
291- withCabal pkgDir mlogFile $ \ cabal -> do
283+ -- | Ensure that the configuration for the package matches what is given
284+ ensureConfig :: M env m
285+ => Path Abs Dir -- ^ package directory
286+ -> ExecuteEnv
287+ -> Task
288+ -> ( Text -> m () ) -- ^ announce
289+ -> ( Bool -> [ String ] -> m () ) -- ^ cabal
290+ -> m ConfigCache
291+ ensureConfig pkgDir ExecuteEnv { .. } Task { .. } announce cabal = do
292292 -- Determine the old and new configuration in the local directory, to
293293 -- determine if we need to reconfigure.
294294 mOldConfigCache <- tryGetConfigCache pkgDir
@@ -320,6 +320,19 @@ singleBuild ActionContext {..} ExecuteEnv {..} task@Task {..} =
320320 $ logDebug $ T. pack $ show configOpts
321321 writeConfigCache pkgDir newConfigCache
322322
323+ return newConfigCache
324+
325+ singleBuild :: M env m
326+ => ActionContext
327+ -> ExecuteEnv
328+ -> Task
329+ -> m ()
330+ singleBuild ActionContext {.. } ee@ ExecuteEnv {.. } task@ Task {.. } =
331+ withPackage $ \ package cabalfp pkgDir ->
332+ withLogFile package $ \ mlogFile ->
333+ withCabal pkgDir mlogFile $ \ cabal -> do
334+ cache <- ensureConfig pkgDir ee task announce cabal
335+
323336 fileModTimes <- getPackageFileModTimes package cabalfp
324337 writeBuildCache pkgDir fileModTimes
325338
@@ -353,10 +366,7 @@ singleBuild ActionContext {..} ExecuteEnv {..} task@Task {..} =
353366 (packageVersion package)
354367 (True , Nothing ) -> throwM $ Couldn'tFindPkgId $ packageName package
355368 (True , Just pkgid) -> return $ Library pkgid
356- writeFlagCache
357- mpkgid'
358- (map encodeUtf8 configOpts)
359- allDeps
369+ writeFlagCache mpkgid' cache
360370 liftIO $ atomically $ modifyTVar eeGhcPkgIds $ Map. insert taskProvides mpkgid'
361371 where
362372 announce x = $ logInfo $ T. concat
0 commit comments