X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Frunghc%2Frunghc.hs;h=ab495132cd85fe27096f92112f839b5180385444;hb=9d1a7251a138829f59cc1cf052ee2d3f5603d67b;hp=bfdcc96b3a4c355e9d478461ce1fcb8b47007d4d;hpb=dacc1aa41699ee6c8f4c49ef6061c95ea5e70017;p=ghc-hetmet.git diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index bfdcc96..ab49513 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -1,9 +1,5 @@ {-# LANGUAGE CPP, ForeignFunctionInterface #-} -#if __GLASGOW_HASKELL__ < 603 -#include "config.h" -#else #include "ghcconfig.h" -#endif ----------------------------------------------------------------------------- -- -- (c) The University of Glasgow, 2004 @@ -23,8 +19,6 @@ module Main (main) where import Control.Exception -import Data.Char -import Data.List import Data.Monoid import System.Cmd import System.Directory @@ -44,6 +38,7 @@ main = do args <- getArgs case parseRunGhcFlags args of (Help, _) -> printUsage + (ShowVersion, _) -> printVersion (RunGhcFlags (Just ghc), args') -> doIt ghc args' (RunGhcFlags Nothing, args') -> do mbPath <- getExecPath @@ -55,11 +50,14 @@ main = do data RunGhcFlags = RunGhcFlags (Maybe FilePath) -- GHC location | Help -- Print help text + | ShowVersion -- Print version info instance Monoid RunGhcFlags where mempty = RunGhcFlags Nothing Help `mappend` _ = Help _ `mappend` Help = Help + ShowVersion `mappend` _ = ShowVersion + _ `mappend` ShowVersion = ShowVersion RunGhcFlags _ `mappend` right@(RunGhcFlags (Just _)) = right left@(RunGhcFlags _) `mappend` RunGhcFlags Nothing = left @@ -70,11 +68,16 @@ parseRunGhcFlags = f mempty f flags (('-' : 'f' : ghc) : args) = f (flags `mappend` RunGhcFlags (Just ghc)) args f flags ("--help" : args) = f (flags `mappend` Help) args + f flags ("--version" : args) = f (flags `mappend` ShowVersion) args -- If you need the first GHC flag to be a -f flag then -- you can pass -- first f flags ("--" : args) = (flags, args) f flags args = (flags, args) +printVersion :: IO () +printVersion = do + putStrLn ("runghc " ++ VERSION) + printUsage :: IO () printUsage = do putStrLn "Usage: runghc [runghc flags] [GHC flags] module [program args]" @@ -82,6 +85,7 @@ printUsage = do putStrLn "The runghc flags are" putStrLn " -f /path/to/ghc Tell runghc where GHC is" putStrLn " --help Print this usage information" + putStrLn " --version Print version number" doIt :: String -> [String] -> IO () doIt ghc args = do