-- Interface to system tools
runUnlit, runCpp, runCc, -- [Option] -> IO ()
+ runPp, -- [Option] -> IO ()
runMangle, runSplit, -- [Option] -> IO ()
runAs, runLink, -- [Option] -> IO ()
runMkDLL,
import Config
import Outputable
import Panic ( progName, GhcException(..) )
-import Util ( global )
+import Util ( global, dropList )
import CmdLineOpts ( dynFlag, verbosity )
-import Exception ( throwDyn, catch )
+import Exception ( throwDyn )
+#if __GLASGOW_HASKELL__ > 408
+import qualified Exception ( catch )
+#else
+import Exception ( catchAllIO )
+#endif
import IO
import Directory ( doesFileExist, removeFile )
import IOExts ( IORef, readIORef, writeIORef )
import System ( system )
#endif
+
#include "HsVersions.h"
+-- Make catch work on older GHCs
+#if __GLASGOW_HASKELL__ > 408
+myCatch = Exception.catch
+#else
+myCatch = catchAllIO
+#endif
+
\end{code}
\begin{code}
GLOBAL_VAR(v_Pgm_L, error "pgm_L", String) -- unlit
GLOBAL_VAR(v_Pgm_P, error "pgm_P", String) -- cpp
+GLOBAL_VAR(v_Pgm_F, error "pgm_F", String) -- pp
GLOBAL_VAR(v_Pgm_c, error "pgm_c", String) -- gcc
GLOBAL_VAR(v_Pgm_m, error "pgm_m", String) -- asm code mangler
GLOBAL_VAR(v_Pgm_s, error "pgm_s", String) -- asm code splitter
; writeIORef v_Pgm_L unlit_path
; writeIORef v_Pgm_P cpp_path
+ ; writeIORef v_Pgm_F ""
; writeIORef v_Pgm_c gcc_path
; writeIORef v_Pgm_m mangle_path
; writeIORef v_Pgm_s split_path
-- So the first character says which program to override
setPgm ('P' : pgm) = writeIORef v_Pgm_P pgm
+setPgm ('F' : pgm) = writeIORef v_Pgm_F pgm
setPgm ('c' : pgm) = writeIORef v_Pgm_c pgm
setPgm ('m' : pgm) = writeIORef v_Pgm_m pgm
setPgm ('s' : pgm) = writeIORef v_Pgm_s pgm
%************************************************************************
%* *
\subsection{Running an external program}
-n%* *
+%* *
%************************************************************************
runCpp args = do p <- readIORef v_Pgm_P
runSomething "C pre-processor" p args
+runPp :: [Option] -> IO ()
+runPp args = do p <- readIORef v_Pgm_F
+ runSomething "Haskell pre-processor" p args
+
runCc :: [Option] -> IO ()
runCc args = do p <- readIORef v_Pgm_c
runSomething "C Compiler" p args
("Deleting: " ++ unwords fs)
(mapM_ rm fs)
where
- rm f = removeFile f `catch`
+ rm f = removeFile f `myCatch`
(\_ignored ->
when (verb >= 2) $
hPutStrLn stderr ("Warning: deleting non-existent " ++ f)
; unless n $ do {
-- And run it!
- ; action `catch` handle_exn verb
+ ; action `myCatch` handle_exn verb
}}
where
handle_exn verb exn = do { when (verb >= 2) (hPutStr stderr "\n")
cygdrive_prefix = "/cygdrive/"
real_stuff
- | cygdrive_prefix `isPrefixOf` stuff = drop (length cygdrive_prefix) stuff
+ | cygdrive_prefix `isPrefixOf` stuff = dropList cygdrive_prefix stuff
| otherwise = stuff
#else
if ret == 0 then destructArray len buf >> return Nothing
else do s <- peekCString buf
destructArray len buf
- return (Just (reverse (drop (length "/bin/ghc.exe") (reverse (unDosifyPath s)))))
+ return (Just (reverse (dropList "/bin/ghc.exe" (reverse (unDosifyPath s)))))
foreign import stdcall "GetModuleFileNameA" getModuleFileName :: Addr -> CString -> Int -> IO Int32