@@ -109,6 +109,7 @@ import Data.HashMap.Strict (HashMap)
109
109
import Data.HashSet (HashSet )
110
110
import qualified Data.HashSet as Set
111
111
import Database.SQLite.Simple
112
+ import Development.IDE (Rules , getFileExists )
112
113
import Development.IDE.Core.Tracing (withTrace )
113
114
import Development.IDE.Session.Diagnostics (renderCradleError )
114
115
import Development.IDE.Types.Shake (Key , WithHieDb ,
@@ -128,7 +129,6 @@ import qualified Data.Set as OS
128
129
import qualified Development.IDE.GHC.Compat.Util as Compat
129
130
import GHC.Data.Graph.Directed
130
131
131
- import Development.IDE (Rules , getFileExists )
132
132
import GHC.Data.Bag
133
133
import GHC.Driver.Env (hsc_all_home_unit_ids )
134
134
import GHC.Driver.Errors.Types
@@ -541,7 +541,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
541
541
hscEnv <- liftIO $ emptyHscEnv ideNc _libDir
542
542
all_target_details <- liftIO $ newComponentCache recorder optExtensions hieYaml _cfp hscEnv old_deps new_deps rootDir
543
543
544
- this_dep_info <- liftIO $ getDependencyInfo $ maybeToList hieYaml
544
+ this_dep_info <- getDependencyInfo $ maybeToList hieYaml
545
545
-- this should be added to deps
546
546
let (all_targets, this_flags_map, this_options)
547
547
= case HM. lookup _cfp flags_map' of
@@ -579,7 +579,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
579
579
hscEnv <- liftIO $ emptyHscEnv ideNc libDir
580
580
newTargetDfs <- liftIO $ evalGhcEnv hscEnv $ setOptions cfp opts (hsc_dflags hscEnv) rootDir
581
581
let deps = componentDependencies opts ++ maybeToList hieYaml
582
- dep_info <- liftIO $ getDependencyInfo deps
582
+ dep_info <- getDependencyInfo deps
583
583
-- Now lookup to see whether we are combining with an existing HscEnv
584
584
-- or making a new one. The lookup returns the HscEnv and a list of
585
585
-- information about other components loaded into the HscEnv
@@ -716,7 +716,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
716
716
session (hieYaml, cfp, opts, libDir)
717
717
-- Failure case, either a cradle error or the none cradle
718
718
Left err -> do
719
- dep_info <- liftIO $ getDependencyInfo (maybeToList hieYaml)
719
+ dep_info <- getDependencyInfo (maybeToList hieYaml)
720
720
let res = (map (\ err' -> renderCradleError err' cradle cfp) err, Nothing )
721
721
liftIO $ atomically $ modifyTVar' fileToFlags $
722
722
Map. insertWith HM. union hieYaml (HM. singleton cfp (res, dep_info))
@@ -741,7 +741,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
741
741
Just (opts, old_di) -> do
742
742
-- need to differ two kinds of invocation, one is the file is changed
743
743
-- other is the cache version bumped
744
- deps_ok <- liftIO $ checkDependencyInfo old_di
744
+ deps_ok <- checkDependencyInfo old_di
745
745
if not deps_ok
746
746
then do
747
747
logWith recorder Debug $ LogClearingCache file
@@ -750,15 +750,14 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
750
750
else return $ Just (opts, Map. keys old_di, [] , [] )
751
751
Nothing -> return Nothing
752
752
-- install cache version check to get notified when the cache is changed
753
- -- todo but some how it is informing other, then other inform us, causing a loop
753
+ v <- useNoFile_ SessionCacheVersion
754
+ logWith recorder Debug $ LogCacheVersion file v
755
+
754
756
case someThing of
755
757
Just result@ (_, deps, _files, _keys) -> do
756
758
mapM_ addDependency deps
757
759
return $ Just result
758
760
Nothing -> do
759
- v <- useNoFile_ SessionCacheVersion
760
- logWith recorder Debug $ LogCacheVersion file v
761
-
762
761
catchError file hieYaml $ do
763
762
result@ (_, deps, files, keys) <- consultCradle file
764
763
-- add the deps to the Shake graph
@@ -1128,7 +1127,7 @@ setCacheDirs recorder CacheDirs{..} dflags = do
1128
1127
-- we can then make a rule to build each entry in the map
1129
1128
1130
1129
-- See Note [Multi Cradle Dependency Info]
1131
- type DependencyInfo = Map. Map FilePath ( Maybe UTCTime )
1130
+ type DependencyInfo = Map. Map FilePath FileVersion
1132
1131
type HieMap = Map. Map (Maybe FilePath ) [RawComponentInfo ]
1133
1132
-- | Maps a "hie.yaml" location to all its Target Filepaths and options.
1134
1133
type FlagsMap = Map. Map (Maybe FilePath ) (HM. HashMap NormalizedFilePath (IdeResult HscEnvEq , DependencyInfo ))
@@ -1187,7 +1186,7 @@ data ComponentInfo = ComponentInfo
1187
1186
1188
1187
-- | Check if any dependency has been modified lately.
1189
1188
-- it depend on the last result
1190
- checkDependencyInfo :: DependencyInfo -> IO Bool
1189
+ checkDependencyInfo :: DependencyInfo -> Action Bool
1191
1190
checkDependencyInfo old_di = do
1192
1191
di <- getDependencyInfo (Map. keys old_di)
1193
1192
return (di == old_di)
@@ -1202,15 +1201,17 @@ checkDependencyInfo old_di = do
1202
1201
-- | Computes a mapping from a filepath to its latest modification date.
1203
1202
-- See Note [Multi Cradle Dependency Info] why we do this ourselves instead
1204
1203
-- of letting shake take care of it.
1205
- getDependencyInfo :: [FilePath ] -> IO DependencyInfo
1204
+ getDependencyInfo :: [FilePath ] -> Action DependencyInfo
1206
1205
getDependencyInfo fs = Map. fromList <$> mapM do_one fs
1207
-
1208
1206
where
1209
- safeTryIO :: IO a -> IO (Either IOException a )
1210
- safeTryIO = Safe. try
1211
-
1212
- do_one :: FilePath -> IO (FilePath , Maybe UTCTime )
1213
- do_one fp = (fp,) . eitherToMaybe <$> safeTryIO (getModificationTime fp)
1207
+ -- safeTryIO :: Action a -> Action (Either IOException a)
1208
+ -- safeTryIO = Safe.try
1209
+
1210
+ do_one :: FilePath -> Action (FilePath , FileVersion )
1211
+ do_one fpp = do
1212
+ let fp = toNormalizedFilePath' fpp
1213
+ fv <- use_ GetModificationTime fp
1214
+ return (fromNormalizedFilePath fp, fv)
1214
1215
1215
1216
-- | This function removes all the -package flags which refer to packages we
1216
1217
-- are going to deal with ourselves. For example, if a executable depends
0 commit comments