diff options
author | davve <davve@dtek.chalmers.se> | 2007-03-08 15:59:49 +0000 |
---|---|---|
committer | davve <davve@dtek.chalmers.se> | 2007-03-08 15:59:49 +0000 |
commit | c5aa02bc0b97ba73ee19ddd230e0d13f902799ff (patch) | |
tree | c25ccf091615db45c951c3428d0ad18073413a61 /src/Main.hs | |
parent | 7cb99d181c1d34241681e6600c702409c4fcc530 (diff) |
Go back to -B flag
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/Main.hs b/src/Main.hs index feb815fd..944ee10f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -73,35 +73,16 @@ import StaticFlags ( parseStaticFlags ) -- Top-level stuff -------------------------------------------------------------------------------- --- | Get the GHC lib dir by asking the GHC binary that this program was built --- with (or should've been built with if it hasn't moved). -getGHCLibDir = do - str <- systemCaptureStdout 0 (compilerPath ++ " --print-libdir") - case lines str of - (path:_) -> return path - _ -> die ("Error: " ++ compilerPath ++ " did not respond well to " ++ - "--print-libdir") - --- temporarily taken from Cabal. TODO: use a library -systemCaptureStdout :: Int -> String -> IO String -systemCaptureStdout verbose cmd = do - withTempFile "." "" $ \tmp -> do - let cmd_line = cmd ++ " >" ++ tmp - when (verbose > 0) $ putStrLn cmd_line - res <- system cmd_line - case res of - ExitFailure _ -> die ("executing external program failed: "++cmd_line) - ExitSuccess -> do str <- readFile tmp - let ev [] = ' '; ev xs = last xs - ev str `seq` return str +parseLibDir (('-':'B':libdir):rest) = (libdir,rest) +parseLibDir _ = die "Error: no -B<ghc_lib_dir> argument\n" main :: IO () main = do args <- getArgs - libDir <- getGHCLibDir + let (libDir, args') = parseLibDir args -- find out which flag mode we are in - let (isGHCMode, rest) = parseModeFlag args + let (isGHCMode, rest) = parseModeFlag args' -- initialize GHC (session, dynflags) <- startGHC libDir |