@@ -11,13 +11,11 @@ import Control.Monad.Trans (liftIO)
1111import Control.Applicative (Applicative, (<$>))
1212import Control.Monad.Reader (ReaderT, runReaderT, ask)
1313import Control.Monad.State.Strict (StateT, runStateT, get, put)
14−import Control.Arrow ((&&&))
1514import Data.Map (Map)
1615import qualified Data.Map as M
1716import Data.Monoid (mempty, mappend)
1817import Data.Maybe (fromMaybe)
1918import System.FilePath ((</>))
20−import Data.Set (Set)
2119import qualified Data.Set as S
2220
2321import Hakyll.Core.Routes
@@ -31,7 +29,6 @@ import Hakyll.Core.Resource.Provider.File
3129import Hakyll.Core.Rules.Internal
3230import Hakyll.Core.DirectedGraph
3331import Hakyll.Core.DirectedGraph.Dot
34−import Hakyll.Core.DirectedGraph.DependencySolver
3532import Hakyll.Core.DependencyAnalyzer
3633import Hakyll.Core.Writable
3734import Hakyll.Core.Store
@@ -65,14 +62,12 @@ run configuration rules = do
6562 , hakyllRoutes = rulesRoutes ruleSet
6663 , hakyllResourceProvider = provider
6764 , hakyllStore = store
68− , hakyllOldGraph = oldGraph
6965 }
7066
7167 -- Run the program and fetch the resulting state
7268 ((), state') <- runStateT stateT $ RuntimeState
7369 { hakyllAnalyzer = makeDependencyAnalyzer mempty (const False) oldGraph
7470 , hakyllCompilers = M.empty
75− , hakyllModified = S.empty
7671 }
7772
7873 -- We want to save the final dependency graph for the next run
@@ -89,13 +84,11 @@ data RuntimeEnvironment = RuntimeEnvironment
8984 , hakyllRoutes :: Routes
9085 , hakyllResourceProvider :: ResourceProvider
9186 , hakyllStore :: Store
92− , hakyllOldGraph :: DirectedGraph Identifier
9387 }
9488
9589data RuntimeState = RuntimeState
9690 { hakyllAnalyzer :: DependencyAnalyzer Identifier
9791 , hakyllCompilers :: Map Identifier (Compiler () CompileRule)
98− , hakyllModified :: Set Identifier
9992 }
10093
10194newtype Runtime a = Runtime
@@ -104,12 +97,14 @@ newtype Runtime a = Runtime
10497
10598-- | Return a set of modified identifiers
10699--
100+{-
107101modified :: ResourceProvider -- ^ Resource provider
108102 -> Store -- ^ Store
109103 -> [Identifier] -- ^ Identifiers to check
110104 -> IO (Set Identifier) -- ^ Modified resources
111105modified provider store ids = fmap S.fromList $ flip filterM ids $ \id' ->
112106 resourceModified provider (Resource id') store
107+-}
113108
114109-- | Add a number of compilers and continue using these compilers
115110--
@@ -126,7 +121,6 @@ addNewCompilers newCompilers = Runtime $ do
126121 -- Old state information
127122 oldCompilers <- hakyllCompilers <$> get
128123 oldAnalyzer <- hakyllAnalyzer <$> get
129− oldModified <- hakyllModified <$> get
130124
131125 let -- Create a new partial dependency graph
132126 dependencies = flip map newCompilers $ \(id', compiler) ->
@@ -137,18 +131,30 @@ addNewCompilers newCompilers = Runtime $ do
137131 newGraph = fromList dependencies
138132
139133 -- Check which items have been modified
140− newModified <- liftIO $ modified provider store $ map fst newCompilers
134+ modified <- fmap S.fromList $ flip filterM (map fst newCompilers) $
135+ liftIO . resourceModified provider store . Resource
136+ -- newModified <- liftIO $ modified provider store $ map fst newCompilers
141137
142138 -- Create a new analyzer and append it to the currect one
143− let newAnalyzer =
144− makeDependencyAnalyzer newGraph (`S.member` newModified) mempty
139+ let newAnalyzer = makeDependencyAnalyzer newGraph (`S.member` modified) $
140+ analyzerPreviousGraph oldAnalyzer
145141 analyzer = mappend oldAnalyzer newAnalyzer
146142
143+ -- Debugging
144+ liftIO $ putStrLn $ "Remains: " ++ show (analyzerRemains newAnalyzer)
145+ liftIO $ putStrLn $ "Done: " ++ show (analyzerDone newAnalyzer)
146+ liftIO $ writeFile "old-prev.dot" $ toDot show (analyzerPreviousGraph oldAnalyzer)
147+ liftIO $ writeFile "old.dot" $ toDot show (analyzerGraph oldAnalyzer)
148+ liftIO $ writeFile "old-prev.dot" $ toDot show (analyzerPreviousGraph oldAnalyzer)
149+ liftIO $ writeFile "new.dot" $ toDot show (analyzerGraph newAnalyzer)
150+ liftIO $ writeFile "new-prev.dot" $ toDot show (analyzerPreviousGraph newAnalyzer)
151+ liftIO $ writeFile "result.dot" $ toDot show (analyzerGraph analyzer)
152+ liftIO $ writeFile "result-prev.dot" $ toDot show (analyzerPreviousGraph analyzer)
153+
147154 -- Update the state
148155 put $ RuntimeState
149156 { hakyllAnalyzer = analyzer
150157 , hakyllCompilers = M.union oldCompilers (M.fromList newCompilers)
151− , hakyllModified = S.union oldModified newModified
152158 }
153159
154160 -- Continue
@@ -162,7 +168,7 @@ stepAnalyzer = Runtime $ do
162168 put $ state { hakyllAnalyzer = analyzer' }
163169
164170 case signal of Done -> return ()
165− Cycle c -> return ()
171+ Cycle _ -> return ()
166172 Build id' -> unRuntime $ build id'
167173
168174build :: Identifier -> Runtime ()
@@ -171,16 +177,15 @@ build id' = Runtime $ do
171177 routes <- hakyllRoutes <$> ask
172178 provider <- hakyllResourceProvider <$> ask
173179 store <- hakyllStore <$> ask
174− modified' <- hakyllModified <$> get
175180 compilers <- hakyllCompilers <$> get
176181
177182 section logger $ "Compiling " ++ show id'
178183
179− let -- Fetch the right compiler from the map
180− compiler = compilers M.! id'
184+ -- Fetch the right compiler from the map
185+ let compiler = compilers M.! id'
181186
182− -- Check if the resource was modified
183− isModified = id' `S.member` modified'
187+ -- Check if the resource was modified
188+ isModified <- liftIO $ resourceModified provider store (Resource id')
184189
185190 -- Run the compiler
186191 result <- timed logger "Total compile time" $ liftIO $