diff options
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index f636c380b2..52a90d07e7 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -109,6 +109,7 @@ main = do ShowSupportedExtensions -> showSupportedExtensions ShowVersion -> showVersion ShowNumVersion -> putStrLn cProjectVersion + ShowOptions -> showOptions Right postStartupMode -> -- start our GHC session GHC.runGhc mbMinusB $ do @@ -371,11 +372,13 @@ data PreStartupMode = ShowVersion -- ghc -V/--version | ShowNumVersion -- ghc --numeric-version | ShowSupportedExtensions -- ghc --supported-extensions + | ShowOptions -- ghc --show-options -showVersionMode, showNumVersionMode, showSupportedExtensionsMode :: Mode +showVersionMode, showNumVersionMode, showSupportedExtensionsMode, showOptionsMode :: Mode showVersionMode = mkPreStartupMode ShowVersion showNumVersionMode = mkPreStartupMode ShowNumVersion showSupportedExtensionsMode = mkPreStartupMode ShowSupportedExtensions +showOptionsMode = mkPreStartupMode ShowOptions mkPreStartupMode :: PreStartupMode -> Mode mkPreStartupMode = Left @@ -519,6 +522,7 @@ mode_flags = , Flag "-version" (PassFlag (setMode showVersionMode)) , Flag "-numeric-version" (PassFlag (setMode showNumVersionMode)) , Flag "-info" (PassFlag (setMode showInfoMode)) + , Flag "-show-options" (PassFlag (setMode showOptionsMode)) , Flag "-supported-languages" (PassFlag (setMode showSupportedExtensionsMode)) , Flag "-supported-extensions" (PassFlag (setMode showSupportedExtensionsMode)) ] ++ @@ -693,6 +697,21 @@ showSupportedExtensions = mapM_ putStrLn supportedLanguagesAndExtensions showVersion :: IO () showVersion = putStrLn (cProjectName ++ ", version " ++ cProjectVersion) +showOptions :: IO () +showOptions = putStr (unlines availableOptions) + where + availableOptions = map ((:) '-') . filter ((>2) . length) $ + getFlagNames mode_flags ++ + getFlagNames flagsDynamic ++ + (filterUnwantedStatic . getFlagNames $ flagsStatic) ++ + flagsStaticNames + getFlagNames opts = map getFlagName opts + getFlagName (Flag name _) = name + -- this is a hack to get rid of two unwanted entries that get listed + -- as static flags. Hopefully this hack will disappear one day together + -- with static flags + filterUnwantedStatic = filter (\x -> not (x `elem` ["f", "fno-"])) + showGhcUsage :: DynFlags -> IO () showGhcUsage = showUsage False |