2013-05-17 01:00:01 +00:00
|
|
|
module Language.Haskell.GhcMod.Debug (debugInfo, debug) where
|
2013-03-04 02:21:41 +00:00
|
|
|
|
|
|
|
import Control.Applicative
|
2013-05-09 01:09:12 +00:00
|
|
|
import Control.Exception.IOChoice
|
2013-03-13 04:17:22 +00:00
|
|
|
import Control.Monad
|
2013-03-04 02:21:41 +00:00
|
|
|
import Data.List (intercalate)
|
|
|
|
import Data.Maybe
|
2013-03-13 04:17:22 +00:00
|
|
|
import GHC
|
2013-05-18 21:16:37 +00:00
|
|
|
import GhcMonad (liftIO)
|
2013-05-17 01:00:01 +00:00
|
|
|
import Language.Haskell.GhcMod.CabalApi
|
|
|
|
import Language.Haskell.GhcMod.GHCApi
|
|
|
|
import Language.Haskell.GhcMod.Types
|
2013-03-04 02:21:41 +00:00
|
|
|
import Prelude
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2013-05-20 05:28:56 +00:00
|
|
|
-- | Obtaining debug information.
|
|
|
|
debugInfo :: Options
|
|
|
|
-> Cradle
|
|
|
|
-> GHCVersion
|
|
|
|
-> FilePath -- ^ A target file
|
|
|
|
-> IO String
|
2013-05-20 02:29:44 +00:00
|
|
|
debugInfo opt cradle ver fileName = unlines <$> withGHC fileName (debug opt cradle ver fileName)
|
2013-03-04 02:21:41 +00:00
|
|
|
|
2013-05-20 05:28:56 +00:00
|
|
|
-- | Obtaining debug information.
|
|
|
|
debug :: Options
|
|
|
|
-> Cradle
|
|
|
|
-> GHCVersion
|
|
|
|
-> FilePath -- ^ A target file
|
|
|
|
-> Ghc [String]
|
2013-03-04 09:11:09 +00:00
|
|
|
debug opt cradle ver fileName = do
|
2013-03-13 04:17:22 +00:00
|
|
|
(gopts, incDir, pkgs) <-
|
2013-03-04 02:21:41 +00:00
|
|
|
if cabal then
|
2013-05-18 21:16:37 +00:00
|
|
|
liftIO $ fromCabalFile (ghcOpts opt) cradle ||> return (ghcOpts opt, [], [])
|
2013-03-04 02:21:41 +00:00
|
|
|
else
|
2013-03-13 04:17:22 +00:00
|
|
|
return (ghcOpts opt, [], [])
|
2013-05-18 21:16:37 +00:00
|
|
|
[fast] <- do
|
2013-03-13 04:17:22 +00:00
|
|
|
void $ initializeFlagsWithCradle opt cradle gopts True
|
|
|
|
setTargetFile fileName
|
2013-04-01 06:59:53 +00:00
|
|
|
pure . canCheckFast <$> depanal [] False
|
2013-03-04 02:21:41 +00:00
|
|
|
return [
|
2013-03-04 09:11:09 +00:00
|
|
|
"GHC version: " ++ ver
|
2013-03-04 02:21:41 +00:00
|
|
|
, "Current directory: " ++ currentDir
|
|
|
|
, "Cabal file: " ++ cabalFile
|
2013-03-05 07:57:18 +00:00
|
|
|
, "GHC options: " ++ unwords gopts
|
|
|
|
, "Include directories: " ++ unwords incDir
|
2013-03-04 02:21:41 +00:00
|
|
|
, "Dependent packages: " ++ intercalate ", " pkgs
|
2013-03-04 04:11:04 +00:00
|
|
|
, "Fast check: " ++ if fast then "Yes" else "No"
|
2013-03-04 02:21:41 +00:00
|
|
|
]
|
|
|
|
where
|
|
|
|
currentDir = cradleCurrentDir cradle
|
|
|
|
cabal = isJust $ cradleCabalFile cradle
|
|
|
|
cabalFile = fromMaybe "" $ cradleCabalFile cradle
|