X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fhsc2hs%2FMain.hs;h=e541e21d1444dabdcad83c79ecc1c2cc7b96b1bc;hb=e796c0f1a48b71be6917da401f5c1cbaf699a87e;hp=75ea57b555dc5a6e42842cf3b1578f9a3c0b9b3c;hpb=91380819349da8d7c18590ec44fab49c9075b26f;p=ghc-hetmet.git diff --git a/utils/hsc2hs/Main.hs b/utils/hsc2hs/Main.hs index 75ea57b..e541e21 100644 --- a/utils/hsc2hs/Main.hs +++ b/utils/hsc2hs/Main.hs @@ -1,4 +1,4 @@ -{-# OPTIONS -fffi -cpp #-} +{-# LANGUAGE CPP, ForeignFunctionInterface #-} ------------------------------------------------------------------------ -- Program for converting .hsc files to .hs files, by converting the @@ -42,7 +42,7 @@ import System.IO ( openFile, IOMode(..), hClose ) #endif #if defined(__GLASGOW_HASKELL__) && !defined(BUILD_NHC) -import Compat.RawSystem ( rawSystem ) +import System.Cmd ( rawSystem ) #define HAVE_rawSystem #elif __NHC__ >= 117 import System.Cmd ( rawSystem ) @@ -129,7 +129,7 @@ main = do -- to find one by looking near the executable. This only -- works on Win32 or Hugs (getExecDir). On Unix, there's a wrapper -- script which specifies an explicit template flag. - flags_w_tpl <- if any template_flag flags then + flags_w_tpl0 <- if any template_flag flags then return flags else do mb_path <- getExecDir "/bin/hsc2hs.exe" @@ -143,6 +143,12 @@ main = do then return ((Template templ):) else return id return (add_opt flags) + + -- take only the last --template flag on the cmd line + let + (before,tpl:after) = break template_flag (reverse flags_w_tpl0) + flags_w_tpl = reverse (before ++ tpl : filter (not.template_flag) after) + case (files, errs) of (_, _) | any isHelp flags_w_tpl -> bye (usageInfo header options) @@ -569,8 +575,7 @@ output flags name toks = do -- (called hsc2hs-inplace, generated from hsc2hs.sh) compiler <- case [c | Compiler c <- flags] of [] -> locateGhc "ghc" - [c] -> return c - _ -> onlyOne "compiler" + cs -> return (last cs) linker <- case [l | Linker l <- flags] of [] -> locateGhc compiler