Complain more loudly if any of the hsc2hs phases fail

previously hsc2hs just exits with a non-zero exit code, now if any of
the compilation, linking or runing phases fail then we get a message
saying so and the failing command is printed.
parent 9f2ceb4d
......@@ -611,34 +611,23 @@ output flags name toks = do
compilerStatus <- rawSystemL beVerbose compiler
rawSystemL ("compiling " ++ cProgName) beVerbose compiler
( ["-c"]
++ [f | CompFlag f <- flags]
++ [cProgName]
++ ["-o", oProgName]
)
case compilerStatus of
e@(ExitFailure _) -> exitWith e
_ -> return ()
removeFile cProgName
linkerStatus <- rawSystemL beVerbose linker
rawSystemL ("linking " ++ oProgName) beVerbose linker
( [f | LinkFlag f <- flags]
++ [oProgName]
++ ["-o", progName]
)
case linkerStatus of
e@(ExitFailure _) -> exitWith e
_ -> return ()
removeFile oProgName
progStatus <- rawSystemWithStdOutL beVerbose execProgName [] outName
rawSystemWithStdOutL ("running " ++ execProgName) beVerbose execProgName [] outName
removeFile progName
case progStatus of
e@(ExitFailure _) -> exitWith e
_ -> return ()
when needsH $ writeFile outHName $
"#ifndef "++includeGuard++"\n" ++
......@@ -661,29 +650,34 @@ output flags name toks = do
-- NB. outHFile not outHName; works better when processed
-- by gcc or mkdependC.
rawSystemL :: Bool -> FilePath -> [String] -> IO ExitCode
rawSystemL flg prog args = do
rawSystemL :: String -> Bool -> FilePath -> [String] -> IO ()
rawSystemL action flg prog args = do
let cmdLine = prog++" "++unwords args
when flg $ hPutStrLn stderr ("Executing: " ++ cmdLine)
#ifndef HAVE_rawSystem
system cmdLine
exitStatus <- system cmdLine
#else
rawSystem prog args
exitStatus <- rawSystem prog args
#endif
case exitStatus of
ExitFailure _ -> die $ action ++ " failed\ncommand was: " ++ cmdLine ++ "\n"
_ -> return ()
rawSystemWithStdOutL :: Bool -> FilePath -> [String] -> FilePath -> IO ExitCode
rawSystemWithStdOutL flg prog args outFile = do
rawSystemWithStdOutL :: String -> Bool -> FilePath -> [String] -> FilePath -> IO ()
rawSystemWithStdOutL action flg prog args outFile = do
let cmdLine = prog++" "++unwords args++" >"++outFile
when flg (hPutStrLn stderr ("Executing: " ++ cmdLine))
#ifndef HAVE_runProcess
system cmdLine
exitStatus <- system cmdLine
#else
hOut <- openFile outFile WriteMode
process <- runProcess prog args Nothing Nothing Nothing (Just hOut) Nothing
res <- waitForProcess process
exitStatus <- waitForProcess process
hClose hOut
return res
#endif
case exitStatus of
ExitFailure _ -> die $ action ++ " failed\ncommand was: " ++ cmdLine ++ "\n"
_ -> return ()
onlyOne :: String -> IO a
onlyOne what = die ("Only one "++what++" may be specified\n")
......
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