226 session_content(options, false, Nil, session).syntax |
226 session_content(options, false, Nil, session).syntax |
227 |
227 |
228 |
228 |
229 /* jobs */ |
229 /* jobs */ |
230 |
230 |
231 private class Job(progress: Progress, name: String, val info: Sessions.Info, |
231 private class Job(progress: Progress, name: String, val info: Sessions.Info, tree: Sessions.Tree, |
232 store: Sessions.Store, do_output: Boolean, verbose: Boolean, |
232 store: Sessions.Store, do_output: Boolean, verbose: Boolean, |
233 session_graph: Graph_Display.Graph, command_timings: List[Properties.T]) |
233 session_graph: Graph_Display.Graph, command_timings: List[Properties.T]) |
234 { |
234 { |
235 val output = store.output_dir + Path.basic(name) |
235 val output = store.output_dir + Path.basic(name) |
236 def output_path: Option[Path] = if (do_output) Some(output) else None |
236 def output_path: Option[Path] = if (do_output) Some(output) else None |
237 def output_save_state: String = |
237 def output_save_state: String = |
238 if (do_output) |
238 if (do_output) |
239 "PolyML.SaveState.saveState " + ML_Syntax.print_string_raw(File.platform_path(output)) |
239 "PolyML.SaveState.saveChild (" + ML_Syntax.print_string_raw(File.platform_path(output)) + |
|
240 ", List.length (PolyML.SaveState.showHierarchy ()))" |
240 else "" |
241 else "" |
241 output.file.delete |
242 output.file.delete |
242 |
243 |
243 private val parent = info.parent.getOrElse("") |
244 private val parent = info.parent.getOrElse("") |
244 |
245 |
256 if (Sessions.is_pure(name)) { |
257 if (Sessions.is_pure(name)) { |
257 val eval = |
258 val eval = |
258 "Command_Line.tool0 (fn () => (Session.finish (); Options.reset_default ();" + |
259 "Command_Line.tool0 (fn () => (Session.finish (); Options.reset_default ();" + |
259 " Session.shutdown (); ML_Heap.share_common_data (); " + output_save_state + "));" |
260 " Session.shutdown (); ML_Heap.share_common_data (); " + output_save_state + "));" |
260 ML_Process(info.options, "RAW_ML_SYSTEM", List("--use", "ROOT.ML", "--eval", eval), |
261 ML_Process(info.options, "RAW_ML_SYSTEM", List("--use", "ROOT.ML", "--eval", eval), |
261 cwd = info.dir.file, env = env, store = store) |
262 cwd = info.dir.file, env = env, tree = Some(tree), store = store) |
262 } |
263 } |
263 else { |
264 else { |
264 val args_file = Isabelle_System.tmp_file("build") |
265 val args_file = Isabelle_System.tmp_file("build") |
265 File.write(args_file, YXML.string_of_body( |
266 File.write(args_file, YXML.string_of_body( |
266 { |
267 { |
279 "Command_Line.tool0 (fn () => (" + |
280 "Command_Line.tool0 (fn () => (" + |
280 "Build.build " + ML_Syntax.print_string_raw(File.standard_path(args_file)) + |
281 "Build.build " + ML_Syntax.print_string_raw(File.standard_path(args_file)) + |
281 (if (do_output) "; ML_Heap.share_common_data (); " + output_save_state |
282 (if (do_output) "; ML_Heap.share_common_data (); " + output_save_state |
282 else "") + "));" |
283 else "") + "));" |
283 ML_Process(info.options, parent, List("--eval", eval), cwd = info.dir.file, |
284 ML_Process(info.options, parent, List("--eval", eval), cwd = info.dir.file, |
284 env = env, cleanup = () => args_file.delete, store = store) |
285 env = env, tree = Some(tree), store = store, cleanup = () => args_file.delete) |
285 } |
286 } |
286 process.result( |
287 process.result( |
287 progress_stdout = (line: String) => |
288 progress_stdout = (line: String) => |
288 Library.try_unprefix("\floading_theory = ", line) match { |
289 Library.try_unprefix("\floading_theory = ", line) match { |
289 case Some(theory) => progress.theory(name, theory) |
290 case Some(theory) => progress.theory(name, theory) |
620 results + (name -> Result(false, heap_stamp, Some(Process_Result(1))))) |
621 results + (name -> Result(false, heap_stamp, Some(Process_Result(1))))) |
621 } |
622 } |
622 else if (ancestor_results.forall(_.ok) && !progress.stopped) { |
623 else if (ancestor_results.forall(_.ok) && !progress.stopped) { |
623 progress.echo((if (do_output) "Building " else "Running ") + name + " ...") |
624 progress.echo((if (do_output) "Building " else "Running ") + name + " ...") |
624 val job = |
625 val job = |
625 new Job(progress, name, info, store, do_output, verbose, |
626 new Job(progress, name, info, selected_tree, store, do_output, verbose, |
626 deps(name).session_graph, queue.command_timings(name)) |
627 deps(name).session_graph, queue.command_timings(name)) |
627 loop(pending, running + (name -> (ancestor_heaps, job)), results) |
628 loop(pending, running + (name -> (ancestor_heaps, job)), results) |
628 } |
629 } |
629 else { |
630 else { |
630 progress.echo(name + " CANCELLED") |
631 progress.echo(name + " CANCELLED") |