From 34534e07ff908c565f6b4f0e83a420c0ed7cff7d Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 28 Apr 2010 10:05:45 +0900 Subject: [PATCH] removing *.o file so that C-xC-s surely works. --- Check.hs | 14 +++++++++++--- GHCMod.hs | 3 ++- Param.hs | 19 +++++++++++++------ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Check.hs b/Check.hs index 5d7ba52..8e0a1fc 100644 --- a/Check.hs +++ b/Check.hs @@ -16,11 +16,16 @@ import System.Process checkSyntax :: Options -> String -> IO String checkSyntax opt file = do - makeDirectory (outDir opt) + let outdir = outDir opt + outfile = outFile opt + objfile = objectFile outdir file + makeDirectory outdir + exist <- doesFileExist objfile + when exist $ removeFile objfile #if __GLASGOW_HASKELL__ >= 611 - (_,_,herr,_) <- runInteractiveProcess (ghc opt) ["--make","-Wall","-fno-warn-unused-do-bind",file,"-outputdir","dist/flymake","-o","dist/flymake/a.out","-i..","-i../..","-i../../..","-i../../../..","-i../../../../.."] Nothing Nothing + (_,_,herr,_) <- runInteractiveProcess (ghc opt) ["--make","-Wall","-fno-warn-unused-do-bind",file,"-outputdir",outdir,"-o",outfile,"-i..","-i../..","-i../../..","-i../../../..","-i../../../../.."] Nothing Nothing #else - (_,_,herr,_) <- runInteractiveProcess (ghc opt) ["--make","-Wall",file,"-outputdir","dist/flymake","-o","dist/flymake/a.out","-i..","-i../..","-i../../..","-i../../../..","-i../../../../.."] Nothing Nothing + (_,_,herr,_) <- runInteractiveProcess (ghc opt) ["--make","-Wall",file,"-outputdir",outdir,"-o",outfile,"-i..","-i../..","-i../../..","-i../../../..","-i../../../../.."] Nothing Nothing #endif hSetBinaryMode herr False refine <$> hGetContents herr @@ -51,3 +56,6 @@ makeDirectory dir = makeDirectoryRecur $ normalise dir unless exist $ do makeDirectoryRecur par createDirectory cur + +objectFile :: FilePath -> FilePath -> FilePath +objectFile dir hsfile = dir replaceExtension hsfile ".o" diff --git a/GHCMod.hs b/GHCMod.hs index afe7685..d136b6b 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -28,7 +28,8 @@ defaultOptions = Options { convert = toPlain , ghc = "ghc" , ghci = "ghci" , ghcPkg = "ghc-pkg" - , outDir = "dist/flymake" + , outDir = outputDir + , outFile = outputFile } argspec :: [OptDescr (Options -> Options)] diff --git a/Param.hs b/Param.hs index f666b6a..9ca4c72 100644 --- a/Param.hs +++ b/Param.hs @@ -1,9 +1,16 @@ module Param where -data Options = Options { convert :: [String] -> String - , ghc :: FilePath - , ghci :: FilePath - , ghcPkg :: FilePath - , outDir :: FilePath - } +data Options = Options { + convert :: [String] -> String + , ghc :: FilePath + , ghci :: FilePath + , ghcPkg :: FilePath + , outDir :: FilePath + , outFile :: FilePath + } +outputDir :: String +outputDir = "dist/flymake" + +outputFile :: String +outputFile = "dist/flymake/a.out"