author | wenzelm |
Tue, 19 Feb 2013 16:49:40 +0100 | |
changeset 51220 | e140c8fa485a |
parent 51218 | 6425a0d3b7ac |
child 51228 | dff3471dd8bc |
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:
48681
diff
changeset
|
9 |
val build: string -> unit |
48418 | 10 |
end; |
11 |
||
12 |
structure Build: BUILD = |
|
13 |
struct |
|
14 |
||
50683 | 15 |
(* protocol messages *) |
16 |
||
51045
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
17 |
local |
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
18 |
|
51216 | 19 |
(* FIXME avoid hardwired stuff!? *) |
20 |
val protocol_echo = [Markup.ML_statistics, Markup.task_statistics, Markup.command_timing]; |
|
50683 | 21 |
|
51216 | 22 |
fun protocol_undef () = raise Fail "Undefined Output.protocol_message"; |
51045
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
23 |
|
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
24 |
in |
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
25 |
|
50683 | 26 |
fun protocol_message props output = |
51216 | 27 |
(case props of |
28 |
function :: args => |
|
29 |
if member (op =) protocol_echo function then |
|
30 |
writeln ("\f" ^ #2 function ^ " = " ^ YXML.string_of_body (XML.Encode.properties args)) |
|
31 |
else |
|
32 |
(case Markup.dest_loading_theory props of |
|
33 |
SOME name => writeln ("\floading_theory = " ^ name) |
|
34 |
| NONE => protocol_undef ()) |
|
35 |
| [] => protocol_undef ()); |
|
50683 | 36 |
|
51045
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
37 |
end; |
630c0895d9d1
more efficient inlined properties, especially relevant for voluminous tasks trace;
wenzelm
parents:
50982
diff
changeset
|
38 |
|
50683 | 39 |
|
40 |
(* build *) |
|
41 |
||
48465 | 42 |
local |
43 |
||
48500 | 44 |
fun no_document options = |
50121
97d2b77313a0
isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
wenzelm
parents:
49911
diff
changeset
|
45 |
(case Options.string options "document" of "" => true | "false" => true | _ => false); |
48500 | 46 |
|
51217
65ab2c4f4c32
support for prescient timing information within command transactions;
wenzelm
parents:
51216
diff
changeset
|
47 |
fun use_theories last_timing options = |
65ab2c4f4c32
support for prescient timing information within command transactions;
wenzelm
parents:
51216
diff
changeset
|
48 |
Thy_Info.use_theories {last_timing = last_timing, master_dir = Path.current} |
48457 | 49 |
|> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs") |
50 |
|> Unsynchronized.setmp print_mode |
|
51 |
(space_explode "," (Options.string options "print_mode") @ print_mode_value ()) |
|
52 |
|> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs") |
|
53 |
|> Unsynchronized.setmp Goal.parallel_proofs_threshold |
|
54 |
(Options.int options "parallel_proofs_threshold") |
|
55 |
|> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace") |
|
48460 | 56 |
|> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads") |
50698
49621c755075
always enable Future.ML_statistics where this makes sense -- runtime overhead should be negligible;
wenzelm
parents:
50686
diff
changeset
|
57 |
|> Unsynchronized.setmp Future.ML_statistics true |
48500 | 58 |
|> no_document options ? Present.no_document |
48486 | 59 |
|> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty") |
48634 | 60 |
|> Unsynchronized.setmp Toplevel.skip_proofs (Options.bool options "skip_proofs") |
48486 | 61 |
|> Unsynchronized.setmp Printer.show_question_marks_default |
62 |
(Options.bool options "show_question_marks") |
|
63 |
|> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long") |
|
64 |
|> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short") |
|
48492 | 65 |
|> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique") |
48520 | 66 |
|> Unsynchronized.setmp Thy_Output.display_default (Options.bool options "thy_output_display") |
67 |
|> Unsynchronized.setmp Thy_Output.quotes_default (Options.bool options "thy_output_quotes") |
|
68 |
|> Unsynchronized.setmp Thy_Output.indent_default (Options.int options "thy_output_indent") |
|
69 |
|> Unsynchronized.setmp Thy_Output.source_default (Options.bool options "thy_output_source") |
|
70 |
|> Unsynchronized.setmp Thy_Output.break_default (Options.bool options "thy_output_break") |
|
48527 | 71 |
|> Unsynchronized.setmp Pretty.margin_default (Options.int options "pretty_margin") |
48492 | 72 |
|> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing"); |
48457 | 73 |
|
51217
65ab2c4f4c32
support for prescient timing information within command transactions;
wenzelm
parents:
51216
diff
changeset
|
74 |
fun use_theories_condition last_timing (options, thys) = |
48465 | 75 |
let val condition = space_explode "," (Options.string options "condition") in |
76 |
(case filter_out (can getenv_strict) condition of |
|
51217
65ab2c4f4c32
support for prescient timing information within command transactions;
wenzelm
parents:
51216
diff
changeset
|
77 |
[] => use_theories last_timing options (map (rpair Position.none) thys) |
48465 | 78 |
| conds => |
48512 | 79 |
Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^ |
48477 | 80 |
" (undefined " ^ commas conds ^ ")\n")) |
48465 | 81 |
end; |
82 |
||
51218
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
83 |
structure Timings = |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
84 |
Table(type key = Properties.T val ord = dict_ord (prod_ord fast_string_ord fast_string_ord)); |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
85 |
|
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
86 |
fun make_timing props = |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
87 |
let val (t, id) = List.partition (member (op =) Markup.timing_propertiesN o fst) props |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
88 |
in (id, Markup.parse_timing_properties t) end; |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
89 |
|
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
90 |
fun make_timings timings = fold (Timings.update o make_timing) timings Timings.empty; |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
91 |
|
48465 | 92 |
in |
93 |
||
48681
181b91e1d1c1
prefer general Command_Line.tool wrapper (cf. Scala version);
wenzelm
parents:
48673
diff
changeset
|
94 |
fun build args_file = Command_Line.tool (fn () => |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
95 |
let |
51220 | 96 |
val (command_timings, (do_output, (options, (verbose, (browser_info, |
51218
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
97 |
(parent_name, (name, theories))))))) = |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
98 |
File.read (Path.explode args_file) |> YXML.parse_body |> |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
99 |
let open XML.Decode in |
51218
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
100 |
pair (list properties) (pair bool (pair Options.decode (pair bool (pair string |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
101 |
(pair string (pair string ((list (pair Options.decode (list string)))))))))) |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
102 |
end; |
48418 | 103 |
|
48804
6348e5fca42e
more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents:
48734
diff
changeset
|
104 |
val document_variants = |
6348e5fca42e
more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents:
48734
diff
changeset
|
105 |
map Present.read_variant (space_explode ":" (Options.string options "document_variants")); |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
106 |
val _ = |
48805
c3ea910b3581
explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents:
48804
diff
changeset
|
107 |
(case duplicates (op =) (map fst document_variants) of |
c3ea910b3581
explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents:
48804
diff
changeset
|
108 |
[] => () |
c3ea910b3581
explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents:
48804
diff
changeset
|
109 |
| dups => error ("Duplicate document variants: " ^ commas_quote dups)); |
49242 | 110 |
|
50982 | 111 |
val _ = writeln ("\fSession.name = " ^ name); |
49242 | 112 |
val _ = |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
113 |
(case Session.path () of |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
114 |
[] => () |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
115 |
| path => writeln ("\fSession.parent_path = " ^ space_implode "/" path)); |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
116 |
val _ = |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
117 |
Session.init do_output false |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
118 |
(Options.bool options "browser_info") browser_info |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
119 |
(Options.string options "document") |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
120 |
(Options.bool options "document_graph") |
48805
c3ea910b3581
explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents:
48804
diff
changeset
|
121 |
(Options.string options "document_output") |
48804
6348e5fca42e
more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents:
48734
diff
changeset
|
122 |
document_variants |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
123 |
parent_name name |
50121
97d2b77313a0
isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
wenzelm
parents:
49911
diff
changeset
|
124 |
(false, "") "" |
97d2b77313a0
isabelle build no longer supports document_dump/document_dump_mode (no INCOMPATIBILITY, since it was never in official release);
wenzelm
parents:
49911
diff
changeset
|
125 |
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:
49242
diff
changeset
|
126 |
|
51218
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
127 |
val last_timing = |
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
128 |
the_default Timing.zero o |
51220 | 129 |
Timings.lookup (make_timings command_timings) o Toplevel.approximative_id; |
51218
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
130 |
|
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:
49242
diff
changeset
|
131 |
val res1 = |
48673
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
132 |
theories |> |
51218
6425a0d3b7ac
support for build passing timings from Scala to ML;
wenzelm
parents:
51217
diff
changeset
|
133 |
(List.app (use_theories_condition last_timing) |
48673
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
134 |
|> Session.with_timing name verbose |
50683 | 135 |
|> Unsynchronized.setmp Output.Private_Hooks.protocol_message_fn protocol_message |
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:
49242
diff
changeset
|
136 |
|> Unsynchronized.setmp Multithreading.max_threads (Options.int options "threads") |
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:
49242
diff
changeset
|
137 |
|> Exn.capture); |
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:
49242
diff
changeset
|
138 |
val res2 = Exn.capture Session.finish (); |
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:
49242
diff
changeset
|
139 |
val _ = Par_Exn.release_all [res1, res2]; |
48673
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
140 |
|
48734
af91cd2301ba
back to implicit commit via isabelle-process -- save image only once (cf. 181b91e1d1c1);
wenzelm
parents:
48731
diff
changeset
|
141 |
val _ = if do_output then () else exit 0; |
48681
181b91e1d1c1
prefer general Command_Line.tool wrapper (cf. Scala version);
wenzelm
parents:
48673
diff
changeset
|
142 |
in 0 end); |
48418 | 143 |
|
144 |
end; |
|
48465 | 145 |
|
146 |
end; |