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