diff options
author | Joey Hess <joey@kitenet.net> | 2013-12-06 14:20:44 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-12-06 14:20:44 -0400 |
commit | 6c6fae49e4ec42b58414bb194142596c17fcd276 (patch) | |
tree | 4762c743c1874ea894df5fd5501999f3f73ba6aa /Build/EvilLinker.hs | |
parent | 43c7199170dfd9428ac1bdadfa668f673cebd2da (diff) |
progress
Diffstat (limited to 'Build/EvilLinker.hs')
-rw-r--r-- | Build/EvilLinker.hs | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/Build/EvilLinker.hs b/Build/EvilLinker.hs index f9eb641dd..258f994c4 100644 --- a/Build/EvilLinker.hs +++ b/Build/EvilLinker.hs @@ -49,24 +49,46 @@ parseGhcLink = do {- Find where gcc calls collect2. -} parseGccLink :: Parser CmdParams parseGccLink = do - many precollectenvline - env <- collectenvline + many preenv + env <- collectenv try $ char ' ' path <- manyTill anyChar (try $ string collectcmd) char ' ' collect2params <- restOfLine - return $ CmdParams (path ++ collectcmd) (escapeDosPaths collect2params) - (Just [(collectenv, env)]) + return $ CmdParams (path ++ collectcmd) (escapeDosPaths collect2params) env where collectcmd = "collect2.exe" - collectenv = "COLLECT_GCC_OPTIONS" - collectenvline = do - string collectenv + pathenv = "COMPILER_PATH" + libpathenv = "LIBRARY_PATH" + optenv = "COLLECT_GCC_OPTIONS" + collectenv = do + string pathenv char '=' + p <- restOfLine + string libpathenv + char '=' + lp <- restOfLine + string optenv + char '=' + o <- restOfLine + return $ Just [(pathenv, p), (libpathenv, lp), (optenv, o)] + preenv = do + notFollowedBy collectenv restOfLine - precollectenvline = do - notFollowedBy collectenvline - restOfLine + +{- Find where collect2 calls ld. -} +parseCollect2 :: Parser CmdParams +parseCollect2 = do + string "GNU ld" + restOfLine + string "collect2 version" + restOfLine + path <- manyTill anyChar (try $ string ldcmd) + char ' ' + params <- restOfLine + return $ CmdParams (path ++ ldcmd) params Nothing + where + ldcmd = "ld.exe" {- Input contains something like - c:/program files/haskell platform/foo -LC:/Program Files/Haskell Platform/ -L... @@ -80,10 +102,6 @@ escapeDosPaths = replace "Program Files" "Program\\ Files" . replace "Haskell Platform" "Haskell\\ Platform" . replace "haskell platform" "haskell\\ platform" -{- Find where collect2 calls ld. -} -parseCollect2 :: Parser CmdParams -parseCollect2 = error "TODO" - restOfLine :: Parser String restOfLine = newline `after` many (noneOf "\n") |