author | wenzelm |
Fri, 18 Jan 2013 17:51:50 +0100 | |
changeset 50975 | 73ec6ad6700e |
parent 50845 | 477ca927676f |
child 50982 | a7aa17a1f721 |
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 |
||
17 |
fun ML_statistics (function :: stats) "" = |
|
18 |
if function = Markup.ML_statistics then SOME stats |
|
19 |
else NONE |
|
20 |
| ML_statistics _ _ = NONE; |
|
21 |
||
50975 | 22 |
fun task_statistics (function :: stats) "" = |
23 |
if function = Markup.task_statistics then SOME stats |
|
24 |
else NONE |
|
25 |
| task_statistics _ _ = NONE; |
|
26 |
||
50683 | 27 |
fun protocol_message props output = |
28 |
(case ML_statistics props output of |
|
50777 | 29 |
SOME stats => writeln ("\fML_statistics = " ^ ML_Syntax.print_properties stats) |
50845 | 30 |
| NONE => |
50975 | 31 |
(case task_statistics props output of |
32 |
SOME stats => writeln ("\ftask_statistics = " ^ ML_Syntax.print_properties stats) |
|
33 |
| NONE => |
|
34 |
(case Markup.dest_loading_theory props of |
|
35 |
SOME name => writeln ("\floading_theory = " ^ name) |
|
36 |
| NONE => raise Fail "Undefined Output.protocol_message"))); |
|
50683 | 37 |
|
38 |
||
39 |
(* build *) |
|
40 |
||
48465 | 41 |
local |
42 |
||
48500 | 43 |
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
|
44 |
(case Options.string options "document" of "" => true | "false" => true | _ => false); |
48500 | 45 |
|
48465 | 46 |
fun use_thys options = |
48457 | 47 |
Thy_Info.use_thys |
48 |
|> Unsynchronized.setmp Proofterm.proofs (Options.int options "proofs") |
|
49 |
|> Unsynchronized.setmp print_mode |
|
50 |
(space_explode "," (Options.string options "print_mode") @ print_mode_value ()) |
|
51 |
|> Unsynchronized.setmp Goal.parallel_proofs (Options.int options "parallel_proofs") |
|
52 |
|> Unsynchronized.setmp Goal.parallel_proofs_threshold |
|
53 |
(Options.int options "parallel_proofs_threshold") |
|
54 |
|> Unsynchronized.setmp Multithreading.trace (Options.int options "threads_trace") |
|
48460 | 55 |
|> 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
|
56 |
|> Unsynchronized.setmp Future.ML_statistics true |
48500 | 57 |
|> no_document options ? Present.no_document |
48486 | 58 |
|> Unsynchronized.setmp quick_and_dirty (Options.bool options "quick_and_dirty") |
48634 | 59 |
|> Unsynchronized.setmp Toplevel.skip_proofs (Options.bool options "skip_proofs") |
48486 | 60 |
|> Unsynchronized.setmp Printer.show_question_marks_default |
61 |
(Options.bool options "show_question_marks") |
|
62 |
|> Unsynchronized.setmp Name_Space.names_long_default (Options.bool options "names_long") |
|
63 |
|> Unsynchronized.setmp Name_Space.names_short_default (Options.bool options "names_short") |
|
48492 | 64 |
|> Unsynchronized.setmp Name_Space.names_unique_default (Options.bool options "names_unique") |
48520 | 65 |
|> Unsynchronized.setmp Thy_Output.display_default (Options.bool options "thy_output_display") |
66 |
|> Unsynchronized.setmp Thy_Output.quotes_default (Options.bool options "thy_output_quotes") |
|
67 |
|> Unsynchronized.setmp Thy_Output.indent_default (Options.int options "thy_output_indent") |
|
68 |
|> Unsynchronized.setmp Thy_Output.source_default (Options.bool options "thy_output_source") |
|
69 |
|> Unsynchronized.setmp Thy_Output.break_default (Options.bool options "thy_output_break") |
|
48527 | 70 |
|> Unsynchronized.setmp Pretty.margin_default (Options.int options "pretty_margin") |
48492 | 71 |
|> Unsynchronized.setmp Toplevel.timing (Options.bool options "timing"); |
48457 | 72 |
|
48465 | 73 |
fun use_theories (options, thys) = |
74 |
let val condition = space_explode "," (Options.string options "condition") in |
|
75 |
(case filter_out (can getenv_strict) condition of |
|
48927
ef462b5558eb
theory def/ref position reports, which enable hyperlinks etc.;
wenzelm
parents:
48805
diff
changeset
|
76 |
[] => use_thys options (map (rpair Position.none) thys) |
48465 | 77 |
| conds => |
48512 | 78 |
Output.physical_stderr ("Skipping theories " ^ commas_quote thys ^ |
48477 | 79 |
" (undefined " ^ commas conds ^ ")\n")) |
48465 | 80 |
end; |
81 |
||
82 |
in |
|
83 |
||
48681
181b91e1d1c1
prefer general Command_Line.tool wrapper (cf. Scala version);
wenzelm
parents:
48673
diff
changeset
|
84 |
fun build args_file = Command_Line.tool (fn () => |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
85 |
let |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
86 |
val (do_output, (options, (verbose, (browser_info, (parent_name, |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
87 |
(name, theories)))))) = |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
88 |
File.read (Path.explode args_file) |> YXML.parse_body |> |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
89 |
let open XML.Decode in |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
90 |
pair bool (pair Options.decode (pair bool (pair string (pair string |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
91 |
(pair string ((list (pair Options.decode (list string))))))))) |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
92 |
end; |
48418 | 93 |
|
48804
6348e5fca42e
more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents:
48734
diff
changeset
|
94 |
val document_variants = |
6348e5fca42e
more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents:
48734
diff
changeset
|
95 |
map Present.read_variant (space_explode ":" (Options.string options "document_variants")); |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
96 |
val _ = |
48805
c3ea910b3581
explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents:
48804
diff
changeset
|
97 |
(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
|
98 |
[] => () |
c3ea910b3581
explicit document_output directory, without implicit purge of default in ISABELLE_BROWSER_INFO;
wenzelm
parents:
48804
diff
changeset
|
99 |
| dups => error ("Duplicate document variants: " ^ commas_quote dups)); |
49242 | 100 |
|
101 |
val _ = |
|
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
102 |
(case Session.path () of |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
103 |
[] => () |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
104 |
| path => writeln ("\fSession.parent_path = " ^ space_implode "/" path)); |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50698
diff
changeset
|
105 |
val _ = |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
106 |
Session.init do_output false |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
107 |
(Options.bool options "browser_info") browser_info |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
108 |
(Options.string options "document") |
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
109 |
(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
|
110 |
(Options.string options "document_output") |
48804
6348e5fca42e
more direct interpretation of document_variants for build (unchanged for usedir);
wenzelm
parents:
48734
diff
changeset
|
111 |
document_variants |
48672
9bc7922ba2ae
further robustification of interrupts during build;
wenzelm
parents:
48662
diff
changeset
|
112 |
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
|
113 |
(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
|
114 |
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
|
115 |
|
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
|
116 |
val res1 = |
48673
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
117 |
theories |> |
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
118 |
(List.app use_theories |
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
119 |
|> Session.with_timing name verbose |
50683 | 120 |
|> 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
|
121 |
|> 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
|
122 |
|> 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
|
123 |
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
|
124 |
val _ = Par_Exn.release_all [res1, res2]; |
48673
b2b09970c571
let with_timing report overall number of threads;
wenzelm
parents:
48672
diff
changeset
|
125 |
|
48734
af91cd2301ba
back to implicit commit via isabelle-process -- save image only once (cf. 181b91e1d1c1);
wenzelm
parents:
48731
diff
changeset
|
126 |
val _ = if do_output then () else exit 0; |
48681
181b91e1d1c1
prefer general Command_Line.tool wrapper (cf. Scala version);
wenzelm
parents:
48673
diff
changeset
|
127 |
in 0 end); |
48418 | 128 |
|
129 |
end; |
|
48465 | 130 |
|
131 |
end; |