Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputs can't be autodeps, fixes #818 #820

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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