diff options
author | Duncan Coutts <duncan@well-typed.com> | 2014-08-24 03:38:39 +0100 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-08-29 12:39:04 +0100 |
commit | a4cb9a6173f0af76a32b812c022bbdd76b2abfac (patch) | |
tree | bd7183486166fcd4eb714dc777233e3d15fc9cca /ghc | |
parent | 8955b5eea3e8c1ddcba57261ab0e1250783ddda2 (diff) | |
download | haskell-a4cb9a6173f0af76a32b812c022bbdd76b2abfac.tar.gz |
Add a ghc -show-packages mode to display ghc's view of the package env
You can use ghc -show-packages, in addition to any -package -package-conf
-hide-package, etc flags and see just what ghc's package info looks like.
The format is much like ghc-pkg show.
Like the existing verbose tracing, but a specific mode.
Re-introduce pretty printed package info (Cabal handled this previously).
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/Main.hs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ghc/Main.hs b/ghc/Main.hs index 70dde39824..8746125450 100644 --- a/ghc/Main.hs +++ b/ghc/Main.hs @@ -33,7 +33,7 @@ import InteractiveUI ( interactiveUI, ghciWelcomeMsg, defaultGhciSettings ) import Config import Constants import HscTypes -import Packages ( dumpPackages, simpleDumpPackages, pprModuleMap ) +import Packages ( pprPackages, pprPackagesSimple, pprModuleMap ) import DriverPhases import BasicTypes ( failed ) import StaticFlags @@ -210,7 +210,7 @@ main' postLoadMode dflags0 args flagWarnings = do ---------------- Display configuration ----------- case verbosity dflags6 of - v | v == 4 -> liftIO $ simpleDumpPackages dflags6 + v | v == 4 -> liftIO $ dumpPackagesSimple dflags6 | v >= 5 -> liftIO $ dumpPackages dflags6 | otherwise -> return () @@ -237,6 +237,7 @@ main' postLoadMode dflags0 args flagWarnings = do DoInteractive -> ghciUI srcs Nothing DoEval exprs -> ghciUI srcs $ Just $ reverse exprs DoAbiHash -> abiHash srcs + ShowPackages -> liftIO $ showPackages dflags6 liftIO $ dumpFinalStats dflags6 @@ -435,12 +436,15 @@ data PostLoadMode | DoInteractive -- ghc --interactive | DoEval [String] -- ghc -e foo -e bar => DoEval ["bar", "foo"] | DoAbiHash -- ghc --abi-hash + | ShowPackages -- ghc --show-packages -doMkDependHSMode, doMakeMode, doInteractiveMode, doAbiHashMode :: Mode +doMkDependHSMode, doMakeMode, doInteractiveMode, + doAbiHashMode, showPackagesMode :: Mode doMkDependHSMode = mkPostLoadMode DoMkDependHS doMakeMode = mkPostLoadMode DoMake doInteractiveMode = mkPostLoadMode DoInteractive doAbiHashMode = mkPostLoadMode DoAbiHash +showPackagesMode = mkPostLoadMode ShowPackages showInterfaceMode :: FilePath -> Mode showInterfaceMode fp = mkPostLoadMode (ShowInterface fp) @@ -533,6 +537,7 @@ mode_flags = , Flag "-show-options" (PassFlag (setMode showOptionsMode)) , Flag "-supported-languages" (PassFlag (setMode showSupportedExtensionsMode)) , Flag "-supported-extensions" (PassFlag (setMode showSupportedExtensionsMode)) + , Flag "-show-packages" (PassFlag (setMode showPackagesMode)) ] ++ [ Flag k' (PassFlag (setMode (printSetting k))) | k <- ["Project version", @@ -772,6 +777,11 @@ countFS entries longest has_z (b:bs) = in countFS entries' longest' (has_z + has_zs) bs +showPackages, dumpPackages, dumpPackagesSimple :: DynFlags -> IO () +showPackages dflags = putStrLn (showSDoc dflags (pprPackages dflags)) +dumpPackages dflags = putMsg dflags (pprPackages dflags) +dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple dflags) + -- ----------------------------------------------------------------------------- -- ABI hash support |