2013-03-04 04:41:56 +00:00
|
|
|
module Debug (debugInfo) where
|
2013-03-04 02:21:41 +00:00
|
|
|
|
|
|
|
import CabalApi
|
|
|
|
import GHCApi
|
|
|
|
import Control.Applicative
|
|
|
|
import Data.List (intercalate)
|
|
|
|
import Data.Maybe
|
|
|
|
import Prelude
|
|
|
|
import Types
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2013-03-04 09:11:09 +00:00
|
|
|
debugInfo :: Options -> Cradle -> String -> String -> IO String
|
|
|
|
debugInfo opt cradle ver fileName = unlines <$> debug opt cradle ver fileName
|
2013-03-04 02:21:41 +00:00
|
|
|
|
2013-03-04 09:11:09 +00:00
|
|
|
debug :: Options -> Cradle -> String -> String -> IO [String]
|
|
|
|
debug opt cradle ver fileName = do
|
2013-03-04 02:21:41 +00:00
|
|
|
(gopts, incDir, pkgs, langext) <-
|
|
|
|
if cabal then
|
|
|
|
fromCabalFile (ghcOpts opt) cradle
|
|
|
|
else
|
|
|
|
return (ghcOpts opt, [], [], [])
|
2013-03-04 04:41:56 +00:00
|
|
|
dflags <- getDynamicFlags
|
|
|
|
fast <- getFastCheck dflags fileName (Just langext)
|
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
|