| author | wenzelm | 
| Thu, 07 Nov 2019 11:40:17 +0100 | |
| changeset 71078 | 5bb2235d843d | 
| parent 70876 | 91b311e7d040 | 
| child 71158 | 1c58a01a372e | 
| permissions | -rw-r--r-- | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 1 | /* Title: Pure/Tools/dump.scala | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 2 | Author: Makarius | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 3 | |
| 68348 | 4 | Dump cumulative PIDE session database. | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 5 | */ | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 6 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 7 | package isabelle | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 8 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 9 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 10 | object Dump | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 11 | {
 | 
| 68316 | 12 | /* aspects */ | 
| 13 | ||
| 14 | sealed case class Aspect_Args( | |
| 68355 | 15 | options: Options, | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 16 | deps: Sessions.Deps, | 
| 68355 | 17 | progress: Progress, | 
| 69896 | 18 | output_dir: Path, | 
| 68929 | 19 | snapshot: Document.Snapshot, | 
| 69534 | 20 | status: Document_Status.Node_Status) | 
| 68319 | 21 |   {
 | 
| 68365 | 22 | def write(file_name: Path, bytes: Bytes) | 
| 68319 | 23 |     {
 | 
| 68929 | 24 | val path = output_dir + Path.basic(snapshot.node_name.theory) + file_name | 
| 68319 | 25 | Isabelle_System.mkdirs(path.dir) | 
| 26 | Bytes.write(path, bytes) | |
| 27 | } | |
| 28 | ||
| 68365 | 29 | def write(file_name: Path, text: String): Unit = | 
| 30 | write(file_name, Bytes(text)) | |
| 68332 | 31 | |
| 68365 | 32 | def write(file_name: Path, body: XML.Body): Unit = | 
| 33 | write(file_name, Symbol.encode(YXML.string_of_body(body))) | |
| 68319 | 34 | } | 
| 68316 | 35 | |
| 68347 | 36 | sealed case class Aspect(name: String, description: String, operation: Aspect_Args => Unit, | 
| 37 | options: List[String] = Nil) | |
| 68345 | 38 |   {
 | 
| 39 | override def toString: String = name | |
| 40 | } | |
| 68316 | 41 | |
| 69521 | 42 | val known_aspects: List[Aspect] = | 
| 68316 | 43 | List( | 
| 68365 | 44 |       Aspect("markup", "PIDE markup (YXML format)",
 | 
| 45 |         { case args =>
 | |
| 46 |             args.write(Path.explode("markup.yxml"),
 | |
| 47 | args.snapshot.markup_to_XML(Text.Range.full, Markup.Elements.full)) | |
| 48 | }), | |
| 68319 | 49 |       Aspect("messages", "output messages (YXML format)",
 | 
| 50 |         { case args =>
 | |
| 68365 | 51 |             args.write(Path.explode("messages.yxml"),
 | 
| 52 | args.snapshot.messages.iterator.map(_._1).toList) | |
| 68347 | 53 | }), | 
| 54 |       Aspect("latex", "generated LaTeX source",
 | |
| 55 |         { case args =>
 | |
| 68365 | 56 | for (entry <- args.snapshot.exports if entry.name == "document.tex") | 
| 57 | args.write(Path.explode(entry.name), entry.uncompressed()) | |
| 69533 
1d2e6a4e073f
clarified options: ensure consolidated Node_Status and thus percentage = 100% for progress;
 wenzelm parents: 
69532diff
changeset | 58 |         }, options = List("export_document")),
 | 
| 68347 | 59 |       Aspect("theory", "foundational theory content",
 | 
| 60 |         { case args =>
 | |
| 61 |             for {
 | |
| 68365 | 62 | entry <- args.snapshot.exports | 
| 68347 | 63 | if entry.name.startsWith(Export_Theory.export_prefix) | 
| 68365 | 64 | } args.write(Path.explode(entry.name), entry.uncompressed()) | 
| 69533 
1d2e6a4e073f
clarified options: ensure consolidated Node_Status and thus percentage = 100% for progress;
 wenzelm parents: 
69532diff
changeset | 65 |         }, options = List("export_theory"))
 | 
| 68345 | 66 | ).sortBy(_.name) | 
| 68316 | 67 | |
| 68 | def show_aspects: String = | |
| 68345 | 69 | cat_lines(known_aspects.map(aspect => aspect.name + " - " + aspect.description)) | 
| 68316 | 70 | |
| 71 | def the_aspect(name: String): Aspect = | |
| 72 | known_aspects.find(aspect => aspect.name == name) getOrElse | |
| 73 |       error("Unknown aspect " + quote(name))
 | |
| 74 | ||
| 75 | ||
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 76 | /* context and session */ | 
| 69538 
faf547d2834c
clarified signature, notably cascade of dump_options, deps, resources, session;
 wenzelm parents: 
69537diff
changeset | 77 | |
| 69896 | 78 | sealed case class Args( | 
| 69897 | 79 | session: Headless.Session, | 
| 80 | snapshot: Document.Snapshot, | |
| 81 | status: Document_Status.Node_Status) | |
| 69896 | 82 |   {
 | 
| 83 | def print_node: String = snapshot.node_name.toString | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 84 | } | 
| 69896 | 85 | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 86 | object Context | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 87 |   {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 88 | def apply( | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 89 | options: Options, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 90 | aspects: List[Aspect] = Nil, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 91 | progress: Progress = No_Progress, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 92 | dirs: List[Path] = Nil, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 93 | select_dirs: List[Path] = Nil, | 
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 94 | selection: Sessions.Selection = Sessions.Selection.empty): Context = | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 95 |     {
 | 
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 96 | val session_options: Options = | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 97 |       {
 | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 98 | val options0 = if (NUMA.enabled) NUMA.policy_options(options) else options | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 99 | val options1 = | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 100 | options0 + | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 101 | "completion_limit=0" + | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 102 | "ML_statistics=false" + | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 103 | "parallel_proofs=0" + | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 104 | "editor_tracing_messages=0" + | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 105 | "editor_presentation" | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 106 |         (options1 /: aspects)({ case (opts, aspect) => (opts /: aspect.options)(_ + _) })
 | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 107 | } | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 108 | |
| 70869 | 109 | val sessions_structure: Sessions.Structure = | 
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 110 | Sessions.load_structure(session_options, dirs = dirs, select_dirs = select_dirs). | 
| 70869 | 111 | selection(selection) | 
| 112 | ||
| 113 |       {
 | |
| 114 | val selection_size = sessions_structure.build_graph.size | |
| 115 |         if (selection_size > 1) progress.echo("Loading " + selection_size + " sessions ...")
 | |
| 116 | } | |
| 117 | ||
| 118 | val deps: Sessions.Deps = | |
| 119 | Sessions.deps(sessions_structure, progress = progress).check_errors | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 120 | |
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 121 | new Context(options, progress, dirs, select_dirs, session_options, deps) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 122 | } | 
| 69896 | 123 | } | 
| 124 | ||
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 125 | class Context private( | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 126 | val options: Options, | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 127 | val progress: Progress, | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 128 | val dirs: List[Path], | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 129 | val select_dirs: List[Path], | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 130 | val session_options: Options, | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 131 | val deps: Sessions.Deps) | 
| 69538 
faf547d2834c
clarified signature, notably cascade of dump_options, deps, resources, session;
 wenzelm parents: 
69537diff
changeset | 132 |   {
 | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 133 | context => | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 134 | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 135 | def session_dirs: List[Path] = dirs ::: select_dirs | 
| 68926 | 136 | |
| 70857 | 137 | def build_logic(logic: String) | 
| 138 |     {
 | |
| 139 | Build.build_logic(options, logic, build_heap = true, progress = progress, | |
| 140 | dirs = session_dirs, strict = true) | |
| 141 | } | |
| 142 | ||
| 70864 | 143 | def sessions( | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 144 | logic: String = default_logic, | 
| 70861 | 145 | log: Logger = No_Logger): List[Session] = | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 146 |     {
 | 
| 70869 | 147 | /* partitions */ | 
| 148 | ||
| 149 | def session_info(session_name: String): Sessions.Info = | |
| 150 | deps.sessions_structure(session_name) | |
| 151 | ||
| 70870 
877fe56af178
proper build_graph to make session selection work as in "isabelle build";
 wenzelm parents: 
70869diff
changeset | 152 | val session_graph = deps.sessions_structure.build_graph | 
| 70869 | 153 | val all_sessions = session_graph.topological_order | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 154 | |
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 155 | val afp_sessions = | 
| 70869 | 156 | (for (name <- all_sessions if session_info(name).is_afp) yield name).toSet | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 157 | |
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 158 | val afp_bulky_sessions = | 
| 70869 | 159 | (for (name <- all_sessions if session_info(name).is_afp_bulky) yield name).toList | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 160 | |
| 70862 | 161 | val base_sessions = | 
| 162 | session_graph.all_preds(List(logic).filter(session_graph.defined)).reverse | |
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 163 | |
| 70869 | 164 | val proof_sessions = | 
| 165 | session_graph.all_succs( | |
| 166 | for (name <- all_sessions if session_info(name).record_proofs) yield name) | |
| 167 | ||
| 168 | ||
| 169 | /* resulting sessions */ | |
| 170 | ||
| 171 | def make_session( | |
| 172 | selected_sessions: List[String], | |
| 173 | pure: Boolean = false, | |
| 174 | record_proofs: Boolean = false): List[Session] = | |
| 175 |       {
 | |
| 176 | if (selected_sessions.isEmpty) Nil | |
| 177 |         else {
 | |
| 178 | val session_logic = if (pure) isabelle.Thy_Header.PURE else logic | |
| 179 | List(new Session(context, session_logic, log, selected_sessions, record_proofs)) | |
| 180 | } | |
| 181 | } | |
| 182 | ||
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 183 | val base = | 
| 70869 | 184 | if (logic == isabelle.Thy_Header.PURE) Nil | 
| 185 | else make_session(base_sessions, pure = true) | |
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 186 | |
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 187 | val main = | 
| 70869 | 188 | make_session( | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 189 | session_graph.topological_order.filterNot(name => | 
| 70869 | 190 | afp_sessions.contains(name) || | 
| 191 | base_sessions.contains(name) || | |
| 192 | proof_sessions.contains(name))) | |
| 193 | ||
| 194 | val proofs = | |
| 195 | make_session(proof_sessions, pure = true, record_proofs = true) | |
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 196 | |
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 197 | val afp = | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 198 | if (afp_sessions.isEmpty) Nil | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 199 |         else {
 | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 200 | val (part1, part2) = | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 201 |           {
 | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 202 | val graph = session_graph.restrict(afp_sessions -- afp_bulky_sessions) | 
| 70862 | 203 | val force_partition1 = AFP.force_partition1.filter(graph.defined) | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 204 | val force_part1 = graph.all_preds(graph.all_succs(force_partition1)).toSet | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 205 | graph.keys.partition(a => force_part1(a) || graph.is_isolated(a)) | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 206 | } | 
| 70869 | 207 | List(part1, part2, afp_bulky_sessions).flatMap(make_session(_)) | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 208 | } | 
| 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 209 | |
| 70874 
2010397f7c9a
load HOL-Proofs first: it introduces some extra "thm" items that are required later on;
 wenzelm parents: 
70871diff
changeset | 210 | proofs ::: base ::: main ::: afp | 
| 70857 | 211 | } | 
| 70875 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 212 | |
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 213 | |
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 214 | /* processed theories */ | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 215 | |
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 216 | private val processed_theories = Synchronized(Set.empty[String]) | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 217 | |
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 218 | def process_theory(theory: String): Boolean = | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 219 | processed_theories.change_result(processed => (!processed(theory), processed + theory)) | 
| 70876 | 220 | |
| 221 | ||
| 222 | /* errors */ | |
| 223 | ||
| 224 | private val errors = Synchronized(List.empty[String]) | |
| 225 | ||
| 226 | def add_errors(more_errs: List[String]) | |
| 227 |     {
 | |
| 228 | errors.change(errs => errs ::: more_errs) | |
| 229 | } | |
| 230 | ||
| 231 | def check_errors | |
| 232 |     {
 | |
| 233 | val errs = errors.value | |
| 234 |       if (errs.nonEmpty) error(errs.mkString("\n\n"))
 | |
| 235 | } | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 236 | } | 
| 68926 | 237 | |
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 238 | class Session private[Dump]( | 
| 70867 | 239 | val context: Context, | 
| 240 | val logic: String, | |
| 241 | log: Logger, | |
| 70869 | 242 | selected_sessions: List[String], | 
| 243 | record_proofs: Boolean) | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 244 |   {
 | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 245 | /* resources */ | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 246 | |
| 70869 | 247 | val options: Options = | 
| 248 | if (record_proofs) context.session_options + "record_proofs=2" | |
| 249 | else context.session_options | |
| 70866 | 250 | |
| 70867 | 251 | private def deps = context.deps | 
| 252 | private def progress = context.progress | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 253 | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 254 | val resources: Headless.Resources = | 
| 70865 | 255 | Headless.Resources.make(options, logic, progress = progress, log = log, | 
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 256 | session_dirs = context.session_dirs, | 
| 70867 | 257 | include_sessions = deps.sessions_structure.imports_topological_order) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 258 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 259 | val used_theories: List[Document.Node.Name] = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 260 |     {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 261 |       for {
 | 
| 70867 | 262 | session_name <- | 
| 70871 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 263 | deps.sessions_structure.build_graph.restrict(selected_sessions.toSet).topological_order | 
| 70867 | 264 | (name, theory_options) <- deps(session_name).used_theories | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 265 | if !resources.session_base.loaded_theory(name.theory) | 
| 70867 | 266 |         if {
 | 
| 267 | def warn(msg: String): Unit = | |
| 268 |             progress.echo_warning("Skipping theory " + name + "  (" + msg + ")")
 | |
| 269 | ||
| 270 | val conditions = | |
| 271 |             space_explode(',', theory_options.string("condition")).
 | |
| 272 | filter(cond => Isabelle_System.getenv(cond) == "") | |
| 273 |           if (conditions.nonEmpty) {
 | |
| 274 |             warn("undefined " + conditions.mkString(", "))
 | |
| 275 | false | |
| 276 | } | |
| 277 |           else if (options.bool("skip_proofs") && !theory_options.bool("skip_proofs")) {
 | |
| 278 |             warn("option skip_proofs")
 | |
| 279 | false | |
| 280 | } | |
| 281 | else true | |
| 282 | } | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 283 | } yield name | 
| 68926 | 284 | } | 
| 285 | ||
| 286 | ||
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 287 | /* process */ | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 288 | |
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 289 | def process(process_theory: Args => Unit, unicode_symbols: Boolean = false) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 290 |     {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 291 | val session = resources.start_session(progress = progress) | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 292 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 293 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 294 | // asynchronous consumer | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 295 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 296 | object Consumer | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 297 |       {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 298 | sealed case class Bad_Theory( | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 299 | name: Document.Node.Name, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 300 | status: Document_Status.Node_Status, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 301 | errors: List[String]) | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 302 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 303 | private val consumer_bad_theories = Synchronized(List.empty[Bad_Theory]) | 
| 68318 | 304 | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 305 | private val consumer = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 306 | Consumer_Thread.fork(name = "dump")( | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 307 | consume = (args: (Document.Snapshot, Document_Status.Node_Status)) => | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 308 |               {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 309 | val (snapshot, status) = args | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 310 | val name = snapshot.node_name | 
| 70871 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 311 |                 if (status.ok) {
 | 
| 70875 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 312 |                   try {
 | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 313 |                     if (context.process_theory(name.theory)) {
 | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 314 | process_theory(Args(session, snapshot, status)) | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 315 | } | 
| 
a62c34770df9
proper guard for process_theory: ensure uniform precedence of results;
 wenzelm parents: 
70874diff
changeset | 316 | } | 
| 70871 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 317 |                   catch {
 | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 318 | case exn: Throwable if !Exn.is_interrupt(exn) => | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 319 | val msg = Exn.message(exn) | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 320 |                       progress.echo("FAILED to process theory " + name)
 | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 321 | progress.echo_error_message(msg) | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 322 | consumer_bad_theories.change(Bad_Theory(name, status, List(msg)) :: _) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 323 | } | 
| 70871 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 324 | } | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 325 |                 else {
 | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 326 | val msgs = | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 327 | for ((tree, pos) <- snapshot.messages if Protocol.is_error(tree)) | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 328 |                     yield {
 | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 329 | "Error" + Position.here(pos) + ":\n" + | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 330 | XML.content(Pretty.formatted(List(tree))) | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 331 | } | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 332 |                   progress.echo("FAILED to process theory " + name)
 | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 333 | msgs.foreach(progress.echo_error_message) | 
| 
2beac4adc565
more complete coverage of sessions: process_theory operation needs to handle duplicate theories;
 wenzelm parents: 
70870diff
changeset | 334 | consumer_bad_theories.change(Bad_Theory(name, status, msgs) :: _) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 335 | } | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 336 | true | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 337 | }) | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 338 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 339 | def apply(snapshot: Document.Snapshot, status: Document_Status.Node_Status): Unit = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 340 | consumer.send((snapshot, status)) | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 341 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 342 | def shutdown(): List[Bad_Theory] = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 343 |         {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 344 | consumer.shutdown() | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 345 | consumer_bad_theories.value.reverse | 
| 70634 
0f8742b5a9e8
more scalable isabelle dump (and derivatives): mark individual theories to share common data in ML;
 wenzelm parents: 
70626diff
changeset | 346 | } | 
| 
0f8742b5a9e8
more scalable isabelle dump (and derivatives): mark individual theories to share common data in ML;
 wenzelm parents: 
70626diff
changeset | 347 | } | 
| 
0f8742b5a9e8
more scalable isabelle dump (and derivatives): mark individual theories to share common data in ML;
 wenzelm parents: 
70626diff
changeset | 348 | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 349 | |
| 70653 
f7c5b30fc432
load theories in stages, to reduce ML heap requirements;
 wenzelm parents: 
70645diff
changeset | 350 | // synchronous body | 
| 68320 
1d33697199c1
shutdown ML process before output: Theories_Result is timeless/stateless;
 wenzelm parents: 
68319diff
changeset | 351 | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 352 |       try {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 353 | val use_theories_result = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 354 | session.use_theories(used_theories.map(_.theory), | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 355 | unicode_symbols = unicode_symbols, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 356 | progress = progress, | 
| 70653 
f7c5b30fc432
load theories in stages, to reduce ML heap requirements;
 wenzelm parents: 
70645diff
changeset | 357 | commit = Some(Consumer.apply _)) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 358 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 359 | val bad_theories = Consumer.shutdown() | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 360 | val bad_msgs = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 361 | bad_theories.map(bad => | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 362 | Output.clean_yxml( | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 363 | "FAILED theory " + bad.name + | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 364 | (if (bad.status.consolidated) "" else ": " + bad.status.percentage + "% finished") + | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 365 |                 (if (bad.errors.isEmpty) "" else bad.errors.mkString("\n", "\n", ""))))
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 366 | |
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 367 | val pending_msgs = | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 368 |           use_theories_result.nodes_pending match {
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 369 | case Nil => Nil | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 370 |             case pending => List("Pending theories: " + commas(pending.map(p => p._1.toString)))
 | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 371 | } | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 372 | |
| 70876 | 373 | context.add_errors(bad_msgs ::: pending_msgs) | 
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 374 | } | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 375 |       finally { session.stop() }
 | 
| 69032 
90bb4cabe1e8
clarified errors: no result from forced session.stop, check pending theories;
 wenzelm parents: 
69026diff
changeset | 376 | } | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 377 | } | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 378 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 379 | |
| 69523 | 380 | /* dump */ | 
| 381 | ||
| 382 |   val default_output_dir: Path = Path.explode("dump")
 | |
| 70858 | 383 | val default_logic: String = Thy_Header.PURE | 
| 69523 | 384 | |
| 70640 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 385 | def dump( | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 386 | options: Options, | 
| 
5f4b8a505090
more explicit type Dump.Session, with context information;
 wenzelm parents: 
70634diff
changeset | 387 | logic: String, | 
| 69523 | 388 | aspects: List[Aspect] = Nil, | 
| 389 | progress: Progress = No_Progress, | |
| 390 | log: Logger = No_Logger, | |
| 391 | dirs: List[Path] = Nil, | |
| 392 | select_dirs: List[Path] = Nil, | |
| 393 | output_dir: Path = default_output_dir, | |
| 69535 | 394 | selection: Sessions.Selection = Sessions.Selection.empty) | 
| 69523 | 395 |   {
 | 
| 70856 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 396 | val context = | 
| 
545229df2f82
clarified signature: static Dump.Context vs. dynamic Dump.Session;
 wenzelm parents: 
70796diff
changeset | 397 | Context(options, aspects = aspects, progress = progress, dirs = dirs, | 
| 70796 
2739631ac368
discontinued pointless dump_checkpoint and share_common_data -- superseded by base logic image in Isabelle/MMT;
 wenzelm parents: 
70779diff
changeset | 398 | select_dirs = select_dirs, selection = selection) | 
| 69523 | 399 | |
| 70864 | 400 | context.build_logic(logic) | 
| 401 | ||
| 70865 | 402 |     for (session <- context.sessions(logic = logic, log = log)) {
 | 
| 403 | session.process((args: Args) => | |
| 404 |         {
 | |
| 405 |           progress.echo("Processing theory " + args.print_node + " ...")
 | |
| 406 | val aspect_args = | |
| 407 | Aspect_Args(session.options, context.deps, progress, output_dir, | |
| 408 | args.snapshot, args.status) | |
| 409 | aspects.foreach(_.operation(aspect_args)) | |
| 410 | }) | |
| 411 | } | |
| 70876 | 412 | |
| 413 | context.check_errors | |
| 69523 | 414 | } | 
| 415 | ||
| 416 | ||
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 417 | /* Isabelle tool wrapper */ | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 418 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 419 | val isabelle_tool = | 
| 68348 | 420 |     Isabelle_Tool("dump", "dump cumulative PIDE session database", args =>
 | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 421 |     {
 | 
| 68345 | 422 | var aspects: List[Aspect] = known_aspects | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 423 | var base_sessions: List[String] = Nil | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 424 | var select_dirs: List[Path] = Nil | 
| 68316 | 425 | var output_dir = default_output_dir | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 426 | var requirements = false | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 427 | var exclude_session_groups: List[String] = Nil | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 428 | var all_sessions = false | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 429 | var logic = default_logic | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 430 | var dirs: List[Path] = Nil | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 431 | var session_groups: List[String] = Nil | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 432 | var options = Options.init() | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 433 | var verbose = false | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 434 | var exclude_sessions: List[String] = Nil | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 435 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 436 |       val getopts = Getopts("""
 | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 437 | Usage: isabelle dump [OPTIONS] [SESSIONS ...] | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 438 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 439 | Options are: | 
| 68345 | 440 |     -A NAMES     dump named aspects (default: """ + known_aspects.mkString("\"", ",", "\"") + """)
 | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 441 | -B NAME include session NAME and all descendants | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 442 | -D DIR include session directory and select its sessions | 
| 68316 | 443 | -O DIR output directory for dumped files (default: """ + default_output_dir + """) | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 444 | -R operate on requirements of selected sessions | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 445 | -X NAME exclude sessions from group NAME and all descendants | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 446 | -a select all sessions | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 447 | -b NAME base logic image (default """ + isabelle.quote(default_logic) + """) | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 448 | -d DIR include session directory | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 449 | -g NAME select session group NAME | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 450 | -o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 451 | -v verbose | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 452 | -x NAME exclude session NAME and all descendants | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 453 | |
| 68348 | 454 | Dump cumulative PIDE session database, with the following aspects: | 
| 68316 | 455 | |
| 456 | """ + Library.prefix_lines("    ", show_aspects) + "\n",
 | |
| 457 |       "A:" -> (arg => aspects = Library.distinct(space_explode(',', arg)).map(the_aspect(_))),
 | |
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 458 | "B:" -> (arg => base_sessions = base_sessions ::: List(arg)), | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 459 | "D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))), | 
| 68316 | 460 | "O:" -> (arg => output_dir = Path.explode(arg)), | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 461 | "R" -> (_ => requirements = true), | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 462 | "X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)), | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 463 | "a" -> (_ => all_sessions = true), | 
| 70859 
6e6254bbce1f
split into standard partitions, for improved scalability;
 wenzelm parents: 
70858diff
changeset | 464 | "b:" -> (arg => logic = arg), | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 465 | "d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))), | 
| 68741 | 466 | "g:" -> (arg => session_groups = session_groups ::: List(arg)), | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 467 | "o:" -> (arg => options = options + arg), | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 468 | "v" -> (_ => verbose = true), | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 469 | "x:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg))) | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 470 | |
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 471 | val sessions = getopts(args) | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 472 | |
| 68951 
a7b1fe2d30ad
more uniform Progress, with theory() for batch-build and theory_percentage() for PIDE session;
 wenzelm parents: 
68948diff
changeset | 473 | val progress = new Console_Progress(verbose = verbose) | 
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 474 | |
| 69535 | 475 |       progress.interrupt_handler {
 | 
| 476 | dump(options, logic, | |
| 477 | aspects = aspects, | |
| 478 | progress = progress, | |
| 479 | dirs = dirs, | |
| 480 | select_dirs = select_dirs, | |
| 481 | output_dir = output_dir, | |
| 482 | selection = Sessions.Selection( | |
| 483 | requirements = requirements, | |
| 484 | all_sessions = all_sessions, | |
| 485 | base_sessions = base_sessions, | |
| 486 | exclude_session_groups = exclude_session_groups, | |
| 487 | exclude_sessions = exclude_sessions, | |
| 488 | session_groups = session_groups, | |
| 489 | sessions = sessions)) | |
| 490 | } | |
| 68308 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 491 | }) | 
| 
119fc05f6b00
support to dump build database produced by PIDE session;
 wenzelm parents: diff
changeset | 492 | } |