Skip to content

Commit

Permalink
Offload some work from AutoDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
jacereda committed Nov 12, 2015
1 parent c987533 commit fe1c4f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/Development/Shake/Args.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Paths_shake
import Development.Shake.Types
import Development.Shake.Core
import Development.Shake.Demo
import Development.Shake.FilePath
import Development.Shake.Rules.File
import Development.Shake.Progress
import Development.Shake.Shake
Expand Down Expand Up @@ -115,7 +116,12 @@ shakeArgsWith baseOpts userOptions rules = do
progressRecords = [x | ProgressRecord x <- flagsExtra]
changeDirectory = listToMaybe [x | ChangeDirectory x <- flagsExtra]
printDirectory = last $ False : [x | PrintDirectory x <- flagsExtra]
shakeOpts = foldl' (flip ($)) baseOpts flagsShake
oshakeOpts = foldl' (flip ($)) baseOpts flagsShake
shakeOpts = oshakeOpts {shakeLintInside = map (toStandard . normalise . addTrailingPathSeparator) $
shakeLintInside oshakeOpts
,shakeLintIgnore = map toStandard $
shakeLintIgnore oshakeOpts
}

-- error if you pass some clean and some dirty with specific flags
errs <- return $ errs ++ flagsError ++ ["cannot mix " ++ a ++ " and " ++ b | a:b:_ <-
Expand Down
4 changes: 2 additions & 2 deletions src/Development/Shake/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ commandExplicit funcName icopts results exe args = do
Just LintFSATrace -> fsatrace act
_ -> if autodepping then autodeps act else act exe args
autodepping = AutoDeps `elem` copts
inside = map (toStandard . addTrailingPathSeparator . normalise) $ shakeLintInside opts
inside = shakeLintInside opts
ignore = map (?==) $ shakeLintIgnore opts
ham cwd xs = [makeRelative cwd x | x <- map toStandard xs
, any (`isPrefixOf` x) inside
Expand Down Expand Up @@ -158,7 +158,7 @@ commandExplicit funcName icopts results exe args = do
cwd <- liftIO getCurrentDirectory
let reader (FSATRead x) = x
reader _ = error "autodeps"
needed $ ham cwd $ map reader xs
needNorm $ ham cwd $ map reader xs
return res

skipper $ tracker $ \exe args -> verboser $ tracer $ commandExplicitIO funcName copts results exe args
Expand Down
5 changes: 4 additions & 1 deletion src/Development/Shake/Rules/File.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE ViewPatterns #-}

module Development.Shake.Rules.File(
need, needBS, needed, neededBS, want,
need, needBS, needed, neededBS, needNorm, want,
trackRead, trackWrite, trackAllow,
defaultRuleFile,
(%>), (|%>), (?>), phony, (~>), phonys,
Expand Down Expand Up @@ -116,6 +116,9 @@ defaultRuleFile = priority 0 $ rule $ \x -> Just $ do
need :: [FilePath] -> Action ()
need xs = (apply $ map (FileQ . packU_ . filepathNormalise . unpackU_ . packU) xs :: Action [FileA]) >> return ()

needNorm :: [FilePath] -> Action ()
needNorm xs = (apply $ map (FileQ . packU) xs :: Action [FileA]) >> return ()

needBS :: [BS.ByteString] -> Action ()
needBS xs = (apply $ map (FileQ . packU_ . filepathNormalise) xs :: Action [FileA]) >> return ()

Expand Down
3 changes: 1 addition & 2 deletions src/Test/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ shaken test rules sleeper = do
,shakeReport = ["output/" ++ name ++ "/report.html"]
,shakeLint = Just t
,shakeLintInside = [cwd]
,shakeLintIgnore = map (toStandard (normalise cwd) </>)
[".cabal-sandbox//",".stack-work//"]
,shakeLintIgnore = map (cwd </>) [".cabal-sandbox//",".stack-work//"]
})
-- if you have passed sleep, supress the "no errors" warning
(do rules files obj; when ("--sleep" `elem` args) $ action $ return ())
Expand Down

0 comments on commit fe1c4f4

Please sign in to comment.