225 else context.session_options |
225 else context.session_options |
226 |
226 |
227 private def deps = context.deps |
227 private def deps = context.deps |
228 private def progress = context.progress |
228 private def progress = context.progress |
229 |
229 |
230 private val selected_session = selected_sessions.toSet |
|
231 |
|
232 private def selected_theory(name: Document.Node.Name): Boolean = |
|
233 selected_session(deps.sessions_structure.theory_qualifier(name.theory)) |
|
234 |
|
235 val resources: Headless.Resources = |
230 val resources: Headless.Resources = |
236 Headless.Resources.make(options, logic, progress = progress, log = log, |
231 Headless.Resources.make(options, logic, progress = progress, log = log, |
237 session_dirs = context.session_dirs, |
232 session_dirs = context.session_dirs, |
238 include_sessions = deps.sessions_structure.imports_topological_order) |
233 include_sessions = deps.sessions_structure.imports_topological_order) |
239 |
234 |
240 val used_theories: List[Document.Node.Name] = |
235 val used_theories: List[Document.Node.Name] = |
241 { |
236 { |
242 for { |
237 for { |
243 session_name <- |
238 session_name <- |
244 deps.sessions_structure.build_graph.restrict(selected_session).topological_order |
239 deps.sessions_structure.build_graph.restrict(selected_sessions.toSet).topological_order |
245 (name, theory_options) <- deps(session_name).used_theories |
240 (name, theory_options) <- deps(session_name).used_theories |
246 if !resources.session_base.loaded_theory(name.theory) |
241 if !resources.session_base.loaded_theory(name.theory) |
247 if { |
242 if { |
248 def warn(msg: String): Unit = |
243 def warn(msg: String): Unit = |
249 progress.echo_warning("Skipping theory " + name + " (" + msg + ")") |
244 progress.echo_warning("Skipping theory " + name + " (" + msg + ")") |
287 Consumer_Thread.fork(name = "dump")( |
282 Consumer_Thread.fork(name = "dump")( |
288 consume = (args: (Document.Snapshot, Document_Status.Node_Status)) => |
283 consume = (args: (Document.Snapshot, Document_Status.Node_Status)) => |
289 { |
284 { |
290 val (snapshot, status) = args |
285 val (snapshot, status) = args |
291 val name = snapshot.node_name |
286 val name = snapshot.node_name |
292 if (selected_theory(name)) { |
287 if (status.ok) { |
293 if (status.ok) { |
288 try { process_theory(Args(session, snapshot, status)) } |
294 try { process_theory(Args(session, snapshot, status)) } |
289 catch { |
295 catch { |
290 case exn: Throwable if !Exn.is_interrupt(exn) => |
296 case exn: Throwable if !Exn.is_interrupt(exn) => |
291 val msg = Exn.message(exn) |
297 val msg = Exn.message(exn) |
292 progress.echo("FAILED to process theory " + name) |
298 progress.echo("FAILED to process theory " + name) |
293 progress.echo_error_message(msg) |
299 progress.echo_error_message(msg) |
294 consumer_bad_theories.change(Bad_Theory(name, status, List(msg)) :: _) |
300 consumer_bad_theories.change(Bad_Theory(name, status, List(msg)) :: _) |
295 } |
|
296 } |
|
297 else { |
|
298 val msgs = |
|
299 for ((tree, pos) <- snapshot.messages if Protocol.is_error(tree)) |
|
300 yield { |
|
301 "Error" + Position.here(pos) + ":\n" + |
|
302 XML.content(Pretty.formatted(List(tree))) |
301 } |
303 } |
302 } |
304 progress.echo("FAILED to process theory " + name) |
303 else { |
305 msgs.foreach(progress.echo_error_message) |
304 val msgs = |
306 consumer_bad_theories.change(Bad_Theory(name, status, msgs) :: _) |
305 for ((tree, pos) <- snapshot.messages if Protocol.is_error(tree)) |
|
306 yield { |
|
307 "Error" + Position.here(pos) + ":\n" + |
|
308 XML.content(Pretty.formatted(List(tree))) |
|
309 } |
|
310 progress.echo("FAILED to process theory " + name) |
|
311 msgs.foreach(progress.echo_error_message) |
|
312 consumer_bad_theories.change(Bad_Theory(name, status, msgs) :: _) |
|
313 } |
|
314 } |
307 } |
315 true |
308 true |
316 }) |
309 }) |
317 |
310 |
318 def apply(snapshot: Document.Snapshot, status: Document_Status.Node_Status): Unit = |
311 def apply(snapshot: Document.Snapshot, status: Document_Status.Node_Status): Unit = |