This commit is contained in:
Joey Hess 2013-12-06 14:20:44 -04:00
parent 1f2b42a853
commit b97fe204ba

View file

@ -49,24 +49,46 @@ parseGhcLink = do
{- Find where gcc calls collect2. -} {- Find where gcc calls collect2. -}
parseGccLink :: Parser CmdParams parseGccLink :: Parser CmdParams
parseGccLink = do parseGccLink = do
many precollectenvline many preenv
env <- collectenvline env <- collectenv
try $ char ' ' try $ char ' '
path <- manyTill anyChar (try $ string collectcmd) path <- manyTill anyChar (try $ string collectcmd)
char ' ' char ' '
collect2params <- restOfLine collect2params <- restOfLine
return $ CmdParams (path ++ collectcmd) (escapeDosPaths collect2params) return $ CmdParams (path ++ collectcmd) (escapeDosPaths collect2params) env
(Just [(collectenv, env)])
where where
collectcmd = "collect2.exe" collectcmd = "collect2.exe"
collectenv = "COLLECT_GCC_OPTIONS" pathenv = "COMPILER_PATH"
collectenvline = do libpathenv = "LIBRARY_PATH"
string collectenv optenv = "COLLECT_GCC_OPTIONS"
collectenv = do
string pathenv
char '=' 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 restOfLine
precollectenvline = do
notFollowedBy collectenvline {- Find where collect2 calls ld. -}
restOfLine 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 {- Input contains something like
- c:/program files/haskell platform/foo -LC:/Program Files/Haskell Platform/ -L... - 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"
. 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 :: Parser String
restOfLine = newline `after` many (noneOf "\n") restOfLine = newline `after` many (noneOf "\n")