From a5644eeeb9d0d555745141115b6865b557d855de Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 6 Dec 2013 13:27:29 -0400 Subject: [PATCH] gcc output parser --- Build/EvilLinker.hs | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Build/EvilLinker.hs b/Build/EvilLinker.hs index 978410869e..09a75bd600 100644 --- a/Build/EvilLinker.hs +++ b/Build/EvilLinker.hs @@ -43,17 +43,30 @@ parseGhcLink = do restOfLine manglepaths = replace "\\" "/" -{- Find where gcc calls collect1. -} +{- Find where gcc calls collect2. -} parseGccLink :: Parser CmdParams parseGccLink = do - many prelinkline - error "TODO" + many precollectenvline + env <- collectenvline + try $ char ' ' + path <- manyTill anyChar (try $ string collectcmd) + char ' ' + collect2params <- restOfLine + return $ CmdParams (path ++ collectcmd) collect2params where - prelinkline = error "TODO" + collectcmd = "collect2.exe" + collectenv = "COLLECT_GCC_OPTIONS" + collectenvline = do + string collectenv + char '=' + restOfLine + precollectenvline = do + notFollowedBy collectenvline + restOfLine -{- Find where collect1 calls ld. -} -parseCollect1 :: Parser CmdParams -parseCollect1 = error "TODO" +{- Find where collect2 calls ld. -} +parseCollect2 :: Parser CmdParams +parseCollect2 = error "TODO" restOfLine :: Parser String restOfLine = newline `after` many (noneOf "\n") @@ -86,6 +99,6 @@ main = do ["build", "--ghc-options=-v -keep-tmp-files"] gccout <- runAtFile parseGhcLink ghcout "gcc.opt" ["-v"] writeFile "gcc.out" gccout - collect1out <- runAtFile parseGccLink gccout "collect1.opt" ["-v"] - writeFile "collect1.out" collect1out - void $ runAtFile parseCollect1 collect1out "ld.opt" [] + collect2out <- runAtFile parseGccLink gccout "collect2.opt" ["-v"] + writeFile "collect2.out" collect2out + void $ runAtFile parseCollect2 collect2out "ld.opt" []