output-dir.
This commit is contained in:
parent
133086e1a8
commit
fd04ebfe11
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
|
||||
|
@ -27,6 +27,7 @@ defaultOptions = Options { convert = toPlain
|
||||
, ghc = "ghc"
|
||||
, ghci = "ghci"
|
||||
, ghcPkg = "ghc-pkg"
|
||||
, outDir = "dist/flymake"
|
||||
}
|
||||
|
||||
argspec :: [OptDescr (Options -> Options)]
|
||||
@ -42,6 +43,9 @@ argspec = [ Option ['l'] ["tolisp"]
|
||||
, Option ['p'] ["ghc-pkg"]
|
||||
(ReqArg (\str opts -> opts { ghcPkg = str }) "ghc-pkg")
|
||||
"ghc-pkg path"
|
||||
, Option ['o'] ["output-dir"]
|
||||
(ReqArg (\str opts -> opts { outDir = str }) "dist/flymake")
|
||||
"output directory"
|
||||
]
|
||||
|
||||
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])
|
||||
|
1
Param.hs
1
Param.hs
@ -4,5 +4,6 @@ data Options = Options { convert :: [String] -> String
|
||||
, ghc :: FilePath
|
||||
, ghci :: FilePath
|
||||
, ghcPkg :: FilePath
|
||||
, outDir :: FilePath
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,20 @@
|
||||
ghc-flymake-err-line-patterns)
|
||||
|
||||
(defun ghc-flymake-init ()
|
||||
(let* ((temp-file (flymake-init-create-temp-buffer-copy
|
||||
'flymake-create-temp-inplace))
|
||||
(local-file (file-relative-name
|
||||
temp-file
|
||||
(file-name-directory buffer-file-name))))
|
||||
(list "ghc-mod" (append (ghc-module-command-args)
|
||||
(list "check" local-file)))))
|
||||
(let ((file (file-name-nondirectory (buffer-file-name))))
|
||||
(flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)
|
||||
(list ghc-module-command (append (ghc-module-command-args)
|
||||
(list "check" file)))))
|
||||
|
||||
;; ghc --make GHCMod.hs -outputdir dist/flymake -o dist/flymake/GHCMod
|
||||
|
||||
;; (defun ghc-flymake-init ()
|
||||
;; (let* ((temp-file (flymake-init-create-temp-buffer-copy
|
||||
;; 'flymake-create-temp-inplace))
|
||||
;; (local-file (file-relative-name
|
||||
;; temp-file
|
||||
;; (file-name-directory buffer-file-name))))
|
||||
;; (list ghc-module-command (append (ghc-module-command-args)
|
||||
;; (list "check" local-file)))))
|
||||
|
||||
(provide 'ghc-flymake)
|
Loading…
Reference in New Issue
Block a user