@@ -3,6 +3,7 @@
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4module Hakyll.Core.Run where
4module Hakyll.Core.Run where
6+import Prelude hiding (reverse)
6import Control.Applicative
7import Control.Applicative
7import Control.Monad.Reader
8import Control.Monad.Reader
8import Control.Monad.State
9import Control.Monad.State
@@ -30,7 +31,6 @@ import Hakyll.Core.Rules
30import Hakyll.Core.DirectedGraph
31import Hakyll.Core.DirectedGraph
31import Hakyll.Core.DirectedGraph.Dot
32import Hakyll.Core.DirectedGraph.Dot
32import Hakyll.Core.DirectedGraph.DependencySolver
33import Hakyll.Core.DirectedGraph.DependencySolver
33−import Hakyll.Core.DirectedGraph.ObsoleteFilter
34import Hakyll.Core.Writable
34import Hakyll.Core.Writable
35import Hakyll.Core.Store
35import Hakyll.Core.Store
36import Hakyll.Core.CompiledItem
36import Hakyll.Core.CompiledItem
@@ -49,6 +49,7 @@ hakyll rules = do
49 , hakyllResourceProvider = provider
49 , hakyllResourceProvider = provider
50 , hakyllStore = store
50 , hakyllStore = store
51 , hakyllModified = S.empty
51 , hakyllModified = S.empty
52+ , hakyllObsolete = S.empty
54data HakyllEnvironment = HakyllEnvironment
55data HakyllEnvironment = HakyllEnvironment
@@ -56,6 +57,7 @@ data HakyllEnvironment = HakyllEnvironment
56 , hakyllResourceProvider :: ResourceProvider
57 , hakyllResourceProvider :: ResourceProvider
57 , hakyllStore :: Store
58 , hakyllStore :: Store
58 , hakyllModified :: Set Identifier
59 , hakyllModified :: Set Identifier
60+ , hakyllObsolete :: Set Identifier
61newtype Hakyll a = Hakyll
63newtype Hakyll a = Hakyll
@@ -98,19 +100,22 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
98 -- Create the dependency graph
100 -- Create the dependency graph
99 graph = fromList dependencies
101 graph = fromList dependencies
103+ liftIO $ writeDot "dependencies.dot" show graph
101 -- Check which items are up-to-date. This only needs to happen for the new
105 -- Check which items are up-to-date. This only needs to happen for the new
102 -- compilers
106 -- compilers
103 oldModified <- hakyllModified <$> ask
107 oldModified <- hakyllModified <$> ask
104 newModified <- liftIO $ modified provider store $ map fst newCompilers
108 newModified <- liftIO $ modified provider store $ map fst newCompilers
105− let modified' = oldModified `S.union` newModified
109+ oldObsolete <- hakyllObsolete <$> ask
107− liftIO $ putStrLn $ show modified'
111+ let modified' = oldModified `S.union` newModified
109− let -- Try to reduce the graph using this modified information
113+ -- Find obsolete items
110− reducedGraph = filterObsolete modified' graph
114+ obsolete = reachableNodes (oldObsolete `S.union` modified') $
112− let -- Solve the graph
117+ -- Solve the graph, retain only the obsolete items
113− ordered = solveDependencies reducedGraph
118+ ordered = filter (`S.member` obsolete) $ solveDependencies graph
115 -- Join the order with the compilers again
120 -- Join the order with the compilers again
116 orderedCompilers = map (id &&& (compilerMap M.!)) ordered
121 orderedCompilers = map (id &&& (compilerMap M.!)) ordered
@@ -118,11 +123,13 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
118 liftIO $ putStrLn "Adding compilers..."
123 liftIO $ putStrLn "Adding compilers..."
120 -- Now run the ordered list of compilers
125 -- Now run the ordered list of compilers
126+ local (updateEnv modified' obsolete) $
121− local (updateModified modified') $ unHakyll $ runCompilers orderedCompilers
127+ unHakyll $ runCompilers orderedCompilers
123 -- Add the modified information for the new compilers
129 -- Add the modified information for the new compilers
124− updateModified modified' env = env
130+ updateEnv modified' obsolete env = env
125 { hakyllModified = modified'
131 { hakyllModified = modified'
132+ , hakyllObsolete = obsolete
128runCompilers :: [(Identifier, Compiler () CompileRule)]
135runCompilers :: [(Identifier, Compiler () CompileRule)]