aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2013-09-07 10:46:59 +0200
committerSimon Hengel <sol@typeful.net>2013-09-18 22:43:35 +0200
commita5bf30f4968e7058e9c2a1f6264def56631d8bdd (patch)
tree4f89ae09154fd99bdd0325426242d49dc2de2280 /src
parentbac81211804b5db56c75983212f3df03208ced03 (diff)
Fallback to ./resources when Cabal data is not found
(so that themes are found during development)
Diffstat (limited to 'src')
-rw-r--r--src/Haddock.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Haddock.hs b/src/Haddock.hs
index 1deb6408..398aed4c 100644
--- a/src/Haddock.hs
+++ b/src/Haddock.hs
@@ -40,6 +40,7 @@ import Data.IORef
import qualified Data.Map as Map
import System.IO
import System.Exit
+import System.Directory
#if defined(mingw32_HOST_OS)
import Foreign
@@ -339,11 +340,19 @@ withGhc libDir flags ghcActs = saveStaticFlagGlobals >>= \savedFlags -> do
getHaddockLibDir :: [Flag] -> IO String
getHaddockLibDir flags =
case [str | Flag_Lib str <- flags] of
- [] ->
+ [] -> do
#ifdef IN_GHC_TREE
getInTreeDir
#else
- getDataDir -- provided by Cabal
+ d <- getDataDir -- provided by Cabal
+ doesDirectoryExist d >>= \exists -> case exists of
+ True -> return d
+ False -> do
+ -- If directory does not exist then we are probably invoking from
+ -- ./dist/build/haddock/haddock so we use ./resources as a fallback.
+ doesDirectoryExist "resources" >>= \exists_ -> case exists_ of
+ True -> return "resources"
+ False -> die ("Haddock's resource directory (" ++ d ++ ") does not exist!\n")
#endif
fs -> return (last fs)