aboutsummaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-08-15 23:42:57 +0000
committerDavid Waern <david.waern@gmail.com>2009-08-15 23:42:57 +0000
commit0c2f863e8189e6c31d0b28fa363132993e60b6d4 (patch)
treec790c2096e5a217a12dd9584af53c3068a563ad7 /src/Main.hs
parent3f8dc6644815d3219bcb970ce6fa5cbee144c7c4 (diff)
Put all the IN_GHC_TREE stuff inside getGhcLibDir
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 4a38b8eb..a676d9a8 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -155,21 +155,7 @@ main = handleTopExceptions $ do
if not (null fileArgs)
then do
- libDir <- case getGhcLibDir flags of
- Just dir -> return dir
- Nothing ->
-#ifdef IN_GHC_TREE
- do m <- getExecDir
- case m of
- Nothing -> error "No GhcLibDir found"
-#ifdef NEW_GHC_LAYOUT
- Just d -> return (d </> ".." </> "lib")
-#else
- Just d -> return (d </> "..")
-#endif
-#else
- return libdir -- from GHC.Paths
-#endif
+ libDir <- getGhcLibDir flags
#if __GLASGOW_HASKELL__ >= 609
-- We have one global error handler for all GHC source errors. Other kinds
@@ -415,11 +401,23 @@ startGhc libDir flags = do
-------------------------------------------------------------------------------
-getGhcLibDir :: [Flag] -> Maybe String
-getGhcLibDir flags =
+getGhcLibDir :: [Flag] -> IO String
+getGhcLibDir flags = do
case [ dir | Flag_GhcLibDir dir <- flags ] of
- [] -> Nothing
- xs -> Just $ last xs
+ [] ->
+#ifdef IN_GHC_TREE
+ do m <- getExecDir
+ case m of
+ Nothing -> error "No GhcLibDir found"
+#ifdef NEW_GHC_LAYOUT
+ Just d -> return (d </> ".." </> "lib")
+#else
+ Just d -> return (d </> "..")
+#endif
+#else
+ return libdir -- from GHC.Paths
+#endif
+ xs -> return $ last xs
getVerbosity :: Monad m => [Flag] -> m Verbosity