diff --git a/Language/Haskell/GhcMod/Debug.hs b/Language/Haskell/GhcMod/Debug.hs index 2fd7bb0..48f7137 100644 --- a/Language/Haskell/GhcMod/Debug.hs +++ b/Language/Haskell/GhcMod/Debug.hs @@ -7,6 +7,7 @@ import Control.Monad.Trans.Journal import qualified Data.Map as Map import qualified Data.Set as Set import Data.Char +import Data.Version import Data.List.Split import Text.PrettyPrint import Language.Haskell.GhcMod.Monad @@ -17,6 +18,11 @@ import Language.Haskell.GhcMod.Pretty import Language.Haskell.GhcMod.Utils import Language.Haskell.GhcMod.Cradle import Language.Haskell.GhcMod.Stack +import Language.Haskell.GhcMod.Output + +import Paths_ghc_mod (version) + +import Config (cProjectVersion) ---------------------------------------------------------------- @@ -34,14 +40,20 @@ debugInfo = do pkgOpts <- packageGhcOptions + readProc <- gmReadProcess + + ghcVersion <- liftIO $ + dropWhileEnd isSpace <$> readProc "ghc" ["--numeric-version"] "" + return $ unlines $ - [ "Root directory: " ++ cradleRootDir + [ "Version: ghc-mod-" ++ showVersion version + , "Library GHC Version: " ++ cProjectVersion + , "System GHC Version: " ++ ghcVersion + , "Root directory: " ++ cradleRootDir , "Current directory: " ++ cradleCurrentDir , "GHC Package flags:\n" ++ render (nest 4 $ fsep $ map text pkgOpts) , "GHC System libraries: " ++ ghcLibDir - , "GHC user options:\n" ++ render (nest 4 $ - fsep $ map text optGhcUserOptions) ] ++ cabal stackPaths :: IOish m => GhcModT m [String] @@ -63,9 +75,18 @@ cabalDebug = do opts = Map.map gmcGhcOpts mcs srcOpts = Map.map gmcGhcSrcOpts mcs + readProc <- gmReadProcess + cabalInstVersion <- liftIO $ + dropWhileEnd isSpace <$> readProc "cabal" ["--numeric-version"] "" + packages <- liftIO $ readProc "ghc-pkg" ["list", "--simple-output"] "" + let cabalPackages = filter ((== ["Cabal"]) . take 1 . splitOn "-") $ splitWhen isSpace packages + return $ - [ "Cabal file: " ++ show cradleCabalFile - , "Project: " ++ show cradleProject + [ "cabal-install Version: " ++ cabalInstVersion + , "Cabal Library Versions:\n" ++ render (nest 4 $ + fsep $ map text cabalPackages) + , "Cabal file: " ++ show cradleCabalFile + , "Project: " ++ show cradleProject , "Cabal entrypoints:\n" ++ render (nest 4 $ mapDoc gmComponentNameDoc smpDoc entrypoints) , "Cabal components:\n" ++ render (nest 4 $