ghc-7.6: allow directory-1.2

Get rid of old-time depend (and ClockTime in favour of UTCTime).
time-compat helps to retain backward compatibility with directory-1.1
and lower.
This commit is contained in:
Sergei Trofimovich
2013-03-09 21:38:43 +00:00
parent 6898804a11
commit 05e5895134
4 changed files with 17 additions and 14 deletions

View File

@@ -111,7 +111,8 @@ executable gf
fst, fst,
directory, directory,
random, random,
old-time, time,
time-compat,
old-locale, old-locale,
process, process,
pretty, pretty,

View File

@@ -40,13 +40,14 @@ import Data.List
import Data.Maybe(isJust) import Data.Maybe(isJust)
import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Char8 as BS
import qualified Data.Map as Map import qualified Data.Map as Map
import System.Time import Data.Time
import Data.Time.Compat (toUTCTime)
import System.Directory import System.Directory
import System.FilePath import System.FilePath
import Text.PrettyPrint import Text.PrettyPrint
type ModName = String type ModName = String
type ModEnv = Map.Map ModName (ClockTime,[ModName]) type ModEnv = Map.Map ModName (UTCTime,[ModName])
-- | Returns a list of all files to be compiled in topological order i.e. -- | Returns a list of all files to be compiled in topological order i.e.
@@ -95,13 +96,13 @@ getAllFiles opts ps env file = do
(file,gfTime,gfoTime) <- do (file,gfTime,gfoTime) <- do
mb_gfFile <- ioeIO $ getFilePath ps (gfFile name) mb_gfFile <- ioeIO $ getFilePath ps (gfFile name)
case mb_gfFile of case mb_gfFile of
Just gfFile -> do gfTime <- ioeIO $ getModificationTime gfFile Just gfFile -> do gfTime <- ioeIO $ toUTCTime `fmap` getModificationTime gfFile
mb_gfoTime <- ioeIO $ catch (liftM Just $ getModificationTime (gf2gfo opts gfFile)) mb_gfoTime <- ioeIO $ catch (liftM Just $ toUTCTime `fmap` getModificationTime (gf2gfo opts gfFile))
(\_->return Nothing) (\_->return Nothing)
return (gfFile, Just gfTime, mb_gfoTime) return (gfFile, Just gfTime, mb_gfoTime)
Nothing -> do mb_gfoFile <- ioeIO $ getFilePath (maybe id (:) (flag optGFODir opts) ps) (gfoFile name) Nothing -> do mb_gfoFile <- ioeIO $ getFilePath (maybe id (:) (flag optGFODir opts) ps) (gfoFile name)
case mb_gfoFile of case mb_gfoFile of
Just gfoFile -> do gfoTime <- ioeIO $ getModificationTime gfoFile Just gfoFile -> do gfoTime <- ioeIO $ toUTCTime `fmap` getModificationTime gfoFile
return (gfoFile, Nothing, Just gfoTime) return (gfoFile, Nothing, Just gfoTime)
Nothing -> ioeErr $ Bad (render (text "File" <+> text (gfFile name) <+> text "does not exist." $$ Nothing -> ioeErr $ Bad (render (text "File" <+> text (gfFile name) <+> text "does not exist." $$
text "searched in:" <+> vcat (map text ps))) text "searched in:" <+> vcat (map text ps)))
@@ -147,7 +148,7 @@ gf2gfo opts file = maybe (gfoFile (dropExtension file))
-- From the given Options and the time stamps computes -- From the given Options and the time stamps computes
-- whether the module have to be computed, read from .gfo or -- whether the module have to be computed, read from .gfo or
-- the environment version have to be used -- the environment version have to be used
selectFormat :: Options -> Maybe ClockTime -> Maybe ClockTime -> Maybe ClockTime -> (CompStatus,Maybe ClockTime) selectFormat :: Options -> Maybe UTCTime -> Maybe UTCTime -> Maybe UTCTime -> (CompStatus,Maybe UTCTime)
selectFormat opts mtenv mtgf mtgfo = selectFormat opts mtenv mtgf mtgfo =
case (mtenv,mtgfo,mtgf) of case (mtenv,mtgfo,mtgf) of
(_,_,Just tgf) | fromSrc -> (CSComp,Nothing) (_,_,Just tgf) | fromSrc -> (CSComp,Nothing)
@@ -172,7 +173,7 @@ data CompStatus =
| CSEnv -- gfo is in env | CSEnv -- gfo is in env
deriving Eq deriving Eq
type ModuleInfo = (ModName,CompStatus,Maybe ClockTime,Bool,[ModName],InitPath) type ModuleInfo = (ModName,CompStatus,Maybe UTCTime,Bool,[ModName],InitPath)
importsOfModule :: SourceModule -> (ModName,[ModName]) importsOfModule :: SourceModule -> (ModName,[ModName])
importsOfModule (m,mi) = (modName m,depModInfo mi []) importsOfModule (m,mi) = (modName m,depModInfo mi [])

View File

@@ -14,7 +14,8 @@ import System.Directory(doesDirectoryExist,doesFileExist,createDirectory,
setCurrentDirectory,getCurrentDirectory, setCurrentDirectory,getCurrentDirectory,
getDirectoryContents,removeFile,removeDirectory, getDirectoryContents,removeFile,removeDirectory,
getModificationTime) getModificationTime)
import System.Time(toUTCTime,formatCalendarTime) import Data.Time.Compat (toUTCTime)
import Data.Time (formatTime)
import System.Locale(defaultTimeLocale,rfc822DateFormat) import System.Locale(defaultTimeLocale,rfc822DateFormat)
import System.FilePath(dropExtension,takeExtension,takeFileName,takeDirectory, import System.FilePath(dropExtension,takeExtension,takeFileName,takeDirectory,
(</>)) (</>))
@@ -249,8 +250,7 @@ handle documentroot state0 cache execute1
do t <- liftIO $ getModificationTime path do t <- liftIO $ getModificationTime path
return $ makeObj ["path".=path,"time".=format t] return $ makeObj ["path".=path,"time".=format t]
where where
format = formatCalendarTime defaultTimeLocale rfc822DateFormat format = formatTime defaultTimeLocale rfc822DateFormat
. toUTCTime
rm path | takeExtension path `elem` ok_to_delete = rm path | takeExtension path `elem` ok_to_delete =
do b <- liftIO $ doesFileExist path do b <- liftIO $ doesFileExist path

View File

@@ -4,11 +4,12 @@ import Control.Concurrent.MVar
import Data.Map (Map) import Data.Map (Map)
import qualified Data.Map as Map import qualified Data.Map as Map
import System.Directory (getModificationTime) import System.Directory (getModificationTime)
import System.Time (ClockTime) import Data.Time (UTCTime)
import Data.Time.Compat (toUTCTime)
data Cache a = Cache { data Cache a = Cache {
cacheLoad :: FilePath -> IO a, cacheLoad :: FilePath -> IO a,
cacheObjects :: MVar (Map FilePath (MVar (Maybe (ClockTime, a)))) cacheObjects :: MVar (Map FilePath (MVar (Maybe (UTCTime, a))))
} }
newCache :: (FilePath -> IO a) -> IO (Cache a) newCache :: (FilePath -> IO a) -> IO (Cache a)
@@ -27,7 +28,7 @@ readCache c file =
Nothing -> do v <- newMVar Nothing Nothing -> do v <- newMVar Nothing
return (Map.insert file v objs, v) return (Map.insert file v objs, v)
-- Check time stamp, and reload if different than the cache entry -- Check time stamp, and reload if different than the cache entry
readObject m = do t' <- getModificationTime file readObject m = do t' <- toUTCTime `fmap` getModificationTime file
x' <- case m of x' <- case m of
Just (t,x) | t' == t -> return x Just (t,x) | t' == t -> return x
_ -> cacheLoad c file _ -> cacheLoad c file