Skip to content

Commit

Permalink
Mark packages uninstalled before rebuilding #365
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jun 25, 2015
1 parent 45cc6b7 commit 88b6128
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Bug fixes:

* Haddock links to global packages no longer broken on Windows [#375](https://github.com/commercialhaskell/stack/issues/375)
* Make flags case-insensitive [#397](https://github.com/commercialhaskell/stack/issues/397)
* Mark packages uninstalled before rebuilding [#365](https://github.com/commercialhaskell/stack/issues/365)

## 0.1.0.0

Expand Down
15 changes: 13 additions & 2 deletions src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ module Stack.Build.Cache
, tryGetFlagCache
, deleteCaches
, markExeInstalled
, markExeNotInstalled
, writeFlagCache
, writeBuildCache
, writeConfigCache
, writeCabalMod
) where

import Control.Exception.Enclosed (handleIO, tryIO)
import Control.Exception.Enclosed (catchIO, handleIO, tryIO)
import Control.Monad.Catch (MonadCatch, MonadThrow, catch,
throwM)
import Control.Monad.IO.Class
Expand All @@ -42,7 +43,8 @@ import Stack.Package
import Stack.Types
import System.Directory (createDirectoryIfMissing,
getDirectoryContents,
getModificationTime)
getModificationTime,
removeFile)
import System.IO.Error (isDoesNotExistError)

-- | Directory containing files to mark an executable as installed
Expand Down Expand Up @@ -72,6 +74,15 @@ markExeInstalled loc ident = do
-- longer exist
liftIO $ writeFile fp "Installed"

-- | Mark the given executable as not installed
markExeNotInstalled :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThrow m)
=> InstallLocation -> PackageIdentifier -> m ()
markExeNotInstalled loc ident = do
dir <- exeInstalledDir loc
ident' <- parseRelFile $ packageIdentifierString ident
let fp = toFilePath $ dir </> ident'
liftIO $ catchIO (removeFile fp) (\_ -> return ())

-- | Stored on disk to know whether the flags have changed or any
-- files have changed.
data BuildCache = BuildCache
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ singleBuild ac@ActionContext {..} ee@ExecuteEnv {..} task@Task {..} =
(cache, _neededConfig) <- ensureConfig pkgDir ee task (announce "configure") cabal cabalfp []

fileModTimes <- getPackageFileModTimes package cabalfp
markExeNotInstalled (taskLocation task) taskProvides
writeBuildCache pkgDir fileModTimes

announce "build"
Expand Down

0 comments on commit 88b6128

Please sign in to comment.