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
|
module Check (checkSyntax) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
|
import Control.Monad
|
||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List
|
import Data.List
|
||||||
import Param
|
import Param
|
||||||
|
import System.Directory
|
||||||
|
import System.FilePath
|
||||||
import System.IO
|
import System.IO
|
||||||
import System.Process
|
import System.Process
|
||||||
|
|
||||||
@ -11,7 +14,8 @@ import System.Process
|
|||||||
|
|
||||||
checkSyntax :: Options -> String -> IO String
|
checkSyntax :: Options -> String -> IO String
|
||||||
checkSyntax opt file = do
|
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
|
refine <$> hGetContents herr
|
||||||
where
|
where
|
||||||
refine = unfoldLines start . map (dropWhile isSpace) . filter (/="") . lines
|
refine = unfoldLines start . map (dropWhile isSpace) . filter (/="") . lines
|
||||||
@ -25,3 +29,16 @@ unfoldLines p (x:xs) = x ++ unfold xs
|
|||||||
unfold (l:ls)
|
unfold (l:ls)
|
||||||
| p l = ('\n':l) ++ unfold ls
|
| p l = ('\n':l) ++ unfold ls
|
||||||
| otherwise = (' ' :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"
|
, ghc = "ghc"
|
||||||
, ghci = "ghci"
|
, ghci = "ghci"
|
||||||
, ghcPkg = "ghc-pkg"
|
, ghcPkg = "ghc-pkg"
|
||||||
|
, outDir = "dist/flymake"
|
||||||
}
|
}
|
||||||
|
|
||||||
argspec :: [OptDescr (Options -> Options)]
|
argspec :: [OptDescr (Options -> Options)]
|
||||||
@ -42,6 +43,9 @@ argspec = [ Option ['l'] ["tolisp"]
|
|||||||
, Option ['p'] ["ghc-pkg"]
|
, Option ['p'] ["ghc-pkg"]
|
||||||
(ReqArg (\str opts -> opts { ghcPkg = str }) "ghc-pkg")
|
(ReqArg (\str opts -> opts { ghcPkg = str }) "ghc-pkg")
|
||||||
"ghc-pkg path"
|
"ghc-pkg path"
|
||||||
|
, Option ['o'] ["output-dir"]
|
||||||
|
(ReqArg (\str opts -> opts { outDir = str }) "dist/flymake")
|
||||||
|
"output directory"
|
||||||
]
|
]
|
||||||
|
|
||||||
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])
|
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
|
, ghc :: FilePath
|
||||||
, ghci :: FilePath
|
, ghci :: FilePath
|
||||||
, ghcPkg :: FilePath
|
, ghcPkg :: FilePath
|
||||||
|
, outDir :: FilePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,20 @@
|
|||||||
ghc-flymake-err-line-patterns)
|
ghc-flymake-err-line-patterns)
|
||||||
|
|
||||||
(defun ghc-flymake-init ()
|
(defun ghc-flymake-init ()
|
||||||
(let* ((temp-file (flymake-init-create-temp-buffer-copy
|
(let ((file (file-name-nondirectory (buffer-file-name))))
|
||||||
'flymake-create-temp-inplace))
|
(flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)
|
||||||
(local-file (file-relative-name
|
(list ghc-module-command (append (ghc-module-command-args)
|
||||||
temp-file
|
(list "check" file)))))
|
||||||
(file-name-directory buffer-file-name))))
|
|
||||||
(list "ghc-mod" (append (ghc-module-command-args)
|
;; ghc --make GHCMod.hs -outputdir dist/flymake -o dist/flymake/GHCMod
|
||||||
(list "check" local-file)))))
|
|
||||||
|
;; (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)
|
(provide 'ghc-flymake)
|
Loading…
Reference in New Issue
Block a user