summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-12-06 13:27:29 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-12-06 13:27:29 -0400
commit74b94c7512bd2a23597e78e42c82a859bdcbe1a1 (patch)
treedfcb78b564140fcf3e1fe5c36f56b9da814d29ef /Build
parent7daf44931cda03c593cb1ccd08c9fe139e6c8227 (diff)
gcc output parser
Diffstat (limited to 'Build')
-rw-r--r--Build/EvilLinker.hs33
1 files changed, 23 insertions, 10 deletions
diff --git a/Build/EvilLinker.hs b/Build/EvilLinker.hs
index 978410869..09a75bd60 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" []