Commit 6b0b4ab1 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Add removeFile to Util.hs.

parent 096f6029
......@@ -17,8 +17,6 @@ compilePackage _ target = do
pkg = Target.package target
path = targetPath stage pkg
buildPath = path -/- "build"
cDepsFile = buildPath -/- "c.deps"
hDepsFile = buildPath -/- "haskell.deps"
matchBuildResult buildPath "hi" ?> \hi ->
need [ hi -<.> osuf (detectWay hi) ]
......
......@@ -11,7 +11,6 @@ import Settings.Util
import Settings.TargetDirectory
import Rules.Actions
import Rules.Resources
import qualified System.Directory as IO
buildPackageDependencies :: Resources -> StagePackageTarget -> Rules ()
buildPackageDependencies _ target =
......@@ -31,7 +30,7 @@ buildPackageDependencies _ target =
srcs <- interpret target getPackageSources
need srcs
build $ fullTarget target (GhcM stage) srcs [file]
liftIO . IO.removeFile $ file <.> "bak"
removeFile $ file <.> "bak"
(buildPath -/- ".dependencies") %> \file -> do
cSrcs <- pkgDataList $ CSrcs path
......
......@@ -25,7 +25,7 @@ buildPackageLibrary _ target = do
-- TODO: handle dynamic libraries
matchBuildResult buildPath "a" ?> \a -> do
liftIO $ IO.removeFile a
removeFile a
cSrcs <- interpret target $ getPkgDataList CSrcs
modules <- interpret target $ getPkgDataList Modules
......@@ -34,17 +34,17 @@ buildPackageLibrary _ target = do
cObjs = [ buildPath -/- src -<.> osuf way | src <- cSrcs ]
hObjs = [ buildPath -/- src <.> osuf way | src <- hSrcs ]
-- This will create split objects if required (we don't track them)
-- This will create split objects if required (we don't track them
-- explicitly as this would needlessly bloat the Shake database).
need $ cObjs ++ hObjs
split <- interpret target splitObjects
splitObjs <- if split
then fmap concat $ forM hSrcs $ \src -> do
splitObjs <- if not split then return [] else
fmap concat $ forM hSrcs $ \src -> do
let splitPath = buildPath -/- src ++ "_" ++ osuf way ++ "_split"
contents <- liftIO $ IO.getDirectoryContents splitPath
return . map (splitPath -/-)
. filter (not . all (== '.')) $ contents
else return []
build $ fullTarget target Ar (cObjs ++ hObjs ++ splitObjs) [a]
......
......@@ -5,13 +5,16 @@ module Util (
unifyPath, (-/-),
chunksOfSize,
putColoured, putOracle, putBuild, putSuccess, putError,
bimap, minusOrd, intersectOrd
bimap, minusOrd, intersectOrd,
removeFile
) where
import Base
import Data.Char
import Control.Monad
import System.IO
import System.Console.ANSI
import qualified System.Directory as IO
replaceIf :: (a -> Bool) -> a -> [a] -> [a]
replaceIf p to = map (\from -> if p from then to else from)
......@@ -100,3 +103,10 @@ intersectOrd cmp = loop
LT -> loop xs (y:ys)
EQ -> x : loop xs ys
GT -> loop (x:xs) ys
-- Convenient helper function for removing a single file that doesn't
-- necessarily exist.
removeFile :: FilePath -> Action ()
removeFile file = do
exists <- liftIO $ IO.doesFileExist file
when exists . liftIO $ IO.removeFile file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment