2014-04-21 02:31:15 +00:00
|
|
|
module Language.Haskell.GhcMod.Debug (debugInfo, rootInfo) where
|
2013-03-04 02:21:41 +00:00
|
|
|
|
2014-03-27 06:23:27 +00:00
|
|
|
import Control.Applicative ((<$>))
|
2013-03-04 02:21:41 +00:00
|
|
|
import Data.List (intercalate)
|
2014-07-11 01:10:37 +00:00
|
|
|
import Data.Maybe (isJust, fromJust)
|
2014-05-11 22:40:00 +00:00
|
|
|
import Language.Haskell.GhcMod.Convert
|
2014-07-11 01:10:37 +00:00
|
|
|
import Language.Haskell.GhcMod.Monad
|
2013-05-17 01:00:01 +00:00
|
|
|
import Language.Haskell.GhcMod.Types
|
2015-02-07 22:55:57 +00:00
|
|
|
import Language.Haskell.GhcMod.CabalConfig
|
2014-07-12 01:30:06 +00:00
|
|
|
import Language.Haskell.GhcMod.Internal
|
2013-03-04 02:21:41 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2013-05-20 05:28:56 +00:00
|
|
|
-- | Obtaining debug information.
|
2014-07-12 09:16:16 +00:00
|
|
|
debugInfo :: IOish m => GhcModT m String
|
2014-07-11 01:10:37 +00:00
|
|
|
debugInfo = cradle >>= \c -> convert' =<< do
|
2013-09-19 06:58:50 +00:00
|
|
|
CompilerOptions gopts incDir pkgs <-
|
2014-07-11 01:10:37 +00:00
|
|
|
if isJust $ cradleCabalFile c then
|
2014-07-17 08:16:44 +00:00
|
|
|
fromCabalFile c ||> simpleCompilerOption
|
2013-03-04 02:21:41 +00:00
|
|
|
else
|
2014-07-11 01:10:37 +00:00
|
|
|
simpleCompilerOption
|
2013-03-04 02:21:41 +00:00
|
|
|
return [
|
2014-07-11 01:10:37 +00:00
|
|
|
"Root directory: " ++ cradleRootDir c
|
|
|
|
, "Current directory: " ++ cradleCurrentDir c
|
|
|
|
, "Cabal file: " ++ show (cradleCabalFile c)
|
2013-03-05 07:57:18 +00:00
|
|
|
, "GHC options: " ++ unwords gopts
|
|
|
|
, "Include directories: " ++ unwords incDir
|
2014-04-17 21:40:11 +00:00
|
|
|
, "Dependent packages: " ++ intercalate ", " (map showPkg pkgs)
|
2014-07-12 01:30:06 +00:00
|
|
|
, "System libraries: " ++ ghcLibDir
|
2013-03-04 02:21:41 +00:00
|
|
|
]
|
|
|
|
where
|
2014-07-11 01:10:37 +00:00
|
|
|
simpleCompilerOption = options >>= \op ->
|
2014-08-13 16:40:01 +00:00
|
|
|
return $ CompilerOptions (ghcUserOptions op) [] []
|
2015-02-07 22:55:57 +00:00
|
|
|
fromCabalFile crdl = options >>= \opts -> do
|
|
|
|
config <- cabalGetConfig crdl
|
|
|
|
pkgDesc <- parseCabalFile config $ fromJust $ cradleCabalFile crdl
|
|
|
|
getCompilerOptions (ghcUserOptions opts) crdl config pkgDesc
|
2014-03-20 07:21:48 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
|
|
-- | Obtaining root information.
|
2014-07-12 09:16:16 +00:00
|
|
|
rootInfo :: IOish m => GhcModT m String
|
2014-07-11 01:10:37 +00:00
|
|
|
rootInfo = convert' =<< cradleRootDir <$> cradle
|