Commit a055a8a4 authored by Andreas Klebinger's avatar Andreas Klebinger

Fix dependency derivation on windows

parent 00d0c17e
......@@ -29,6 +29,7 @@ import Measurements (Measurements, Label(..))
import qualified ParseResults
import qualified CachegrindParse
import qualified PerfStatParse
-- import Debug.Trace
-- | A handy shortcut.
ml :: String -> Label
......@@ -39,8 +40,10 @@ ml = Ms.mkLabel
-- | These are directories that contain tests.
testRoots :: [String]
testRoots = words "imaginary spectral real parallel spectral/hartel gc"
testRoots = words "imaginary spectral real shootout parallel gc smp"
defaultRoots :: [String]
defaultRoots = words "imaginary spectral real shootout"
-- -- | These are tests that are under testRoots, but should be skipped (all are skipped by the Makefile system)
-- disabledTests :: [TestName]
......@@ -123,11 +126,12 @@ main = do
, shakeVerbosity = Development.Shake.Loud
}
-- print shakeOpts
shake shakeOpts $ buildRules (args {tests = tests'})
putStrLn "Build completed"
-- | Rules to build the given tests. For each test, there are three files
-- | Rules to build the given tests. For each test, these are the files
-- we care about:
--
-- * config.txt - a cleaned up version of the configuration out of Makefile,
......@@ -136,7 +140,7 @@ main = do
--
-- * Main.exe - the actual binary, produced by ghc linking everything.
--
-- * Main.deps - the files that Main.exe depends on, ghc -M.
-- * .depend - lists all .o files required and their dependencies. Created by ghc -M.
--
-- * .hi/.o - files produced by ghc -c.
--
......@@ -233,7 +237,7 @@ buildRules nofib@Build{..} = do
-- Link executable
["//Main" <.> exe, "//Main.link.tsv"] &%> \[out, resultsTsv] -> do
deps <- readFile' $ replaceExtension out "deps"
deps <- readFile' $ replaceFileName out ".depends"
let objs = nub [ if isLower $ head $ takeFileName x then replaceExtension out "o" else output </> x
| x <- words deps, takeExtension x == ".o"]
need objs
......@@ -260,6 +264,10 @@ buildRules nofib@Build{..} = do
-- Compile object code
["//*.o","//*.hi","//*.o.compile.tsv"] &%> \[o, _hi, resultsTsv] -> do
-- deps <- readFile' $ replaceExtension out "deps"
-- IO\.listDirectory root
liftIO $ print o
let test = unoutput o
dir = testDir test
obj = output </> dir
......@@ -275,11 +283,27 @@ buildRules nofib@Build{..} = do
return $ dir </> modName <.> (if b then "hs" else "lhs")
-- Figure out build dependencies
deps <- readFileLines $ obj </> "Main.deps"
need [ if takeExtension r `elem` [".h",".hs",".lhs"] then r else output </> r
| lhs:":":rhs <- map words $ deps, dir </> modName <.> "o" == lhs
, r <- rhs
deps <- readFileLines $ obj </> ".depends"
liftIO $ print "deps:"
liftIO $ print deps
let mkNeed rhs =
if takeExtension rhs `elem` [".h",".hs",".lhs"]
then replaceExtension rhs ".o"
else output </> rhs
let needs = [ mkNeed r
| lhs:":":rhss <- map words $ deps
, -- equalFilePath is required so that foo/bar and foo\bar match.
-- This can happen on windows.
equalFilePath (dir </> modName <.> "o") lhs
, r <- rhss
-- For a dependency of Main.o : Main.hs there is nothing to do
, not (equalFilePath r src)
]
liftIO $ do
print "needs"
mapM_ print needs
need needs
-- Compile it
let ghc_rts_args = [ "+RTS", "--machine-readable", "-t"++o++".stats" ]
......@@ -299,7 +323,7 @@ buildRules nofib@Build{..} = do
<> Ms.prefix (ml "rts stats") rtsStats
-- Compute build dependencies
"//Main.deps" %> \out -> do
"//.depends" %> \out -> do
let test = unoutput out
config <- readConfig' $ takeDirectory out </> "config.txt"
compileArgs <- getTestCompileArgs nofib test
......
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