diff options
-rw-r--r-- | haddock.cabal | 1 | ||||
-rw-r--r-- | src/Haddock/Options.hs | 2 | ||||
-rw-r--r-- | src/Main.hs | 11 | ||||
-rw-r--r-- | tests/runtests.hs | 9 |
4 files changed, 13 insertions, 10 deletions
diff --git a/haddock.cabal b/haddock.cabal index 3be3d1ea..7883d52f 100644 --- a/haddock.cabal +++ b/haddock.cabal @@ -17,6 +17,7 @@ build-depends: base, haskell98, ghc >= 6.8.2 && < 6.9, + ghc-paths, filepath, directory, pretty, diff --git a/src/Haddock/Options.hs b/src/Haddock/Options.hs index 6e5514cf..d1b20d3a 100644 --- a/src/Haddock/Options.hs +++ b/src/Haddock/Options.hs @@ -91,7 +91,7 @@ options :: Bool -> [OptDescr Flag] options backwardsCompat = [ Option ['B'] [] (ReqArg Flag_GhcLibDir "DIR") - "path to the GHC lib dir, e.g /usr/lib/ghc", + "path to the GHC lib dir, to override the default path", Option ['o'] ["odir"] (ReqArg Flag_OutputDir "DIR") "directory in which to put the output files", Option ['l'] ["lib"] (ReqArg Flag_Lib "DIR") diff --git a/src/Main.hs b/src/Main.hs index f19ae659..3626abe4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -34,6 +34,7 @@ import System.Exit import System.Environment import GHC +import GHC.Paths import DynFlags import Bag import Util (handleDyn) @@ -111,8 +112,12 @@ main = handleTopExceptions $ do if not (null fileArgs) then do + + let libDir + | Just dir <- getGhcLibDir flags = dir + | otherwise = libdir -- from GHC.Paths + -- initialize GHC - libDir <- getGhcLibDir flags (session, dynflags) <- startGhc libDir (ghcFlags flags) -- get packages supplied with --read-interface @@ -275,8 +280,8 @@ dumpInterfaceFile ifaces homeLinks flags = getGhcLibDir flags = case [ dir | Flag_GhcLibDir dir <- flags ] of - [] -> throwE "no GHC lib dir specified" - xs -> return $ last xs + [] -> Nothing + xs -> Just $ last xs handleEasyFlags flags fileArgs = do diff --git a/tests/runtests.hs b/tests/runtests.hs index ac6b293e..74259fbe 100644 --- a/tests/runtests.hs +++ b/tests/runtests.hs @@ -10,11 +10,8 @@ import Text.Regex main = do - args <- getArgs - when (null args) $ error "You must give the path to the GHC lib dir as an argument" putStrLn "Running tests..." - let libdir = head args - test libdir + test putStrLn "All tests passed!" @@ -43,11 +40,11 @@ check modules = do putStrLn $ "Pass: " ++ mod ++ " (no .ref file)" -test libdir = do +test = do contents <- getDirectoryContents "tests" let mods = filter ((==) ".hs" . takeExtension) contents let outdir = "output" let mods' = map ("tests" </>) mods - code <- system $ printf "haddock -B %s -w -o %s -h --optghc=-fglasgow-exts --optghc=-w %s" libdir outdir (unwords mods') + code <- system $ printf "haddock -w -o %s -h --optghc=-fglasgow-exts --optghc=-w %s" outdir (unwords mods') unless (code == ExitSuccess) $ error "Haddock run failed! Exiting." check mods |