Commit d2910ba1 authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Improve zero build performance.

parent 6344510f
......@@ -28,7 +28,7 @@ dependencyListOracle :: Rules ()
dependencyListOracle = do
deps <- newCache $ \file -> do
need [file]
putOracle $ "Reading " ++ file ++ "..."
putOracle $ "Reading dependencies from " ++ file ++ "..."
contents <- parseMakefile <$> (liftIO $ readFile file)
return . Map.fromList
. map (bimap unifyPath (map unifyPath))
......
......@@ -27,37 +27,29 @@ compilePackage _ target = do
need [ hiboot -<.> obootsuf (detectWay hiboot) ]
matchBuildResult buildPath "o" ?> \obj -> do
let way = detectWay obj
cObj = takeFileName obj -<.> "o"
cDeps <- dependencyList cDepsFile cObj
hDeps <- dependencyList hDepsFile obj
let hSrcDeps = filter ("//*hs" ?==) hDeps
when (null cDeps && null hDeps) $
putError $ "Cannot determine sources for '" ++ obj ++ "'."
when (not (null cDeps) && not (null hDeps)) $
putError $ "Both .c and .hs sources found for '" ++ obj ++ "'."
need $ hDeps ++ cDeps
if null cDeps
then build $ fullTargetWithWay target hSrcDeps (Ghc stage) way [obj]
else build $ fullTarget target cDeps (Gcc stage) [obj]
cDeps <- dependencyList cDepsFile (takeFileName obj -<.> "o")
if not (null cDeps)
then do -- obj is produced from a C source file
need cDeps
build $ fullTarget target cDeps (Gcc stage) [obj]
else do -- obj is produced from a Haskell source file
hDeps <- dependencyList hDepsFile obj
when (null hDeps) . putError $
"No dependencies found for '" ++ obj ++ "'."
let way = detectWay obj
hSrc = head hDeps
unless ("//*hs" ?== hSrc) . putError $
"No Haskell source file found for '" ++ obj ++ "'."
need hDeps
build $ fullTargetWithWay target [hSrc] (Ghc stage) way [obj]
matchBuildResult buildPath "o-boot" ?> \obj -> do
let way = detectWay obj
hDeps <- dependencyList hDepsFile obj
let hSrcDeps = filter ("//*hs-boot" ?==) hDeps
when (null hDeps) $
putError $ "Cannot determine sources for '" ++ obj ++ "'."
when (null hDeps) . putError $
"No dependencies found for '" ++ obj ++ "'."
let way = detectWay obj
hSrc = head hDeps
unless ("//*.hs-boot" ?== hSrc) . putError $
"No Haskell source file found for '" ++ obj ++ "'."
need hDeps
build $ fullTargetWithWay target hSrcDeps (Ghc stage) way [obj]
-- TODO: add support for -dyno
-- $1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.hs-boot
-- $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
-- $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno
-- $$(addsuffix .$$(dyn_osuf)-boot,$$(basename $$@)))
build $ fullTargetWithWay target [hSrc] (Ghc stage) way [obj]
......@@ -14,6 +14,7 @@ import Settings.TargetDirectory
import Rules.Actions
import Rules.Resources
import Data.List
import qualified System.Directory as IO
buildPackageLibrary :: Resources -> StagePackageTarget -> Rules ()
buildPackageLibrary _ target = do
......@@ -33,13 +34,16 @@ buildPackageLibrary _ target = do
cObjs = [ buildPath -/- src -<.> osuf way | src <- cSrcs ]
hObjs = [ buildPath -/- src <.> osuf way | src <- hSrcs ]
need $ cObjs ++ hObjs -- this will create split objects if required
-- This will create split objects if required (we don't track them)
need $ cObjs ++ hObjs
split <- interpret target splitObjects
splitObjs <- if split
then fmap concat $ forM hSrcs $ \src -> do
let files = buildPath -/- src ++ "_" ++ osuf way ++ "_split/*"
fmap (map unifyPath) $ getDirectoryFiles "" [files]
let splitPath = buildPath -/- src ++ "_" ++ osuf way ++ "_split"
contents <- liftIO $ IO.getDirectoryContents splitPath
return . map (splitPath -/-)
. filter (not . all (== '.')) $ contents
else return []
build $ fullTarget target (cObjs ++ hObjs ++ splitObjs) Ar [a]
......
......@@ -11,6 +11,11 @@ import Oracles.PackageData
import Settings.Util
import Settings.Ways
-- TODO: add support for -dyno
-- $1/$2/build/%.$$($3_o-bootsuf) : $1/$4/%.hs-boot
-- $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
-- $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno
-- $$(addsuffix .$$(dyn_osuf)-boot,$$(basename $$@)))
-- TODO: check code duplication
ghcArgs :: Args
ghcArgs = stagedBuilder Ghc ? do
......
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