@@ -3,6 +3,7 @@
33{-# LANGUAGE GeneralizedNewtypeDeriving #-}
44module Hakyll.Core.Run where
55
6+import Prelude hiding (reverse)
67import Control.Applicative
78import Control.Monad.Reader
89import Control.Monad.State
@@ -30,7 +31,6 @@ import Hakyll.Core.Rules
3031import Hakyll.Core.DirectedGraph
3132import Hakyll.Core.DirectedGraph.Dot
3233import Hakyll.Core.DirectedGraph.DependencySolver
33−import Hakyll.Core.DirectedGraph.ObsoleteFilter
3434import Hakyll.Core.Writable
3535import Hakyll.Core.Store
3636import Hakyll.Core.CompiledItem
@@ -49,6 +49,7 @@ hakyll rules = do
4949 , hakyllResourceProvider = provider
5050 , hakyllStore = store
5151 , hakyllModified = S.empty
52+ , hakyllObsolete = S.empty
5253 }
5354
5455data HakyllEnvironment = HakyllEnvironment
@@ -56,6 +57,7 @@ data HakyllEnvironment = HakyllEnvironment
5657 , hakyllResourceProvider :: ResourceProvider
5758 , hakyllStore :: Store
5859 , hakyllModified :: Set Identifier
60+ , hakyllObsolete :: Set Identifier
5961 }
6062
6163newtype Hakyll a = Hakyll
@@ -98,19 +100,22 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
98100 -- Create the dependency graph
99101 graph = fromList dependencies
100102
103+ liftIO $ writeDot "dependencies.dot" show graph
104+
101105 -- Check which items are up-to-date. This only needs to happen for the new
102106 -- compilers
103107 oldModified <- hakyllModified <$> ask
104108 newModified <- liftIO $ modified provider store $ map fst newCompilers
105− let modified' = oldModified `S.union` newModified
109+ oldObsolete <- hakyllObsolete <$> ask
106110
107− liftIO $ putStrLn $ show modified'
108−
109− let -- Try to reduce the graph using this modified information
110− reducedGraph = filterObsolete modified' graph
111+ let modified' = oldModified `S.union` newModified
112+
113+ -- Find obsolete items
114+ obsolete = reachableNodes (oldObsolete `S.union` modified') $
115+ reverse graph
111116
112− let -- Solve the graph
113− ordered = solveDependencies reducedGraph
117+ -- Solve the graph, retain only the obsolete items
118+ ordered = filter (`S.member` obsolete) $ solveDependencies graph
114119
115120 -- Join the order with the compilers again
116121 orderedCompilers = map (id &&& (compilerMap M.!)) ordered
@@ -118,11 +123,13 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
118123 liftIO $ putStrLn "Adding compilers..."
119124
120125 -- Now run the ordered list of compilers
121− local (updateModified modified') $ unHakyll $ runCompilers orderedCompilers
126+ local (updateEnv modified' obsolete) $
127+ unHakyll $ runCompilers orderedCompilers
122128 where
123129 -- Add the modified information for the new compilers
124− updateModified modified' env = env
130+ updateEnv modified' obsolete env = env
125131 { hakyllModified = modified'
132+ , hakyllObsolete = obsolete
126133 }
127134
128135runCompilers :: [(Identifier, Compiler () CompileRule)]