@@ -12,7 +12,7 @@ import Control.Arrow ((&&&))
12import Control.Monad (foldM, forM_, forM, filterM)
12import Control.Monad (foldM, forM_, forM, filterM)
13import Data.Map (Map)
13import Data.Map (Map)
14import qualified Data.Map as M
14import qualified Data.Map as M
15−import Data.Monoid (mempty)
15+import Data.Monoid (mempty, mappend)
16import Data.Typeable (Typeable)
16import Data.Typeable (Typeable)
17import Data.Binary (Binary)
17import Data.Binary (Binary)
18import System.FilePath ((</>))
18import System.FilePath ((</>))
@@ -56,7 +56,6 @@ hakyll rules = do
57 state = HakyllState
57 state = HakyllState
58 { hakyllModified = S.empty
58 { hakyllModified = S.empty
59− , hakyllObsolete = S.empty
60 , hakyllGraph = mempty
59 , hakyllGraph = mempty
@@ -68,7 +67,6 @@ data HakyllEnvironment = HakyllEnvironment
69data HakyllState = HakyllState
68data HakyllState = HakyllState
70 { hakyllModified :: Set Identifier
69 { hakyllModified :: Set Identifier
71− , hakyllObsolete :: Set Identifier
72 , hakyllGraph :: DirectedGraph Identifier
70 , hakyllGraph :: DirectedGraph Identifier
@@ -98,7 +96,10 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
98 provider <- hakyllResourceProvider <$> ask
96 provider <- hakyllResourceProvider <$> ask
99 store <- hakyllStore <$> ask
97 store <- hakyllStore <$> ask
99+ let -- Create a set of new compilers
100+ newCompilerIdentifiers = S.fromList $ map fst newCompilers
101− let -- All compilers
102+ -- All compilers
102 compilers = oldCompilers ++ newCompilers
103 compilers = oldCompilers ++ newCompilers
104 -- Get all dependencies for the compilers
105 -- Get all dependencies for the compilers
@@ -110,39 +111,44 @@ addNewCompilers oldCompilers newCompilers = Hakyll $ do
110 compilerMap = M.fromList compilers
111 compilerMap = M.fromList compilers
112 -- Create the dependency graph
113 -- Create the dependency graph
113− graph = fromList dependencies
114+ currentGraph = fromList dependencies
116+ -- Find the old graph and append the new graph to it. This forms the
118+ completeGraph <- (mappend currentGraph) . hakyllGraph <$> get
115− liftIO $ writeDot "dependencies.dot" show graph
120+ liftIO $ writeDot "dependencies.dot" show completeGraph
117 -- Check which items are up-to-date. This only needs to happen for the new
122 -- Check which items are up-to-date. This only needs to happen for the new
118 -- compilers
123 -- compilers
119 oldModified <- hakyllModified <$> get
124 oldModified <- hakyllModified <$> get
120 newModified <- liftIO $ modified provider store $ map fst newCompilers
125 newModified <- liftIO $ modified provider store $ map fst newCompilers
121− oldObsolete <- hakyllObsolete <$> get
123 let modified' = oldModified `S.union` newModified
127 let modified' = oldModified `S.union` newModified
125− -- Find obsolete items
129+ -- Find obsolete items. Every item that is reachable from a modified
126− obsolete = reachableNodes (oldObsolete `S.union` modified') $
130+ -- item is considered obsolete. From these obsolete items, we are only
127− reverse graph
131+ -- interested in ones that are in the current subgraph.
132+ obsolete = S.filter (`S.member` newCompilerIdentifiers)
133+ $ reachableNodes modified' $ reverse completeGraph
129− -- Solve the graph, retain only the obsolete items
135+ -- Solve the graph and retain only the obsolete items
130− ordered = filter (`S.member` obsolete) $ solveDependencies graph
136+ ordered = filter (`S.member` obsolete) $ solveDependencies currentGraph
132 -- Join the order with the compilers again
138 -- Join the order with the compilers again
133 orderedCompilers = map (id &&& (compilerMap M.!)) ordered
139 orderedCompilers = map (id &&& (compilerMap M.!)) ordered
135 liftIO $ putStrLn "Adding compilers..."
141 liftIO $ putStrLn "Adding compilers..."
137− modify $ updateState modified' obsolete
143+ modify $ updateState modified' completeGraph
139 -- Now run the ordered list of compilers
145 -- Now run the ordered list of compilers
140 unHakyll $ runCompilers orderedCompilers
146 unHakyll $ runCompilers orderedCompilers
142 -- Add the modified information for the new compilers
148 -- Add the modified information for the new compilers
143− updateState modified' obsolete state = state
149+ updateState modified' graph state = state
144 { hakyllModified = modified'
150 { hakyllModified = modified'
145− , hakyllObsolete = obsolete
151+ , hakyllGraph = graph
148runCompilers :: [(Identifier, Compiler () CompileRule)]
154runCompilers :: [(Identifier, Compiler () CompileRule)]