From 26f9e593087c3b738a1961d37f4c4a0a6bab0a0c Mon Sep 17 00:00:00 2001 From: simonmar Date: Wed, 5 Jan 2005 10:26:46 +0000 Subject: [PATCH] [project @ 2005-01-05 10:26:45 by simonmar] Use rawSystem where appropriate. --- ghc/utils/hsc2hs/Main.hs | 33 +++++++++++++++++++++------------ ghc/utils/hsc2hs/Makefile | 3 +++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/ghc/utils/hsc2hs/Main.hs b/ghc/utils/hsc2hs/Main.hs index e2cfbb7..0ad0a03 100644 --- a/ghc/utils/hsc2hs/Main.hs +++ b/ghc/utils/hsc2hs/Main.hs @@ -1,7 +1,7 @@ {-# OPTIONS -fffi -cpp #-} ------------------------------------------------------------------------ --- $Id: Main.hs,v 1.60 2004/08/13 13:11:21 simonmar Exp $ +-- $Id: Main.hs,v 1.61 2005/01/05 10:26:45 simonmar Exp $ -- -- Program for converting .hsc files to .hs files, by converting the -- file into a C program which is run to generate the Haskell source. @@ -17,6 +17,8 @@ import System.Console.GetOpt import GetOpt #endif +import Compat.RawSystem ( rawSystem ) + import System (getProgName, getArgs, ExitCode(..), exitWith, system) import Directory (removeFile,doesFileExist) import Monad (MonadPlus(..), liftM, liftM2, when) @@ -570,22 +572,24 @@ output flags name toks = do - compilerStatus <- systemL beVerbose $ - compiler++ - " -c"++ - concat [" "++f | CompFlag f <- flags]++ - " "++cProgName++ - " -o "++oProgName + compilerStatus <- rawSystemL beVerbose compiler + ( ["-c"] + ++ [f | CompFlag f <- flags] + ++ [cProgName] + ++ ["-o", oProgName] + ) + case compilerStatus of e@(ExitFailure _) -> exitWith e _ -> return () removeFile cProgName - linkerStatus <- systemL beVerbose $ - linker++ - concat [" "++f | LinkFlag f <- flags]++ - " "++oProgName++ - " -o "++progName + linkerStatus <- rawSystemL beVerbose linker + ( [f | LinkFlag f <- flags] + ++ [oProgName] + ++ ["-o", progName] + ) + case linkerStatus of e@(ExitFailure _) -> exitWith e _ -> return () @@ -618,6 +622,11 @@ output flags name toks = do -- NB. outHFile not outHName; works better when processed -- by gcc or mkdependC. +rawSystemL :: Bool -> String -> [String] -> IO ExitCode +rawSystemL flg prog args = do + when flg $ hPutStrLn stderr ("Executing: " ++ prog ++ concat (map (' ':) args)) + rawSystem prog args + systemL :: Bool -> String -> IO ExitCode systemL flg s = do when flg (hPutStrLn stderr ("Executing: " ++ s)) diff --git a/ghc/utils/hsc2hs/Makefile b/ghc/utils/hsc2hs/Makefile index 2ea5786..dee4085 100644 --- a/ghc/utils/hsc2hs/Makefile +++ b/ghc/utils/hsc2hs/Makefile @@ -10,6 +10,9 @@ INCLUDE_DIR=ghc/includes INSTALLING=1 +SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR) +SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat + HS_PROG = hsc2hs-bin ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" HS_PROG = hsc2hs$(exeext) -- 1.7.10.4