Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Database (clearRedoTempDirectory, initializeTargetDatabase, hasAlwaysDep,
getStdoutFile, getTempFile, markBuilt, isBuilt, markErrored, isErrored) where

import Control.Exception (catch, SomeException(..))
import Control.Monad (when)
import qualified Data.ByteString.Char8 as BS
import Crypto.Hash (hashWith, MD5(..), Digest)
import qualified Data.ByteArray
Expand Down Expand Up @@ -377,7 +378,16 @@ createRedoTempDirectory = do
-- dependencies hanging around if we are rebuilding a file.
initializeTargetDatabase :: Key -> DoFile -> IO ()
initializeTargetDatabase key doFile = withDatabaseLock key func
where func = do refreshDatabase key
where func = do -- Diagnostic: warn if we're about to overwrite a source-marked
-- database. This should never happen during normal builds — it
-- means a file that redo knows is a source is being treated as
-- a build target. Logging this will help diagnose the root cause
-- of "No rule to build" errors for source files.
wasSource <- doesEntryExist =<< getSourceEntry key
when wasSource $ putWarningStrLn $
"Warning: initializeTargetDatabase is overwriting a source-marked database " ++
"(do file: " ++ unDoFile doFile ++ "). This may corrupt redo state."
refreshDatabase key
-- Write out .do script as dependency:
storeIfChangeDep' key (Target $ unDoFile doFile)
-- Cache the do file:
Expand Down
Loading