226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/autobuild/parallel.rb', line 226
def resolve_cycle(all_tasks, tasks, reverse_dependencies)
cycle = tasks.dup
chain = []
next_task = tasks.first
loop do
task = next_task
chain << task
tasks.delete(next_task)
next_task = task.prerequisite_tasks.find do |dep_task|
if chain.include?(dep_task)
reject = chain.take_while { |t| t != dep_task }
return chain[reject.size..-1]
elsif tasks.include?(dep_task)
true
end
end
unless next_task
Autobuild.fatal "parallel processing stopped prematurely, "\
"but no cycle is present in the remaining tasks"
Autobuild.fatal "remaining tasks: #{cycle.map(&:name).join(', ')}"
Autobuild.fatal "known dependencies at initialization time that "\
"could block the processing of the remaining tasks"
reverse_dependencies.each do |parent_task, parents|
if cycle.include?(parent_task)
parents.each do |p|
Autobuild.fatal " #{p}: #{parent_task}"
end
end
end
Autobuild.fatal "known dependencies right now that could block "\
"the processing of the remaining tasks"
all_tasks.each do |p|
(cycle & p.prerequisite_tasks).each do |t|
Autobuild.fatal " #{p}: #{t}"
end
end
raise "failed to resolve cycle in #{cycle.map(&:name).join(', ')}"
end
end
chain
end
|