ghc-core 0.3.0.1 → 0.4
raw patch · 2 files changed
+21/−15 lines, 2 filesdep ~hscolour
Dependency ranges changed: hscolour
Files
- ghc-core.cabal +2/−2
- ghc-core.hs +19/−13
ghc-core.cabal view
@@ -1,5 +1,5 @@ name: ghc-core-version: 0.3.0.1+version: 0.4 license: BSD3 license-file: LICENSE author: Don Stewart@@ -27,7 +27,7 @@ build-depends: base, process, pcre-light,- hscolour ==1.9,+ hscolour >=1.10, directory, filepath main-is: ghc-core.hs
ghc-core.hs view
@@ -94,6 +94,8 @@ (_, _, es) -> ioError (userError (concat es ++ usageInfo header options)) where header = "Usage: ghc-core [OPTION...] [--] [GHC_OPTION...] [files...]" +isExtCoreFile :: FilePath -> Bool+isExtCoreFile = (== ".hcr") . takeExtension ------------------------------------------------------------------------ main :: IO ()@@ -107,21 +109,25 @@ mv <- getEnvMaybe "PAGER" let less = case mv of Just s -> case s of "less" -> "less -f" ; _ -> s _ -> "less -f"-- strs' <- polish `fmap` compileWithCore (optGhcExe opts) args- (strs,tmps) <- do- -- TODO this is a bit lazy on my part...- x <- readProcess "sh" ["-c","ls /tmp/ghc*/*.s | head -1"] []- case x of- Left _ -> return (strs', Nothing)- Right s -> if "-fvia-C" `elem` args- then do asm <- readFile (init s)- return ((strs' ++ asm), Just $ takeDirectory s)- else return (strs', Just $ takeDirectory s)+ + (strs, tmps) <- case args of+ [fp] | isExtCoreFile fp -> do+ contents <- readFile fp+ return (contents, Nothing)+ _ -> do+ strs' <- polish `fmap` compileWithCore (optGhcExe opts) args+ -- TODO this is a bit lazy on my part...+ x <- readProcess "sh" ["-c","ls /tmp/ghc*/*.s | head -1"] []+ case x of+ Left _ -> return (strs', Nothing)+ Right s -> if "-fvia-C" `elem` args+ then do asm <- readFile (init s)+ return ((strs' ++ asm), Just $ takeDirectory s)+ else return (strs', Just $ takeDirectory s) let nice = hscolour (optFormat opts)- colourPrefs False True False strs+ colourPrefs False True False [] strs bracket (openTempFile "/tmp" "ghc-core-XXXX.hcr")@@ -191,7 +197,7 @@ compileWithCore ghc opts = do let args = words "-O2 -keep-tmp-files -ddump-simpl -ddump-asm -ddump-simpl-stats -no-recomp --make" - x <- readProcess ghc (opts ++ args) []+ x <- readProcess ghc (args ++ opts) [] case x of Left (err,str,std) -> do mapM_ putStrLn (lines str)