86 object Session |
86 object Session |
87 { |
87 { |
88 def apply( |
88 def apply( |
89 options: Options, |
89 options: Options, |
90 logic: String, |
90 logic: String, |
91 dump_checkpoints: Boolean = false, |
|
92 aspects: List[Aspect] = Nil, |
91 aspects: List[Aspect] = Nil, |
93 progress: Progress = No_Progress, |
92 progress: Progress = No_Progress, |
94 log: Logger = No_Logger, |
93 log: Logger = No_Logger, |
95 dirs: List[Path] = Nil, |
94 dirs: List[Path] = Nil, |
96 select_dirs: List[Path] = Nil, |
95 select_dirs: List[Path] = Nil, |
97 selection: Sessions.Selection = Sessions.Selection.empty): Session = |
96 selection: Sessions.Selection = Sessions.Selection.empty): Session = |
98 { |
97 { |
99 new Session( |
98 new Session(options, logic, aspects, progress, log, dirs, select_dirs, selection) |
100 options, logic, dump_checkpoints, aspects, progress, log, dirs, select_dirs, selection) |
|
101 } |
99 } |
102 } |
100 } |
103 |
101 |
104 class Session private( |
102 class Session private( |
105 options: Options, |
103 options: Options, |
106 logic: String, |
104 logic: String, |
107 dump_checkpoints: Boolean, |
|
108 aspects: List[Aspect], |
105 aspects: List[Aspect], |
109 progress: Progress, |
106 progress: Progress, |
110 log: Logger, |
107 log: Logger, |
111 dirs: List[Path], |
108 dirs: List[Path], |
112 select_dirs: List[Path], |
109 select_dirs: List[Path], |
213 try { |
210 try { |
214 val use_theories_result = |
211 val use_theories_result = |
215 session.use_theories(used_theories.map(_.theory), |
212 session.use_theories(used_theories.map(_.theory), |
216 unicode_symbols = unicode_symbols, |
213 unicode_symbols = unicode_symbols, |
217 progress = progress, |
214 progress = progress, |
218 checkpoints = if (dump_checkpoints) deps.dump_checkpoints else Set.empty, |
|
219 commit = Some(Consumer.apply _)) |
215 commit = Some(Consumer.apply _)) |
220 |
216 |
221 val bad_theories = Consumer.shutdown() |
217 val bad_theories = Consumer.shutdown() |
222 val bad_msgs = |
218 val bad_msgs = |
223 bad_theories.map(bad => |
219 bad_theories.map(bad => |
245 val default_output_dir: Path = Path.explode("dump") |
241 val default_output_dir: Path = Path.explode("dump") |
246 |
242 |
247 def dump( |
243 def dump( |
248 options: Options, |
244 options: Options, |
249 logic: String, |
245 logic: String, |
250 dump_checkpoints: Boolean = false, |
|
251 aspects: List[Aspect] = Nil, |
246 aspects: List[Aspect] = Nil, |
252 progress: Progress = No_Progress, |
247 progress: Progress = No_Progress, |
253 log: Logger = No_Logger, |
248 log: Logger = No_Logger, |
254 dirs: List[Path] = Nil, |
249 dirs: List[Path] = Nil, |
255 select_dirs: List[Path] = Nil, |
250 select_dirs: List[Path] = Nil, |
256 output_dir: Path = default_output_dir, |
251 output_dir: Path = default_output_dir, |
257 selection: Sessions.Selection = Sessions.Selection.empty) |
252 selection: Sessions.Selection = Sessions.Selection.empty) |
258 { |
253 { |
259 val session = |
254 val session = |
260 Session(options, logic, dump_checkpoints = dump_checkpoints, aspects = aspects, |
255 Session(options, logic, aspects = aspects, progress = progress, log = log, dirs = dirs, |
261 progress = progress, log = log, dirs = dirs, select_dirs = select_dirs, |
256 select_dirs = select_dirs, selection = selection) |
262 selection = selection) |
|
263 |
257 |
264 session.run((args: Args) => |
258 session.run((args: Args) => |
265 { |
259 { |
266 progress.echo("Processing theory " + args.print_node + " ...") |
260 progress.echo("Processing theory " + args.print_node + " ...") |
267 val aspect_args = |
261 val aspect_args = |
278 Isabelle_Tool("dump", "dump cumulative PIDE session database", args => |
272 Isabelle_Tool("dump", "dump cumulative PIDE session database", args => |
279 { |
273 { |
280 var aspects: List[Aspect] = known_aspects |
274 var aspects: List[Aspect] = known_aspects |
281 var base_sessions: List[String] = Nil |
275 var base_sessions: List[String] = Nil |
282 var select_dirs: List[Path] = Nil |
276 var select_dirs: List[Path] = Nil |
283 var dump_checkpoints = false |
|
284 var output_dir = default_output_dir |
277 var output_dir = default_output_dir |
285 var requirements = false |
278 var requirements = false |
286 var exclude_session_groups: List[String] = Nil |
279 var exclude_session_groups: List[String] = Nil |
287 var all_sessions = false |
280 var all_sessions = false |
288 var dirs: List[Path] = Nil |
281 var dirs: List[Path] = Nil |
296 Usage: isabelle dump [OPTIONS] [SESSIONS ...] |
289 Usage: isabelle dump [OPTIONS] [SESSIONS ...] |
297 |
290 |
298 Options are: |
291 Options are: |
299 -A NAMES dump named aspects (default: """ + known_aspects.mkString("\"", ",", "\"") + """) |
292 -A NAMES dump named aspects (default: """ + known_aspects.mkString("\"", ",", "\"") + """) |
300 -B NAME include session NAME and all descendants |
293 -B NAME include session NAME and all descendants |
301 -C observe option dump_checkpoint for theories |
|
302 -D DIR include session directory and select its sessions |
294 -D DIR include session directory and select its sessions |
303 -O DIR output directory for dumped files (default: """ + default_output_dir + """) |
295 -O DIR output directory for dumped files (default: """ + default_output_dir + """) |
304 -R operate on requirements of selected sessions |
296 -R operate on requirements of selected sessions |
305 -X NAME exclude sessions from group NAME and all descendants |
297 -X NAME exclude sessions from group NAME and all descendants |
306 -a select all sessions |
298 -a select all sessions |
314 Dump cumulative PIDE session database, with the following aspects: |
306 Dump cumulative PIDE session database, with the following aspects: |
315 |
307 |
316 """ + Library.prefix_lines(" ", show_aspects) + "\n", |
308 """ + Library.prefix_lines(" ", show_aspects) + "\n", |
317 "A:" -> (arg => aspects = Library.distinct(space_explode(',', arg)).map(the_aspect(_))), |
309 "A:" -> (arg => aspects = Library.distinct(space_explode(',', arg)).map(the_aspect(_))), |
318 "B:" -> (arg => base_sessions = base_sessions ::: List(arg)), |
310 "B:" -> (arg => base_sessions = base_sessions ::: List(arg)), |
319 "C" -> (_ => dump_checkpoints = true), |
|
320 "D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))), |
311 "D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))), |
321 "O:" -> (arg => output_dir = Path.explode(arg)), |
312 "O:" -> (arg => output_dir = Path.explode(arg)), |
322 "R" -> (_ => requirements = true), |
313 "R" -> (_ => requirements = true), |
323 "X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)), |
314 "X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)), |
324 "a" -> (_ => all_sessions = true), |
315 "a" -> (_ => all_sessions = true), |
333 |
324 |
334 val progress = new Console_Progress(verbose = verbose) |
325 val progress = new Console_Progress(verbose = verbose) |
335 |
326 |
336 progress.interrupt_handler { |
327 progress.interrupt_handler { |
337 dump(options, logic, |
328 dump(options, logic, |
338 dump_checkpoints = dump_checkpoints, |
|
339 aspects = aspects, |
329 aspects = aspects, |
340 progress = progress, |
330 progress = progress, |
341 dirs = dirs, |
331 dirs = dirs, |
342 select_dirs = select_dirs, |
332 select_dirs = select_dirs, |
343 output_dir = output_dir, |
333 output_dir = output_dir, |