hake 1.3.5 → 1.3.6
raw patch · 6 files changed
+68/−7 lines, 6 filesdep ~yjtools
Dependency ranges changed: yjtools
Files
- Development/Hake.hs +1/−1
- Development/Hake/Core.hs +1/−1
- Development/Hake/DirectoryTools.hs +20/−0
- Development/Hake/RunHake.hs +2/−2
- Development/Hake/Tribial.hs +39/−0
- hake.cabal +5/−3
Development/Hake.hs view
@@ -47,7 +47,7 @@ import System.Environment (getArgs) import System.Exit (ExitCode(ExitSuccess, ExitFailure)) import System.Directory (doesFileExist)-import System.Directory.Tools (maybeGetModificationTime)+import Development.Hake.DirectoryTools (maybeGetModificationTime) import System.IO.Unsafe (unsafeInterleaveIO) import Control.Monad.Trans (lift) import Control.Monad.Reader (ReaderT(runReaderT), asks)
Development/Hake/Core.hs view
@@ -6,7 +6,7 @@ ) where import System.Directory (doesFileExist)-import System.Directory.Tools (maybeGetModificationTime)+import Development.Hake.DirectoryTools (maybeGetModificationTime) import Control.Monad.Trans (lift) import Control.Monad.Tools (ifM) import Control.Applicative ((<$>), liftA2)
+ Development/Hake/DirectoryTools.hs view
@@ -0,0 +1,20 @@+module Development.Hake.DirectoryTools (+ maybeGetModificationTime+, doesNotExistOrOldThan+) where++import System.Directory (doesFileExist, getModificationTime)+import System.Time (ClockTime)+import Control.Monad.Tools (ifM)+import Control.Applicative (liftA2, (<$>))+import Data.Function (on)++maybeGetModificationTime :: FilePath -> IO (Maybe ClockTime)+maybeGetModificationTime fn+ = ifM (doesFileExist fn)+ (Just <$> getModificationTime fn)+ (return Nothing)++doesNotExistOrOldThan :: FilePath -> FilePath -> IO Bool+doesNotExistOrOldThan dfn sfn+ = on (liftA2 (<)) maybeGetModificationTime dfn sfn
Development/Hake/RunHake.hs view
@@ -24,13 +24,13 @@ import System.Exit (ExitCode(ExitSuccess), exitWith) import System.Directory (createDirectory, doesDirectoryExist, doesFileExist)-import System.Directory.Tools (doesNotExistOrOldThan)+import Development.Hake.DirectoryTools (doesNotExistOrOldThan) import System.FilePath (takeFileName) import System.Process (runProcess, waitForProcess) import Control.Monad (when) import Control.Monad.Tools (unlessM, filterM) import Data.Function.Tools (applyWhen, apply2way)-import YJTools.Tribial (ghcMake, updateFile_)+import Development.Hake.Tribial (ghcMake, updateFile_) import Text.RegexPR (gsubRegexPR, ggetbrsRegexPR, matchRegexPR) import Development.Hake.Variables (defaultTrgtStr, hakefileUpdateOption, hakeDir, commentPair, srcSuffix, exeEscPairs)
+ Development/Hake/Tribial.hs view
@@ -0,0 +1,39 @@+module Development.Hake.Tribial (+ ghcMake+, updateFile_+) where++import System.IO (openFile, hClose, IOMode(WriteMode), hGetLine,+ IOMode(ReadMode), withFile)+import System.IO.Unsafe (unsafeInterleaveIO)+import System.Process (runProcess, waitForProcess)+import System.Exit (ExitCode(ExitSuccess))+import System.Directory (doesFileExist)+import Development.Hake.DirectoryTools (doesNotExistOrOldThan)+import Control.Exception (bracket)+import Control.Monad.Tools (ifM)+import Control.Applicative ((<$>))++ghcMake :: String -> FilePath -> IO ExitCode+ghcMake exe dir = do+ let errFile = dir ++ "/" ++ exe ++ ".error"+ ret <- bracket (openFile errFile WriteMode) hClose $ \errH ->+ runProcess "ghc" [ "--make", exe ] (Just dir)+ Nothing Nothing Nothing (Just errH) >>= waitForProcess+ case ret of+ ExitSuccess -> return ()+ _ -> readFile errFile >>= putStr+ return ret++updateFile_ :: (String -> Maybe String) -> (FilePath -> String) -> FilePath -> FilePath -> IO Bool+updateFile_ gtSrc hdr src dst+ = ifM ( not <$> doesFileExist dst+ `orIO`+ (/= Just src) . gtSrc <$> withFile dst ReadMode (hGetLine)+ `orIO`+ doesNotExistOrOldThan dst src )+ (readFile src >>= writeFile dst . ( (hdr src ++ "\n") ++ ) >> return True )+ ( return False)+ where+ infixr 2 `orIO`+ orIO p1 p2 = do { b1 <- p1; b2 <- unsafeInterleaveIO p2; return $ b1 || b2 }
hake.cabal view
@@ -1,5 +1,5 @@ Name: hake-Version: 1.3.5+Version: 1.3.6 License: GPL License-file: LICENSE Author: Yoshikuni Jujo@@ -78,9 +78,11 @@ GHC-Options: -Wall Build-Depends: base<=4.2.0.3, old-time, mtl, filepath Exposed-Modules: Development.Hake, Development.Hake.OldFunSet, Development.Hake.FunSet, Development.Hake.FunSetRaw, Development.Hake.FunSetIO- Other-Modules: Development.Hake.Variables, Development.Hake.Types, Development.Hake.Tools, Development.Hake.RunHake, Development.Hake.Core+ Other-Modules: Development.Hake.Variables, Development.Hake.Types,+ Development.Hake.Tools, Development.Hake.RunHake, Development.Hake.Core,+ Development.Hake.Tribial, Development.Hake.DirectoryTools Executable hake GHC-Options: -Wall- Build-Depends: directory, process, yjtools >= 0.9.9, regexpr >= 0.5.1+ Build-Depends: directory, process, regexpr >= 0.5.1, yjtools >= 0.9.10 Main-Is: Main.hs