Commit 3344cead authored by Andrey Mokhov's avatar Andrey Mokhov
Browse files

Split compile rules for {hi, o}, clean up code.

parent 9e247b06
......@@ -67,15 +67,17 @@ packageDataOracle = do
-- Oracle for 'path/dist/*.deps' files
dependencyOracle :: Rules ()
dependencyOracle = do
deps <- newCache $ \depFile -> do
need [depFile]
putOracle $ "Parsing " ++ toStandard depFile ++ "..."
contents <- parseMakefile <$> (liftIO $ readFile depFile)
deps <- newCache $ \file -> do
need [file]
putOracle $ "Parsing " ++ file ++ "..."
contents <- parseMakefile <$> (liftIO $ readFile file)
return $ M.fromList
$ map (bimap toStandard (map toStandard))
$ map (bimap head concat . unzip)
$ groupBy ((==) `on` fst)
$ sortBy (compare `on` fst) contents
addOracle $ \(DependencyListKey (file, obj)) -> M.lookup obj <$> deps file
addOracle $ \(DependencyListKey (file, obj)) ->
M.lookup (toStandard obj) <$> deps (toStandard file)
return ()
oracleRules :: Rules ()
......
......@@ -47,10 +47,14 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
forM_ allWays $ \way -> do -- TODO: optimise (too many ways in allWays)
let oPattern = "*." ++ osuf way
let hiPattern = "*." ++ hisuf way
[buildDir <//> oPattern, buildDir <//> hiPattern] |%> \out -> do
(buildDir <//> hiPattern) %> \out -> do
let obj = out -<.> osuf way
need [obj]
(buildDir <//> oPattern) %> \obj -> do
need [argListPath argListDir pkg stage]
let obj = toStandard $ out -<.> osuf way
vanillaObj = toStandard $ out -<.> "o"
let vanillaObj = obj -<.> "o"
-- TODO: keep only vanilla dependencies in hDepFile
hDeps <- args $ DependencyList hDepFile obj
cDeps <- args $ DependencyList cDepFile $ takeFileName vanillaObj
......@@ -59,10 +63,10 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
-- Report impossible cases
when (null $ hSrcs ++ cSrcs)
$ redError_ $ "No source files found for "
++ toStandard out ++ "."
++ toStandard obj ++ "."
when (not (null hSrcs) && not (null cSrcs))
$ redError_ $ "Both c and Haskell sources found for "
++ toStandard out ++ "."
++ toStandard obj ++ "."
-- Build using appropriate compiler
need $ hDeps ++ cDeps
when (not $ null hSrcs)
......@@ -70,6 +74,7 @@ buildRule pkg @ (Package name path _) todo @ (stage, dist, _) =
when (not $ null cSrcs)
$ run (Gcc stage) $ gccArgs pkg todo cSrcs obj
argListRule :: Package -> TodoItem -> Rules ()
argListRule pkg todo @ (stage, _, settings) =
(argListPath argListDir pkg stage) %> \out -> 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