output-dir.
This commit is contained in:
19
Check.hs
19
Check.hs
@@ -1,9 +1,12 @@
|
||||
module Check (checkSyntax) where
|
||||
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.Char
|
||||
import Data.List
|
||||
import Param
|
||||
import System.Directory
|
||||
import System.FilePath
|
||||
import System.IO
|
||||
import System.Process
|
||||
|
||||
@@ -11,7 +14,8 @@ import System.Process
|
||||
|
||||
checkSyntax :: Options -> String -> IO String
|
||||
checkSyntax opt file = do
|
||||
(_,_,herr,_) <- runInteractiveProcess (ghc opt) ["--make","-Wall",file] Nothing Nothing
|
||||
makeDirectory (outDir opt)
|
||||
(_,_,herr,_) <- runInteractiveProcess (ghc opt) ["--make","-Wall",file,"-outputdir","dist/flymake","-o","dist/flymake/a.out"] Nothing Nothing
|
||||
refine <$> hGetContents herr
|
||||
where
|
||||
refine = unfoldLines start . map (dropWhile isSpace) . filter (/="") . lines
|
||||
@@ -25,3 +29,16 @@ unfoldLines p (x:xs) = x ++ unfold xs
|
||||
unfold (l:ls)
|
||||
| p l = ('\n':l) ++ unfold ls
|
||||
| otherwise = (' ' :l) ++ unfold ls
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
makeDirectory :: FilePath -> IO ()
|
||||
makeDirectory dir = makeDirectoryRecur $ normalise dir
|
||||
where
|
||||
makeDirectoryRecur "" = return ()
|
||||
makeDirectoryRecur cur = do
|
||||
exist <- doesDirectoryExist cur
|
||||
let par = takeDirectory cur
|
||||
unless exist $ do
|
||||
makeDirectoryRecur par
|
||||
createDirectory cur
|
||||
|
||||
Reference in New Issue
Block a user