[project @ 2003-11-06 10:31:55 by simonmar]
authorsimonmar <unknown>
Thu, 6 Nov 2003 10:32:06 +0000 (10:32 +0000)
committersimonmar <unknown>
Thu, 6 Nov 2003 10:32:06 +0000 (10:32 +0000)
Add a separate --help message for GHCi.

ghc/compiler/main/DriverFlags.hs
ghc/compiler/main/SysTools.lhs
ghc/driver/Makefile
ghc/driver/ghc-usage.txt
ghc/driver/ghci-usage.txt [new file with mode: 0644]

index 701f2ba..0ea708b 100644 (file)
@@ -1,9 +1,8 @@
 -----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.127 2003/10/09 11:58:56 simonpj Exp $
 --
 -- Driver flags
 --
--- (c) Simon Marlow 2000
+-- (c) The University of Glasgow 2000-2003
 --
 -----------------------------------------------------------------------------
 
@@ -651,7 +650,24 @@ setVerbosity n
 
 addCmdlineHCInclude a = updDynFlags (\s -> s{cmdlineHcIncludes =  a : cmdlineHcIncludes s})
 
+-- -----------------------------------------------------------------------------
+-- Version and usage messages
+
 showVersion :: IO ()
 showVersion = do
   putStrLn (cProjectName ++ ", version " ++ cProjectVersion)
   exitWith ExitSuccess
+
+showGhcUsage = do 
+  (ghc_usage_path,ghci_usage_path) <- getUsageMsgPaths
+  mode <- readIORef v_GhcMode
+  let usage_path 
+       | mode == DoInteractive  = ghci_usage_path
+       | otherwise              = ghc_usage_path
+  usage <- readFile usage_path
+  dump usage
+  exitWith ExitSuccess
+  where
+     dump ""         = return ()
+     dump ('$':'$':s) = hPutStr stderr progName >> dump s
+     dump (c:s)              = hPutChar stderr c >> dump s
index 48fcd4f..bd4aacb 100644 (file)
@@ -1,6 +1,6 @@
 -----------------------------------------------------------------------------
 --
--- (c) The University of Glasgow 2001
+-- (c) The University of Glasgow 2001-2003
 --
 -- Access to system tools: gcc, cp, rm etc
 --
@@ -28,6 +28,7 @@ module SysTools (
 
        getTopDir,              -- IO String    -- The value of $libdir
        getPackageConfigPath,   -- IO String    -- Where package.conf is
+        getUsageMsgPaths,       -- IO (String,String)
 
        -- Interface to system tools
        runUnlit, runCpp, runCc, -- [Option] -> IO ()
@@ -55,7 +56,6 @@ module SysTools (
        system,                 -- String -> IO ExitCode
 
        -- Misc
-       showGhcUsage,           -- IO ()        Shows usage message and exits
        getSysMan,              -- IO String    Parallel system only
        
        Option(..)
@@ -68,7 +68,7 @@ import DriverUtil
 import DriverPhases     ( isHaskellUserSrcFilename )
 import Config
 import Outputable
-import Panic           ( progName, GhcException(..) )
+import Panic           ( GhcException(..) )
 import Util            ( global, notNull )
 import CmdLineOpts     ( dynFlag, verbosity )
 
@@ -77,9 +77,9 @@ import DATA_IOREF     ( IORef, readIORef, writeIORef )
 import DATA_INT
     
 import Monad           ( when, unless )
-import System          ( ExitCode(..), exitWith, getEnv, system )
+import System          ( ExitCode(..), getEnv, system )
 import IO              ( try, catch,
-                         openFile, hPutChar, hPutStrLn, hPutStr, hClose, hFlush, IOMode(..),
+                         openFile, hPutStrLn, hPutStr, hClose, hFlush, IOMode(..),
                          stderr )
 import Directory       ( doesFileExist, removeFile )
 import List             ( intersperse, partition )
@@ -204,7 +204,7 @@ GLOBAL_VAR(v_Pgm_T,    error "pgm_T",    String)    -- touch
 GLOBAL_VAR(v_Pgm_CP,   error "pgm_CP",          String)        -- cp
 
 GLOBAL_VAR(v_Path_package_config, error "path_package_config", String)
-GLOBAL_VAR(v_Path_usage,         error "ghc_usage.txt",       String)
+GLOBAL_VAR(v_Path_usages,        error "ghc_usage.txt",       (String,String))
 
 GLOBAL_VAR(v_TopDir,   error "TopDir", String)         -- -B<dir>
 
@@ -254,6 +254,10 @@ initSysTools minusB_args
                | am_installed = installed "ghc-usage.txt"
                | otherwise    = inplace cGHC_DRIVER_DIR_REL "ghc-usage.txt"
 
+             ghci_usage_msg_path
+               | am_installed = installed "ghci-usage.txt"
+               | otherwise    = inplace cGHC_DRIVER_DIR_REL "ghci-usage.txt"
+
                -- For all systems, unlit, split, mangle are GHC utilities
                -- architecture-specific stuff is done when building Config.hs
              unlit_path
@@ -382,7 +386,8 @@ initSysTools minusB_args
                                       
        -- Initialise the global vars
        ; writeIORef v_Path_package_config pkgconfig_path
-       ; writeIORef v_Path_usage          ghc_usage_msg_path
+       ; writeIORef v_Path_usages         (ghc_usage_msg_path,
+                                           ghci_usage_msg_path)
 
        ; writeIORef v_Pgm_sysman          (top_dir ++ "/ghc/rts/parallel/SysMan")
                -- Hans: this isn't right in general, but you can 
@@ -586,23 +591,10 @@ getSysMan :: IO String    -- How to invoke the system manager
 getSysMan = readIORef v_Pgm_sysman
 \end{code}
 
-%************************************************************************
-%*                                                                     *
-\subsection{GHC Usage message}
-%*                                                                     *
-%************************************************************************
-
-Show the usage message and exit
-
 \begin{code}
-showGhcUsage = do { usage_path <- readIORef v_Path_usage
-                 ; usage      <- readFile usage_path
-                 ; dump usage
-                 ; exitWith ExitSuccess }
-  where
-     dump ""         = return ()
-     dump ('$':'$':s) = hPutStr stderr progName >> dump s
-     dump (c:s)              = hPutChar stderr c >> dump s
+getUsageMsgPaths :: IO (FilePath,FilePath)
+         -- the filenames of the usage messages (ghc, ghci)
+getUsageMsgPaths = readIORef v_Path_usages
 \end{code}
 
 
@@ -868,13 +860,6 @@ platformPath stuff = stuff
 
 \begin{code}
 slash           :: String -> String -> String
-absPath, relPath :: [String] -> String
-
-relPath [] = ""
-relPath xs = foldr1 slash xs
-
-absPath xs = "" `slash` relPath xs
-
 slash s1 s2 = s1 ++ ('/' : s2)
 \end{code}
 
index a6faed4..3e4f6cf 100644 (file)
@@ -1,5 +1,5 @@
 # -----------------------------------------------------------------------------=
-# $Id: Makefile,v 1.74 2002/09/25 10:32:34 simonmar Exp $
+# $Id: Makefile,v 1.75 2003/11/06 10:31:55 simonmar Exp $
 #
 # (c) The University of Glasgow 2002
 #
@@ -18,7 +18,7 @@ package.conf :
        echo "[]" > $@
 
 override datadir = $(libdir)
-INSTALL_DATAS += package.conf ghc-usage.txt
+INSTALL_DATAS += package.conf ghc-usage.txt ghci-usage.txt
 
 # Since cleaning effectively uninstalls all the packages, we must 
 # remove the stamp files that the build system uses to avoid unnecessarily
index 0986086..e95d584 100644 (file)
@@ -61,8 +61,6 @@ Other commonly-used options are:
     -M              Output Makefile rules recording the
                    dependencies of a list of Haskell files.
 
-The User's Guide has more information about GHC's *many* options.
-
 Given the above, here are some TYPICAL invocations of $$:
 
     # compile a Haskell module to a .o file, optimising:
@@ -73,4 +71,10 @@ Given the above, here are some TYPICAL invocations of $$:
     % $$ -C -H16m Foo.hs
     # compile Haskell-produced C (.hc) to assembly language:
     % $$ -S Foo.hc
+
+The User's Guide has more information about GHC's *many* options.  An
+online copy can be found here:
+
+   http://www.haskell.org/ghc/documentation.html
+
 ------------------------------------------------------------------------
diff --git a/ghc/driver/ghci-usage.txt b/ghc/driver/ghci-usage.txt
new file mode 100644 (file)
index 0000000..4a633fc
--- /dev/null
@@ -0,0 +1,26 @@
+Usage:
+
+    ghci [command-line-options-and-input-files]
+
+The kinds of input files that can be given on the command-line
+include:
+
+  - Haskell source files (.hs or .lhs suffix)
+  - Object files (.o suffix, or .obj on Windows)
+  - Dynamic libraries (.so suffix, or .dll on Windows)
+
+In addition, ghci accepts most of the command-line options that plain
+GHC does.  Some of the options that are commonly used are:
+
+    -fglasgow-exts  Allow Glasgow extensions (unboxed types, etc.)
+
+    -i<dir>         Search for imported modules in the directory <dir>.
+
+    -H32m          Increase GHC's default heap size to 32m
+
+    -cpp            Enable CPP processing of source files
+
+Full details can be found in the User's Guide, an online copy of which
+can be found here:
+
+    http://www.haskell.org/ghc/documentation.html