Skip to content
Open
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
13 changes: 9 additions & 4 deletions src/Development/Shake/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import Prelude

import Development.Shake.Internal.CmdOption
import Development.Shake.Internal.Core.Action
import Development.Shake.Internal.Core.Monad
import Development.Shake.Internal.Core.Types hiding (Result)
import Development.Shake.FilePath
import Development.Shake.Internal.Options
Expand Down Expand Up @@ -313,18 +314,22 @@ commandExplicitAction oparams = do

autodeps act = do
ResultFSATrace pxs : res <- act params{opts = addFSAOptions "rwm" opts, results = ResultFSATrace [] : results}
Local{localProduces} <- Action getRW
let written = Set.fromList $ [x | FSAMove x _ <- pxs] ++ [x | FSAWrite x <- pxs]
-- If something both reads and writes to a file, it isn't eligible to be an autodeps
xs <- liftIO $ filterM doesFileExist [x | FSARead x <- pxs, not $ x `Set.member` written]
cwd <- liftIO getCurrentDirectory
temp <- fixPaths cwd xs
unsafeAllowApply $ need temp
-- Outputs can't be autodeps.
let outputs = Set.fromList $ snd <$> localProduces
inputs = filter (not . (`Set.member` outputs)) temp
unsafeAllowApply $ need inputs
pure res

fixPaths cwd xs = liftIO $ do
xs<- pure $ map toStandard xs
xs<- pure $ filter (\x -> any (`isPrefixOf` x) shakeLintInside) xs
mapM (\x -> fromMaybe x <$> makeRelativeEx cwd x) xs
let standard = map toStandard xs
inside = filter (\x -> any (`isPrefixOf` x) shakeLintInside) standard
mapM (\x -> fromMaybe x <$> makeRelativeEx cwd x) inside

fsalint act = do
ResultFSATrace xs : res <- act params{opts = addFSAOptions "rwm" opts, results = ResultFSATrace [] : results}
Expand Down