| author | wenzelm | 
| Mon, 16 Dec 2019 13:58:46 +0100 | |
| changeset 71283 | cfcc1a2233ca | 
| parent 70991 | f9f7c34b7dd4 | 
| child 71611 | fb6953e77000 | 
| permissions | -rw-r--r-- | 
| 50686 | 1 | (* Title: Pure/Tools/build.ML | 
| 48418 | 2 | Author: Makarius | 
| 3 | ||
| 4 | Build Isabelle sessions. | |
| 5 | *) | |
| 6 | ||
| 7 | signature BUILD = | |
| 8 | sig | |
| 48731 
a45ba78abcc1
more casual exit back to ML toplevel, to accomodate commit in SML/NJ which continues at the saved point;
 wenzelm parents: 
48681diff
changeset | 9 | val build: string -> unit | 
| 48418 | 10 | end; | 
| 11 | ||
| 12 | structure Build: BUILD = | |
| 13 | struct | |
| 14 | ||
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 15 | (* command timings *) | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 16 | |
| 56615 | 17 | type timings = ((string * Time.time) Inttab.table) Symtab.table; (*file -> offset -> name, time*) | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 18 | |
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 19 | val empty_timings: timings = Symtab.empty; | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 20 | |
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 21 | fun update_timings props = | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 22 | (case Markup.parse_command_timing_properties props of | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 23 |     SOME ({file, offset, name}, time) =>
 | 
| 51666 
b97aeb018900
add command timings (like document command status);
 wenzelm parents: 
51662diff
changeset | 24 | Symtab.map_default (file, Inttab.empty) | 
| 62826 | 25 | (Inttab.map_default (offset, (name, time)) (fn (_, t) => (name, t + time))) | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 26 | | NONE => I); | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 27 | |
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 28 | fun approximative_id name pos = | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 29 | (case (Position.file_of pos, Position.offset_of pos) of | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 30 | (SOME file, SOME offset) => | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 31 |       if name = "" then NONE else SOME {file = file, offset = offset, name = name}
 | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 32 | | _ => NONE); | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 33 | |
| 65058 
3e9f382fb67e
absent timing information means zero, according to 0070053570c4, f235646b1b73;
 wenzelm parents: 
64599diff
changeset | 34 | fun get_timings timings tr = | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 35 | (case approximative_id (Toplevel.name_of tr) (Toplevel.pos_of tr) of | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 36 |     SOME {file, offset, name} =>
 | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 37 | (case Symtab.lookup timings file of | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 38 | SOME offsets => | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 39 | (case Inttab.lookup offsets offset of | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 40 | SOME (name', time) => if name = name' then SOME time else NONE | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 41 | | NONE => NONE) | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 42 | | NONE => NONE) | 
| 65058 
3e9f382fb67e
absent timing information means zero, according to 0070053570c4, f235646b1b73;
 wenzelm parents: 
64599diff
changeset | 43 | | NONE => NONE) | 
| 
3e9f382fb67e
absent timing information means zero, according to 0070053570c4, f235646b1b73;
 wenzelm parents: 
64599diff
changeset | 44 | |> the_default Time.zeroTime; | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 45 | |
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 46 | |
| 52052 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 47 | (* session timing *) | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 48 | |
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 49 | fun session_timing name verbose f x = | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 50 | let | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 51 | val start = Timing.start (); | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 52 | val y = f x; | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 53 | val timing = Timing.result start; | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 54 | |
| 62925 | 55 | val threads = string_of_int (Multithreading.max_threads ()); | 
| 52052 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 56 | val factor = Time.toReal (#cpu timing) / Time.toReal (#elapsed timing) | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 57 | |> Real.fmt (StringCvt.FIX (SOME 2)); | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 58 | |
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 59 | val timing_props = | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 60 |       [("threads", threads)] @ Markup.timing_properties timing @ [("factor", factor)];
 | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 61 |     val _ = writeln ("\fTiming = " ^ YXML.string_of_body (XML.Encode.properties timing_props));
 | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 62 | val _ = | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 63 | if verbose then | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 64 |         Output.physical_stderr ("Timing " ^ name ^ " (" ^
 | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 65 | threads ^ " threads, " ^ Timing.message timing ^ ", factor " ^ factor ^ ")\n") | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 66 | else (); | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 67 | in y end; | 
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 68 | |
| 
892061142ba6
discontinued obsolete isabelle usedir, mkdir, make;
 wenzelm parents: 
52041diff
changeset | 69 | |
| 50683 | 70 | (* protocol messages *) | 
| 71 | ||
| 72 | fun protocol_message props output = | |
| 51216 | 73 | (case props of | 
| 74 | function :: args => | |
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 75 | if function = Markup.ML_statistics orelse function = Markup.task_statistics then | 
| 70907 | 76 | Protocol_Message.inline (#2 function) args | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 77 | else if function = Markup.command_timing then | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 78 | let | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 79 | val name = the_default "" (Properties.get args Markup.nameN); | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 80 | val pos = Position.of_properties args; | 
| 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 81 |           val {elapsed, ...} = Markup.parse_timing_properties args;
 | 
| 62793 
f235646b1b73
less bulky timing information, e.g. HOL 56913 ~> 672;
 wenzelm parents: 
62715diff
changeset | 82 | val is_significant = | 
| 
f235646b1b73
less bulky timing information, e.g. HOL 56913 ~> 672;
 wenzelm parents: 
62715diff
changeset | 83 | Timing.is_relevant_time elapsed andalso | 
| 62826 | 84 | elapsed >= Options.default_seconds "command_timing_threshold"; | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 85 | in | 
| 62793 
f235646b1b73
less bulky timing information, e.g. HOL 56913 ~> 672;
 wenzelm parents: 
62715diff
changeset | 86 | if is_significant then | 
| 59149 
0070053570c4
suppress irrelevant timing messages (the majority);
 wenzelm parents: 
59058diff
changeset | 87 | (case approximative_id name pos of | 
| 70907 | 88 | SOME id => | 
| 89 | Protocol_Message.inline (#2 function) (Markup.command_timing_properties id elapsed) | |
| 59149 
0070053570c4
suppress irrelevant timing messages (the majority);
 wenzelm parents: 
59058diff
changeset | 90 | | NONE => ()) | 
| 
0070053570c4
suppress irrelevant timing messages (the majority);
 wenzelm parents: 
59058diff
changeset | 91 | else () | 
| 51662 
3391a493f39a
just one timing protocol function, with 3 implementations: TTY/PG, PIDE/document, build;
 wenzelm parents: 
51661diff
changeset | 92 | end | 
| 66873 
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
 wenzelm parents: 
66712diff
changeset | 93 | else if function = Markup.theory_timing then | 
| 70907 | 94 | Protocol_Message.inline (#2 function) args | 
| 51216 | 95 | else | 
| 96 | (case Markup.dest_loading_theory props of | |
| 97 |           SOME name => writeln ("\floading_theory = " ^ name)
 | |
| 70907 | 98 | | NONE => Export.protocol_message props output) | 
| 51661 | 99 | | [] => raise Output.Protocol_Message props); | 
| 51045 
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
 wenzelm parents: 
50982diff
changeset | 100 | |
| 50683 | 101 | |
| 65307 | 102 | (* build theories *) | 
| 50683 | 103 | |
| 67297 
86a099f896fc
formal check of @{cite} bibtex entries -- only in batch-mode session builds;
 wenzelm parents: 
67219diff
changeset | 104 | fun build_theories symbols bibtex_entries last_timing qualifier master_dir (options, thys) = | 
| 59366 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 105 | let | 
| 68179 
da70c9e91135
clarified signature: more explicit type "context" with full options;
 wenzelm parents: 
68148diff
changeset | 106 | val context = | 
| 
da70c9e91135
clarified signature: more explicit type "context" with full options;
 wenzelm parents: 
68148diff
changeset | 107 |       {options = options, symbols = symbols, bibtex_entries = bibtex_entries,
 | 
| 
da70c9e91135
clarified signature: more explicit type "context" with full options;
 wenzelm parents: 
68148diff
changeset | 108 | last_timing = last_timing}; | 
| 59366 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 109 | val condition = space_explode "," (Options.string options "condition"); | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 110 | val conds = filter_out (can getenv_strict) condition; | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 111 | in | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 112 | if null conds then | 
| 69755 | 113 | (Options.set_default options; | 
| 62714 | 114 | Isabelle_Process.init_options (); | 
| 64599 
80ef54198f44
dummy fork to produce ML_statistics even in sequential mode (e.g. for heap size);
 wenzelm parents: 
64308diff
changeset | 115 | Future.fork I; | 
| 68179 
da70c9e91135
clarified signature: more explicit type "context" with full options;
 wenzelm parents: 
68148diff
changeset | 116 | (Thy_Info.use_theories context qualifier master_dir | 
| 64308 | 117 | |> | 
| 118 | (case Options.string options "profiling" of | |
| 119 | "" => I | |
| 120 | | "time" => profile_time | |
| 121 | | "allocations" => profile_allocations | |
| 122 |           | bad => error ("Bad profiling option: " ^ quote bad))
 | |
| 59366 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 123 | |> Unsynchronized.setmp print_mode | 
| 62714 | 124 | (space_explode "," (Options.string options "print_mode") @ print_mode_value ())) thys) | 
| 59366 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 125 | else | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 126 |       Output.physical_stderr ("Skipping theories " ^ commas_quote (map #1 thys) ^
 | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 127 | " (undefined " ^ commas conds ^ ")\n") | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 128 | end; | 
| 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 129 | |
| 65307 | 130 | |
| 131 | (* build session *) | |
| 132 | ||
| 133 | datatype args = Args of | |
| 134 |  {symbol_codes: (string * int) list,
 | |
| 135 | command_timings: Properties.T list, | |
| 136 | do_output: bool, | |
| 137 | verbose: bool, | |
| 138 | browser_info: Path.T, | |
| 139 | document_files: (Path.T * Path.T) list, | |
| 140 | graph_file: Path.T, | |
| 141 | parent_name: string, | |
| 142 | chapter: string, | |
| 143 | name: string, | |
| 144 | master_dir: Path.T, | |
| 65431 
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
 wenzelm parents: 
65318diff
changeset | 145 | theories: (Options.T * (string * Position.T) list) list, | 
| 70683 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 146 | session_positions: (string * Properties.T) list, | 
| 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 147 | session_directories: (string * string) list, | 
| 67471 | 148 | doc_names: string list, | 
| 65457 | 149 | global_theories: (string * string) list, | 
| 66712 | 150 | loaded_theories: string list, | 
| 67297 
86a099f896fc
formal check of @{cite} bibtex entries -- only in batch-mode session builds;
 wenzelm parents: 
67219diff
changeset | 151 | bibtex_entries: string list}; | 
| 65307 | 152 | |
| 153 | fun decode_args yxml = | |
| 62630 | 154 | let | 
| 65307 | 155 | open XML.Decode; | 
| 65517 | 156 | val position = Position.of_properties o properties; | 
| 62630 | 157 | val (symbol_codes, (command_timings, (do_output, (verbose, (browser_info, | 
| 65431 
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
 wenzelm parents: 
65318diff
changeset | 158 | (document_files, (graph_file, (parent_name, (chapter, (name, (master_dir, | 
| 70683 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 159 | (theories, (session_positions, (session_directories, (doc_names, (global_theories, | 
| 70712 
a3cfe859d915
find theories via session directories only -- ignore known_theories;
 wenzelm parents: 
70683diff
changeset | 160 | (loaded_theories, bibtex_entries))))))))))))))))) = | 
| 65307 | 161 | pair (list (pair string int)) (pair (list properties) (pair bool (pair bool (pair string | 
| 162 | (pair (list (pair string string)) (pair string (pair string (pair string (pair string | |
| 65431 
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
 wenzelm parents: 
65318diff
changeset | 163 | (pair string | 
| 65517 | 164 | (pair (((list (pair Options.decode (list (pair string position)))))) | 
| 70683 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 165 | (pair (list (pair string properties)) | 
| 67493 
c4e9e0c50487
treat sessions as entities with defining position;
 wenzelm parents: 
67471diff
changeset | 166 | (pair (list (pair string string)) (pair (list string) | 
| 70712 
a3cfe859d915
find theories via session directories only -- ignore known_theories;
 wenzelm parents: 
70683diff
changeset | 167 | (pair (list (pair string string)) (pair (list string) (list string))))))))))))))))) | 
| 65307 | 168 | (YXML.parse_body yxml); | 
| 169 | in | |
| 170 |     Args {symbol_codes = symbol_codes, command_timings = command_timings, do_output = do_output,
 | |
| 171 | verbose = verbose, browser_info = Path.explode browser_info, | |
| 172 | document_files = map (apply2 Path.explode) document_files, | |
| 173 | graph_file = Path.explode graph_file, parent_name = parent_name, chapter = chapter, | |
| 70683 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 174 | name = name, master_dir = Path.explode master_dir, theories = theories, | 
| 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 175 | session_positions = session_positions, session_directories = session_directories, | 
| 67471 | 176 | doc_names = doc_names, global_theories = global_theories, loaded_theories = loaded_theories, | 
| 70712 
a3cfe859d915
find theories via session directories only -- ignore known_theories;
 wenzelm parents: 
70683diff
changeset | 177 | bibtex_entries = bibtex_entries} | 
| 65307 | 178 | end; | 
| 48418 | 179 | |
| 65307 | 180 | fun build_session (Args {symbol_codes, command_timings, do_output, verbose, browser_info,
 | 
| 70683 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 181 | document_files, graph_file, parent_name, chapter, name, master_dir, theories, session_positions, | 
| 70712 
a3cfe859d915
find theories via session directories only -- ignore known_theories;
 wenzelm parents: 
70683diff
changeset | 182 | session_directories, doc_names, global_theories, loaded_theories, bibtex_entries}) = | 
| 65307 | 183 | let | 
| 62630 | 184 | val symbols = HTML.make_symbols symbol_codes; | 
| 51941 
ead4248aef3b
full default options for Isabelle_Process and Build;
 wenzelm parents: 
51666diff
changeset | 185 | |
| 65441 | 186 | val _ = | 
| 65478 
7c40477e0a87
clarified init_session_base / finish_session_base: retain some information for plain "isabelle process", without rechecking dependencies as in "isabelle console";
 wenzelm parents: 
65457diff
changeset | 187 | Resources.init_session_base | 
| 70683 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 188 |         {session_positions = session_positions,
 | 
| 
8c7706b053c7
find theory files via session structure: much faster Prover IDE startup;
 wenzelm parents: 
69755diff
changeset | 189 | session_directories = session_directories, | 
| 67493 
c4e9e0c50487
treat sessions as entities with defining position;
 wenzelm parents: 
67471diff
changeset | 190 | docs = doc_names, | 
| 67219 | 191 | global_theories = global_theories, | 
| 70712 
a3cfe859d915
find theories via session directories only -- ignore known_theories;
 wenzelm parents: 
70683diff
changeset | 192 | loaded_theories = loaded_theories}; | 
| 65431 
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
 wenzelm parents: 
65318diff
changeset | 193 | |
| 62630 | 194 | val _ = | 
| 195 | Session.init | |
| 196 | symbols | |
| 197 | do_output | |
| 198 | (Options.default_bool "browser_info") | |
| 65307 | 199 | browser_info | 
| 62630 | 200 | (Options.default_string "document") | 
| 201 | (Options.default_string "document_output") | |
| 68511 | 202 | (Present.document_variants (Options.default ())) | 
| 65307 | 203 | document_files | 
| 204 | graph_file | |
| 205 | parent_name | |
| 206 | (chapter, name) | |
| 62630 | 207 | verbose; | 
| 49911 
262c36fd5f26
collective errors from use_thys and Session.finish/Goal.finish_futures -- avoid uninformative interrupts stemming from failure of goal forks that are not registered in the theory (e.g. unnamed theorems);
 wenzelm parents: 
49242diff
changeset | 208 | |
| 65058 
3e9f382fb67e
absent timing information means zero, according to 0070053570c4, f235646b1b73;
 wenzelm parents: 
64599diff
changeset | 209 | val last_timing = get_timings (fold update_timings command_timings empty_timings); | 
| 51218 
6425a0d3b7ac
support for build passing timings from Scala to ML;
 wenzelm parents: 
51217diff
changeset | 210 | |
| 62630 | 211 | val res1 = | 
| 212 | theories |> | |
| 67297 
86a099f896fc
formal check of @{cite} bibtex entries -- only in batch-mode session builds;
 wenzelm parents: 
67219diff
changeset | 213 | (List.app (build_theories symbols bibtex_entries last_timing name master_dir) | 
| 62630 | 214 | |> session_timing name verbose | 
| 215 | |> Exn.capture); | |
| 216 | val res2 = Exn.capture Session.finish (); | |
| 65431 
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
 wenzelm parents: 
65318diff
changeset | 217 | |
| 65478 
7c40477e0a87
clarified init_session_base / finish_session_base: retain some information for plain "isabelle process", without rechecking dependencies as in "isabelle console";
 wenzelm parents: 
65457diff
changeset | 218 | val _ = Resources.finish_session_base (); | 
| 62630 | 219 | val _ = Par_Exn.release_all [res1, res2]; | 
| 65307 | 220 | in () end; | 
| 48673 
b2b09970c571
let with_timing report overall number of threads;
 wenzelm parents: 
48672diff
changeset | 221 | |
| 65307 | 222 | (*command-line tool*) | 
| 223 | fun build args_file = | |
| 224 | let | |
| 225 | val _ = SHA1.test_samples (); | |
| 226 | val _ = Options.load_default (); | |
| 227 | val _ = Isabelle_Process.init_options (); | |
| 65936 | 228 | val args = decode_args (File.read (Path.explode args_file)); | 
| 66048 
d244a895da50
avoid markup, for the sake of Build_Log.Log_File.parse_props;
 wenzelm parents: 
65948diff
changeset | 229 |     fun error_message msg = writeln ("\ferror_message = " ^ encode_lines (YXML.content_of msg));
 | 
| 65307 | 230 | val _ = | 
| 231 | Unsynchronized.setmp Private_Output.protocol_message_fn protocol_message | |
| 65934 | 232 | build_session args | 
| 65948 | 233 | handle exn => (List.app error_message (Runtime.exn_message_list exn); Exn.reraise exn); | 
| 70907 | 234 | val _ = Private_Output.protocol_message_fn := Output.protocol_message_undefined; | 
| 62630 | 235 | val _ = Options.reset_default (); | 
| 236 | in () end; | |
| 48418 | 237 | |
| 65307 | 238 | (*PIDE version*) | 
| 239 | val _ = | |
| 240 | Isabelle_Process.protocol_command "build_session" | |
| 65313 | 241 | (fn [args_yxml] => | 
| 70991 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 242 | let | 
| 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 243 | val args = decode_args args_yxml; | 
| 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 244 | val result = (build_session args; "") handle exn => | 
| 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 245 | (Runtime.exn_message exn handle _ (*sic!*) => | 
| 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 246 | "Exception raised, but failed to print details!"); | 
| 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 247 | in Output.protocol_message Markup.build_session_finished [XML.Text result] end | 
| 
f9f7c34b7dd4
more scalable protocol_message: use XML.body directly (Output.output hook is not required);
 wenzelm parents: 
70907diff
changeset | 248 | | _ => raise Match); | 
| 59366 
e94df7f6b608
clarified build_theories: proper protocol handler;
 wenzelm parents: 
59364diff
changeset | 249 | |
| 48418 | 250 | end; |