Commit 5db0017b authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Factor out build :: Target -> Action () into Rules/Util.hs.

parent 196430d4
...@@ -9,11 +9,10 @@ import Package ...@@ -9,11 +9,10 @@ import Package
import Expression hiding (when, liftIO) import Expression hiding (when, liftIO)
import Oracles.Flag (when) import Oracles.Flag (when)
import Oracles.Builder import Oracles.Builder
import Oracles.ArgsHash
import Settings
import Settings.GhcPkg import Settings.GhcPkg
import Settings.GhcCabal import Settings.GhcCabal
import Settings.TargetDirectory import Settings.TargetDirectory
import Rules.Util
import Util import Util
import Ways import Ways
...@@ -35,27 +34,17 @@ buildPackageData target = ...@@ -35,27 +34,17 @@ buildPackageData target =
] &%> \_ -> do ] &%> \_ -> do
let configure = pkgPath pkg </> "configure" let configure = pkgPath pkg </> "configure"
-- TODO: 1) how to automate this? 2) handle multiple files? -- TODO: 1) how to automate this? 2) handle multiple files?
newTarget = target { getFile = path </> "package-data.mk" } newTarget = target { getFile = path </> "package-data.mk"
, getWay = vanilla } -- TODO: think
-- GhcCabal will run the configure script, so we depend on it -- GhcCabal will run the configure script, so we depend on it
need [pkgPath pkg </> pkgCabal pkg] need [pkgPath pkg </> pkgCabal pkg]
-- We still don't know who built the configure script from configure.ac -- We still don't know who built the configure script from configure.ac
when (doesFileExist $ configure <.> "ac") $ need [configure] when (doesFileExist $ configure <.> "ac") $ need [configure]
run' newTarget GhcCabal build $ newTarget { getBuilder = GhcCabal }
-- TODO: when (registerPackage settings) $ -- TODO: when (registerPackage settings) $
run' newTarget (GhcPkg stage) build $ newTarget { getBuilder = GhcPkg stage }
postProcessPackageData $ path </> "package-data.mk" postProcessPackageData $ path </> "package-data.mk"
-- TODO: This should probably go to Oracles.Builder
run' :: Target -> Builder -> Action ()
run' target builder = do
let finalTarget = target {getBuilder = builder, getWay = vanilla }
args <- interpret finalTarget settings
putColoured Green (show args)
-- The line below forces the rule to be rerun if the hash has changed
argsHash <- askArgsHash finalTarget
putColoured Yellow (show argsHash)
run builder args
-- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile: -- Prepare a given 'packaga-data.mk' file for parsing by readConfigFile:
-- 1) Drop lines containing '$' -- 1) Drop lines containing '$'
-- For example, get rid of -- For example, get rid of
......
module Rules.Util (
build
) where
import Base
import Util
import Settings
import Expression
import Oracles.Builder
import Oracles.ArgsHash
build :: Target -> Action ()
build target = do
args <- interpret target settings
putColoured Green (show target)
putColoured Green (show args)
-- The line below forces the rule to be rerun if the args hash has changed
argsHash <- askArgsHash target
run (getBuilder target) args
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