| author | wenzelm |
| Fri, 29 Jun 2018 22:50:35 +0200 | |
| changeset 68548 | a22540ac7052 |
| parent 68487 | 3d710aa23846 |
| child 68731 | c2dcb7f7a3ef |
| permissions | -rw-r--r-- |
| 50686 | 1 |
/* Title: Pure/Tools/build.scala |
| 48276 | 2 |
Author: Makarius |
| 57923 | 3 |
Options: :folding=explicit: |
| 48276 | 4 |
|
5 |
Build and manage Isabelle sessions. |
|
6 |
*/ |
|
7 |
||
8 |
package isabelle |
|
9 |
||
10 |
||
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
11 |
import scala.collection.SortedSet |
|
48340
6f4fc030882a
allow explicit specification of additional session directories;
wenzelm
parents:
48339
diff
changeset
|
12 |
import scala.annotation.tailrec |
|
48337
9c7f8e5805b4
cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents:
48336
diff
changeset
|
13 |
|
| 48335 | 14 |
|
| 48276 | 15 |
object Build |
16 |
{
|
|
| 62631 | 17 |
/** auxiliary **/ |
| 48424 | 18 |
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
19 |
/* persistent build info */ |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
20 |
|
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
21 |
sealed case class Session_Info( |
|
66749
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
22 |
sources: String, |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
23 |
input_heaps: List[String], |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
24 |
output_heap: Option[String], |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
25 |
return_code: Int) |
| 66747 | 26 |
{
|
27 |
def ok: Boolean = return_code == 0 |
|
28 |
} |
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
29 |
|
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
30 |
|
| 65289 | 31 |
/* queue with scheduling information */ |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
32 |
|
| 62631 | 33 |
private object Queue |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
34 |
{
|
|
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
35 |
type Timings = (List[Properties.T], Double) |
|
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
36 |
|
|
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
37 |
def load_timings(progress: Progress, store: Sessions.Store, name: String): Timings = |
| 65289 | 38 |
{
|
|
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
39 |
val no_timings: Timings = (Nil, 0.0) |
| 65289 | 40 |
|
| 68221 | 41 |
store.access_database(name) match {
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
42 |
case None => no_timings |
| 68214 | 43 |
case Some(db) => |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
44 |
def ignore_error(msg: String) = |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
45 |
{
|
| 68214 | 46 |
progress.echo_warning("Ignoring bad database " + db + (if (msg == "") "" else "\n" + msg))
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
47 |
no_timings |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
48 |
} |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
49 |
try {
|
| 68214 | 50 |
val command_timings = store.read_command_timings(db, name) |
51 |
val session_timing = |
|
52 |
store.read_session_timing(db, name) match {
|
|
53 |
case Markup.Elapsed(t) => t |
|
54 |
case _ => 0.0 |
|
55 |
} |
|
56 |
(command_timings, session_timing) |
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
57 |
} |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
58 |
catch {
|
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
59 |
case ERROR(msg) => ignore_error(msg) |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
60 |
case exn: java.lang.Error => ignore_error(Exn.message(exn)) |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
61 |
case _: XML.Error => ignore_error("")
|
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
62 |
} |
| 68214 | 63 |
finally { db.close }
|
| 65289 | 64 |
} |
65 |
} |
|
66 |
||
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
67 |
def make_session_timing(sessions: Sessions.Structure, timing: Map[String, Double]) |
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
68 |
: Map[String, Double] = |
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
69 |
{
|
| 68487 | 70 |
val maximals = sessions.build_graph.maximals.toSet |
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
71 |
def desc_timing(name: String): Double = |
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
72 |
{
|
| 68487 | 73 |
if (maximals.contains(name)) timing(name) |
74 |
else {
|
|
75 |
val g = sessions.build_graph.restrict(sessions.build_descendants(List(name)).toSet) |
|
76 |
(0.0 :: g.maximals.flatMap(desc => {
|
|
77 |
val ps = g.all_preds(List(desc)) |
|
78 |
if (ps.exists(p => timing.get(p).isEmpty)) None |
|
79 |
else Some(ps.map(timing(_)).sum) |
|
80 |
})).max |
|
81 |
} |
|
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
82 |
} |
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
83 |
timing.keySet.iterator.map(name => (name -> desc_timing(name))).toMap.withDefaultValue(0.0) |
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
84 |
} |
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
85 |
|
| 67052 | 86 |
def apply(progress: Progress, sessions: Sessions.Structure, store: Sessions.Store): Queue = |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
87 |
{
|
|
65420
695d4e22345a
support for static session imports, without affect build hierarchy;
wenzelm
parents:
65419
diff
changeset
|
88 |
val graph = sessions.build_graph |
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
89 |
val names = graph.keys |
| 51220 | 90 |
|
| 65831 | 91 |
val timings = names.map(name => (name, load_timings(progress, store, name))) |
| 51220 | 92 |
val command_timings = |
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
93 |
timings.map({ case (name, (ts, _)) => (name, ts) }).toMap.withDefaultValue(Nil)
|
| 51220 | 94 |
val session_timing = |
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
95 |
make_session_timing(sessions, timings.map({ case (name, (_, t)) => (name, t) }).toMap)
|
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
96 |
|
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
97 |
object Ordering extends scala.math.Ordering[String] |
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
98 |
{
|
|
51227
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
99 |
def compare_timing(name1: String, name2: String): Int = |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
100 |
{
|
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
101 |
val t1 = session_timing(name1) |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
102 |
val t2 = session_timing(name2) |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
103 |
if (t1 == 0.0 || t2 == 0.0) 0 |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
104 |
else t1 compare t2 |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
105 |
} |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
106 |
|
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
107 |
def compare(name1: String, name2: String): Int = |
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
108 |
compare_timing(name2, name1) match {
|
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
109 |
case 0 => |
|
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
110 |
sessions(name2).timeout compare sessions(name1).timeout match {
|
|
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
111 |
case 0 => name1 compare name2 |
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
112 |
case ord => ord |
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
113 |
} |
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
114 |
case ord => ord |
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
115 |
} |
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
116 |
} |
|
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
117 |
|
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
118 |
new Queue(graph, SortedSet(names: _*)(Ordering), command_timings) |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
119 |
} |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
120 |
} |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
121 |
|
| 65314 | 122 |
private class Queue( |
| 62631 | 123 |
graph: Graph[String, Sessions.Info], |
| 51220 | 124 |
order: SortedSet[String], |
125 |
val command_timings: String => List[Properties.T]) |
|
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
126 |
{
|
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
127 |
def is_inner(name: String): Boolean = !graph.is_maximal(name) |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
128 |
|
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
129 |
def is_empty: Boolean = graph.is_empty |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
130 |
|
|
51227
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
131 |
def - (name: String): Queue = |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
132 |
new Queue(graph.del_node(name), |
| 67011 | 133 |
order - name, // FIXME scala-2.10.0 .. 2.12.4 TreeSet problem!? |
|
51227
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
134 |
command_timings) |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
135 |
|
| 62631 | 136 |
def dequeue(skip: String => Boolean): Option[(String, Sessions.Info)] = |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
137 |
{
|
|
51227
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
138 |
val it = order.iterator.dropWhile(name => |
|
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
139 |
skip(name) |
| 67011 | 140 |
|| !graph.defined(name) // FIXME scala-2.10.0 .. 2.12.4 TreeSet problem!? |
|
51227
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
141 |
|| !graph.is_minimal(name)) |
| 48680 | 142 |
if (it.hasNext) { val name = it.next; Some((name, graph.get_node(name))) }
|
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
143 |
else None |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
144 |
} |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
145 |
} |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
146 |
|
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
147 |
|
| 65313 | 148 |
/* PIDE protocol handler */ |
149 |
||
150 |
class Handler(progress: Progress, session: Session, session_name: String) |
|
151 |
extends Session.Protocol_Handler |
|
152 |
{
|
|
153 |
val result_error: Promise[String] = Future.promise |
|
154 |
||
155 |
override def exit() { result_error.cancel }
|
|
156 |
||
157 |
private def build_session_finished(msg: Prover.Protocol_Output): Boolean = |
|
158 |
{
|
|
159 |
val error_message = |
|
|
65344
b99283eed13c
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65320
diff
changeset
|
160 |
try { Pretty.string_of(Symbol.decode_yxml(msg.text)) }
|
| 65313 | 161 |
catch { case ERROR(msg) => msg }
|
162 |
result_error.fulfill(error_message) |
|
163 |
session.send_stop() |
|
164 |
true |
|
165 |
} |
|
166 |
||
167 |
private def loading_theory(msg: Prover.Protocol_Output): Boolean = |
|
168 |
msg.properties match {
|
|
169 |
case Markup.Loading_Theory(name) => |
|
170 |
progress.theory(session_name, name) |
|
171 |
true |
|
172 |
case _ => false |
|
173 |
} |
|
174 |
||
175 |
val functions = |
|
176 |
List( |
|
177 |
Markup.BUILD_SESSION_FINISHED -> build_session_finished _, |
|
178 |
Markup.LOADING_THEORY -> loading_theory _) |
|
179 |
} |
|
180 |
||
181 |
||
| 65308 | 182 |
/* job: running prover process */ |
| 48341 | 183 |
|
| 65308 | 184 |
private class Job(progress: Progress, |
185 |
name: String, |
|
186 |
val info: Sessions.Info, |
|
| 65313 | 187 |
deps: Sessions.Deps, |
| 65308 | 188 |
store: Sessions.Store, |
189 |
do_output: Boolean, |
|
190 |
verbose: Boolean, |
|
191 |
pide: Boolean, |
|
192 |
val numa_node: Option[Int], |
|
193 |
command_timings: List[Properties.T]) |
|
| 48418 | 194 |
{
|
| 65312 | 195 |
val options = |
196 |
numa_node match {
|
|
197 |
case None => info.options |
|
198 |
case Some(n) => info.options.string("ML_process_policy") = NUMA.policy(n)
|
|
199 |
} |
|
200 |
||
| 59445 | 201 |
private val graph_file = Isabelle_System.tmp_file("session_graph", "pdf")
|
| 66822 | 202 |
isabelle.graphview.Graph_File.write(options, graph_file, deps(name).session_graph_display) |
| 59445 | 203 |
|
|
68198
6710167e17af
avoid race condition wrt. ISABELLE_TMP, which is removed in Bash.cleanup() before Bash.result(progress_stdout);
wenzelm
parents:
68148
diff
changeset
|
204 |
private val export_tmp_dir = Isabelle_System.tmp_dir("export")
|
| 68289 | 205 |
private val export_consumer = |
206 |
Export.consumer(store.open_database(name, output = true), cache = store.xz_cache) |
|
|
68092
888d35a19866
store exports in session database, with asynchronous / parallel compression;
wenzelm
parents:
68088
diff
changeset
|
207 |
|
| 62573 | 208 |
private val future_result: Future[Process_Result] = |
|
61559
313eca3fa847
more direct task future implementation, with proper cancel operation;
wenzelm
parents:
61556
diff
changeset
|
209 |
Future.thread("build") {
|
| 65308 | 210 |
val parent = info.parent.getOrElse("")
|
| 65441 | 211 |
val base = deps(name) |
| 65308 | 212 |
val args_yxml = |
213 |
YXML.string_of_body( |
|
|
62944
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
214 |
{
|
|
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
215 |
import XML.Encode._ |
|
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
216 |
pair(list(pair(string, int)), pair(list(properties), pair(bool, pair(bool, |
|
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
217 |
pair(Path.encode, pair(list(pair(Path.encode, Path.encode)), pair(string, |
| 65307 | 218 |
pair(string, pair(string, pair(string, pair(Path.encode, |
| 65517 | 219 |
pair(list(pair(Options.encode, list(pair(string, properties)))), |
|
67493
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
220 |
pair(list(pair(string, properties)), pair(list(string), |
|
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
221 |
pair(list(pair(string, string)), |
| 67471 | 222 |
pair(list(string), pair(list(pair(string, string)), list(string))))))))))))))))))( |
|
62944
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
223 |
(Symbol.codes, (command_timings, (do_output, (verbose, |
|
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
224 |
(store.browser_info, (info.document_files, (File.standard_path(graph_file), |
| 65307 | 225 |
(parent, (info.chapter, (name, (Path.current, |
| 67471 | 226 |
(info.theories, (base.known.sessions.toList, (base.doc_names, |
227 |
(base.global_theories.toList, (base.loaded_theories.keys, (base.dest_known_theories, |
|
228 |
info.bibtex_entries.map(_.info))))))))))))))))))) |
|
| 65308 | 229 |
}) |
230 |
||
231 |
val env = |
|
232 |
Isabelle_System.settings() + |
|
|
68198
6710167e17af
avoid race condition wrt. ISABELLE_TMP, which is removed in Bash.cleanup() before Bash.result(progress_stdout);
wenzelm
parents:
68148
diff
changeset
|
233 |
("ISABELLE_EXPORT_TMP" -> File.standard_path(export_tmp_dir)) +
|
| 65312 | 234 |
("ISABELLE_ML_DEBUGGER" -> options.bool("ML_debugger").toString)
|
| 65308 | 235 |
|
236 |
def save_heap: String = |
|
|
66972
f65fc869e835
no heap sharing for empty session (e.g. HOL-ODE);
wenzelm
parents:
66968
diff
changeset
|
237 |
(if (info.theories.isEmpty) "" else "ML_Heap.share_common_data (); ") + |
| 68217 | 238 |
"ML_Heap.save_child " + |
239 |
ML_Syntax.print_string_bytes(File.platform_path(store.output_heap(name))) |
|
|
62944
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
240 |
|
| 65360 | 241 |
if (pide && !Sessions.is_pure(name)) {
|
| 65532 | 242 |
val resources = new Resources(deps(parent)) |
| 65313 | 243 |
val session = new Session(options, resources) |
244 |
val handler = new Handler(progress, session, name) |
|
| 65315 | 245 |
session.init_protocol_handler(handler) |
| 65313 | 246 |
|
| 65317 | 247 |
val session_result = Future.promise[Process_Result] |
| 65313 | 248 |
|
| 68204 | 249 |
Isabelle_Process.start(session, options, logic = parent, cwd = info.dir.file, env = env, |
| 68209 | 250 |
sessions_structure = Some(deps.sessions_structure), store = Some(store), |
| 65313 | 251 |
phase_changed = |
252 |
{
|
|
253 |
case Session.Ready => session.protocol_command("build_session", args_yxml)
|
|
| 65317 | 254 |
case Session.Terminated(result) => session_result.fulfill(result) |
| 65313 | 255 |
case _ => |
256 |
}) |
|
257 |
||
| 65317 | 258 |
val result = session_result.join |
| 65313 | 259 |
handler.result_error.join match {
|
| 65317 | 260 |
case "" => result |
261 |
case msg => |
|
262 |
result.copy( |
|
263 |
rc = result.rc max 1, |
|
| 65828 | 264 |
out_lines = result.out_lines ::: split_lines(Output.error_message_text(msg))) |
| 65313 | 265 |
} |
| 65308 | 266 |
} |
267 |
else {
|
|
268 |
val args_file = Isabelle_System.tmp_file("build")
|
|
269 |
File.write(args_file, args_yxml) |
|
270 |
||
271 |
val eval = |
|
272 |
"Command_Line.tool0 (fn () => (" +
|
|
| 66782 | 273 |
"Build.build " + ML_Syntax.print_string_bytes(File.standard_path(args_file)) + |
| 67380 | 274 |
(if (Sessions.is_pure(name)) "; Theory.install_pure (Thy_Info.get_theory Context.PureN)" |
275 |
else "") + (if (do_output) "; " + save_heap else "") + "));" |
|
| 64265 | 276 |
|
| 65308 | 277 |
val process = |
| 65360 | 278 |
if (Sessions.is_pure(name)) {
|
| 65312 | 279 |
ML_Process(options, raw_ml_system = true, cwd = info.dir.file, |
| 65308 | 280 |
args = |
281 |
(for ((root, _) <- Thy_Header.ml_roots) yield List("--use", root)).flatten :::
|
|
282 |
List("--eval", eval),
|
|
| 68209 | 283 |
env = env, sessions_structure = Some(deps.sessions_structure), store = Some(store), |
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
284 |
cleanup = () => args_file.delete) |
| 65308 | 285 |
} |
286 |
else {
|
|
| 65312 | 287 |
ML_Process(options, parent, List("--eval", eval), cwd = info.dir.file,
|
| 68209 | 288 |
env = env, sessions_structure = Some(deps.sessions_structure), store = Some(store), |
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
289 |
cleanup = () => args_file.delete) |
| 65308 | 290 |
} |
| 64265 | 291 |
|
| 65308 | 292 |
process.result( |
293 |
progress_stdout = (line: String) => |
|
294 |
Library.try_unprefix("\floading_theory = ", line) match {
|
|
295 |
case Some(theory) => progress.theory(name, theory) |
|
296 |
case None => |
|
| 68088 | 297 |
for {
|
298 |
text <- Library.try_unprefix("\fexport = ", line)
|
|
| 68148 | 299 |
(args, path) <- |
| 68088 | 300 |
Markup.Export.dest_inline(XML.Decode.properties(YXML.parse_body(text))) |
| 68148 | 301 |
} {
|
302 |
val body = Bytes.read(path) |
|
303 |
path.file.delete |
|
304 |
export_consumer(name, args, body) |
|
305 |
} |
|
| 65308 | 306 |
}, |
307 |
progress_limit = |
|
| 65312 | 308 |
options.int("process_output_limit") match {
|
| 65308 | 309 |
case 0 => None |
310 |
case m => Some(m * 1000000L) |
|
311 |
}, |
|
312 |
strict = false) |
|
313 |
} |
|
| 50845 | 314 |
} |
| 48674 | 315 |
|
| 62572 | 316 |
def terminate: Unit = future_result.cancel |
317 |
def is_finished: Boolean = future_result.is_finished |
|
| 48674 | 318 |
|
| 56779 | 319 |
private val timeout_request: Option[Event_Timer.Request] = |
320 |
{
|
|
| 62569 | 321 |
if (info.timeout > Time.zero) |
| 66943 | 322 |
Some(Event_Timer.request(Time.now() + info.timeout) { terminate })
|
| 48674 | 323 |
else None |
| 56779 | 324 |
} |
| 48674 | 325 |
|
| 68217 | 326 |
def join: (Process_Result, Option[String]) = |
| 50845 | 327 |
{
|
| 68217 | 328 |
val result0 = future_result.join |
329 |
val result1 = |
|
|
68092
888d35a19866
store exports in session database, with asynchronous / parallel compression;
wenzelm
parents:
68088
diff
changeset
|
330 |
export_consumer.shutdown(close = true).map(Output.error_message_text(_)) match {
|
| 68217 | 331 |
case Nil => result0 |
332 |
case errs if result0.ok => result0.copy(rc = 1).errors(errs) |
|
333 |
case errs => result0.errors(errs) |
|
|
68092
888d35a19866
store exports in session database, with asynchronous / parallel compression;
wenzelm
parents:
68088
diff
changeset
|
334 |
} |
| 50845 | 335 |
|
|
68198
6710167e17af
avoid race condition wrt. ISABELLE_TMP, which is removed in Bash.cleanup() before Bash.result(progress_stdout);
wenzelm
parents:
68148
diff
changeset
|
336 |
Isabelle_System.rm_tree(export_tmp_dir) |
|
6710167e17af
avoid race condition wrt. ISABELLE_TMP, which is removed in Bash.cleanup() before Bash.result(progress_stdout);
wenzelm
parents:
68148
diff
changeset
|
337 |
|
| 68292 | 338 |
if (result1.ok) {
|
339 |
for ((dir, pats) <- info.export_files) {
|
|
340 |
Export.export_files(store, name, info.dir + dir, |
|
341 |
progress = if (verbose) progress else No_Progress, |
|
342 |
export_patterns = pats, |
|
343 |
export_prefix = name + ": ") |
|
344 |
} |
|
| 62633 | 345 |
Present.finish(progress, store.browser_info, graph_file, info, name) |
| 68292 | 346 |
} |
| 61372 | 347 |
|
| 59445 | 348 |
graph_file.delete |
| 66943 | 349 |
|
350 |
val was_timeout = |
|
351 |
timeout_request match {
|
|
352 |
case None => false |
|
353 |
case Some(request) => !request.cancel |
|
354 |
} |
|
| 48674 | 355 |
|
| 68217 | 356 |
val result2 = |
357 |
if (result1.interrupted) {
|
|
358 |
if (was_timeout) result1.error(Output.error_message_text("Timeout")).was_timeout
|
|
359 |
else result1.error(Output.error_message_text("Interrupt"))
|
|
360 |
} |
|
361 |
else result1 |
|
362 |
||
363 |
val heap_digest = |
|
364 |
if (result2.ok && do_output && store.output_heap(name).is_file) |
|
365 |
Some(Sessions.write_heap_digest(store.output_heap(name))) |
|
366 |
else None |
|
367 |
||
368 |
(result2, heap_digest) |
|
| 48674 | 369 |
} |
| 48364 | 370 |
} |
371 |
||
| 48424 | 372 |
|
| 62631 | 373 |
|
| 62641 | 374 |
/** build with results **/ |
| 48424 | 375 |
|
| 63996 | 376 |
class Results private[Build](results: Map[String, (Option[Process_Result], Sessions.Info)]) |
| 62403 | 377 |
{
|
378 |
def sessions: Set[String] = results.keySet |
|
|
63082
6af03422535a
expose Sessions.Info in Build.Results
Lars Hupel <lars.hupel@mytum.de>
parents:
62946
diff
changeset
|
379 |
def cancelled(name: String): Boolean = results(name)._1.isEmpty |
|
6af03422535a
expose Sessions.Info in Build.Results
Lars Hupel <lars.hupel@mytum.de>
parents:
62946
diff
changeset
|
380 |
def apply(name: String): Process_Result = results(name)._1.getOrElse(Process_Result(1)) |
|
6af03422535a
expose Sessions.Info in Build.Results
Lars Hupel <lars.hupel@mytum.de>
parents:
62946
diff
changeset
|
381 |
def info(name: String): Sessions.Info = results(name)._2 |
| 65253 | 382 |
val rc = |
383 |
(0 /: results.iterator.map( |
|
384 |
{ case (_, (Some(r), _)) => r.rc case (_, (None, _)) => 1 }))(_ max _)
|
|
| 62641 | 385 |
def ok: Boolean = rc == 0 |
| 62406 | 386 |
|
387 |
override def toString: String = rc.toString |
|
| 62403 | 388 |
} |
389 |
||
| 62641 | 390 |
def build( |
|
50404
898cac1dad5e
avoid startup within GUI thread -- it is only required later for dialog;
wenzelm
parents:
50367
diff
changeset
|
391 |
options: Options, |
| 64909 | 392 |
progress: Progress = No_Progress, |
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
393 |
check_unknown_files: Boolean = false, |
|
48511
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
wenzelm
parents:
48509
diff
changeset
|
394 |
build_heap: Boolean = false, |
| 48595 | 395 |
clean_build: Boolean = false, |
| 56890 | 396 |
dirs: List[Path] = Nil, |
397 |
select_dirs: List[Path] = Nil, |
|
|
66968
9991671c98aa
allow to augment session context via explicit session infos;
wenzelm
parents:
66962
diff
changeset
|
398 |
infos: List[Sessions.Info] = Nil, |
| 64265 | 399 |
numa_shuffling: Boolean = false, |
| 48509 | 400 |
max_jobs: Int = 1, |
| 48903 | 401 |
list_files: Boolean = false, |
|
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59811
diff
changeset
|
402 |
check_keywords: Set[String] = Set.empty, |
| 66841 | 403 |
fresh_build: Boolean = false, |
| 48509 | 404 |
no_build: Boolean = false, |
| 66745 | 405 |
soft_build: Boolean = false, |
| 48509 | 406 |
system_mode: Boolean = false, |
407 |
verbose: Boolean = false, |
|
| 65308 | 408 |
pide: Boolean = false, |
| 63224 | 409 |
requirements: Boolean = false, |
410 |
all_sessions: Boolean = false, |
|
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
411 |
base_sessions: List[String] = Nil, |
| 63224 | 412 |
exclude_session_groups: List[String] = Nil, |
|
59892
2a616319c171
added isabelle build option -x, to exclude sessions;
wenzelm
parents:
59891
diff
changeset
|
413 |
exclude_sessions: List[String] = Nil, |
| 63224 | 414 |
session_groups: List[String] = Nil, |
| 65422 | 415 |
sessions: List[String] = Nil, |
416 |
selection: Sessions.Selection = Sessions.Selection.empty): Results = |
|
| 63224 | 417 |
{
|
| 66745 | 418 |
val build_options = options.int.update("completion_limit", 0).bool.update("ML_statistics", true)
|
| 51220 | 419 |
|
| 68209 | 420 |
val store = Sessions.store(build_options, system_mode) |
| 66745 | 421 |
|
422 |
||
423 |
/* session selection and dependencies */ |
|
| 65422 | 424 |
|
| 66961 | 425 |
val full_sessions = |
| 67026 | 426 |
Sessions.load_structure(build_options, dirs = dirs, select_dirs = select_dirs, infos = infos) |
| 65422 | 427 |
|
|
66749
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
428 |
def sources_stamp(deps: Sessions.Deps, name: String): String = |
|
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
429 |
{
|
|
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
430 |
val digests = |
|
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
431 |
full_sessions(name).meta_digest :: deps.sources(name) ::: deps.imported_sources(name) |
|
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
432 |
SHA1.digest(cat_lines(digests.map(_.toString).sorted)).toString |
|
0445cfaf6132
more compact (second-order) digest for 10^2..10^3 source files, with slightly increased risk of collisions;
wenzelm
parents:
66747
diff
changeset
|
433 |
} |
| 66745 | 434 |
|
|
67030
a9859e879f38
proper build_selection for clean_build (amending 961285f581e6): e.g. relevant for "isabelle build_doc";
wenzelm
parents:
67026
diff
changeset
|
435 |
val selection1 = |
|
a9859e879f38
proper build_selection for clean_build (amending 961285f581e6): e.g. relevant for "isabelle build_doc";
wenzelm
parents:
67026
diff
changeset
|
436 |
Sessions.Selection(requirements, all_sessions, base_sessions, exclude_session_groups, |
|
a9859e879f38
proper build_selection for clean_build (amending 961285f581e6): e.g. relevant for "isabelle build_doc";
wenzelm
parents:
67026
diff
changeset
|
437 |
exclude_sessions, session_groups, sessions) ++ selection |
|
a9859e879f38
proper build_selection for clean_build (amending 961285f581e6): e.g. relevant for "isabelle build_doc";
wenzelm
parents:
67026
diff
changeset
|
438 |
|
| 68204 | 439 |
val deps = |
| 66745 | 440 |
{
|
441 |
val deps0 = |
|
| 68204 | 442 |
Sessions.deps(full_sessions.selection(selection1), full_sessions.global_theories, |
|
66962
e1bde71bace6
clarified signature: global_theories is always required;
wenzelm
parents:
66961
diff
changeset
|
443 |
progress = progress, inlined_files = true, verbose = verbose, |
|
e1bde71bace6
clarified signature: global_theories is always required;
wenzelm
parents:
66961
diff
changeset
|
444 |
list_files = list_files, check_keywords = check_keywords).check_errors |
| 66745 | 445 |
|
| 66841 | 446 |
if (soft_build && !fresh_build) {
|
| 66745 | 447 |
val outdated = |
| 68204 | 448 |
deps0.sessions_structure.build_topological_order.flatMap(name => |
| 68221 | 449 |
store.access_database(name) match {
|
| 68214 | 450 |
case Some(db) => |
| 68216 | 451 |
using(db)(store.read_build(_, name)) match {
|
| 66745 | 452 |
case Some(build) |
| 66747 | 453 |
if build.ok && build.sources == sources_stamp(deps0, name) => None |
| 66745 | 454 |
case _ => Some(name) |
455 |
} |
|
456 |
case None => Some(name) |
|
457 |
}) |
|
| 68204 | 458 |
|
459 |
Sessions.deps(full_sessions.selection(Sessions.Selection(sessions = outdated)), |
|
460 |
full_sessions.global_theories, progress = progress, inlined_files = true).check_errors |
|
| 66745 | 461 |
} |
| 68204 | 462 |
else deps0 |
| 66745 | 463 |
} |
464 |
||
465 |
||
466 |
/* check unknown files */ |
|
|
48504
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
wenzelm
parents:
48494
diff
changeset
|
467 |
|
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
468 |
if (check_unknown_files) {
|
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
469 |
val source_files = |
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
470 |
(for {
|
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
471 |
(_, base) <- deps.session_bases.iterator |
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
472 |
(path, _) <- base.sources.iterator |
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
473 |
} yield path).toList |
| 67098 | 474 |
val exclude_files = List(Path.explode("$POLYML_EXE")).map(_.canonical_file)
|
475 |
val unknown_files = |
|
|
67782
7e223a05e6d8
clarified notion of unknown files: ignore files outside of a Mercurial repository;
wenzelm
parents:
67493
diff
changeset
|
476 |
Mercurial.check_files(source_files)._2. |
| 67098 | 477 |
filterNot(path => exclude_files.contains(path.canonical_file)) |
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
478 |
if (unknown_files.nonEmpty) {
|
|
67782
7e223a05e6d8
clarified notion of unknown files: ignore files outside of a Mercurial repository;
wenzelm
parents:
67493
diff
changeset
|
479 |
progress.echo_warning("Unknown files (not part of the underlying Mercurial repository):" +
|
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
480 |
unknown_files.map(path => path.expand.implode).sorted.mkString("\n ", "\n ", ""))
|
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
481 |
} |
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
482 |
} |
|
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
483 |
|
| 51220 | 484 |
|
485 |
/* main build process */ |
|
486 |
||
| 68204 | 487 |
val queue = Queue(progress, deps.sessions_structure, store) |
| 65289 | 488 |
|
| 68219 | 489 |
store.prepare_output_dir() |
| 48373 | 490 |
|
| 48595 | 491 |
if (clean_build) {
|
|
67030
a9859e879f38
proper build_selection for clean_build (amending 961285f581e6): e.g. relevant for "isabelle build_doc";
wenzelm
parents:
67026
diff
changeset
|
492 |
for (name <- full_sessions.build_descendants(full_sessions.build_selection(selection1))) {
|
|
68220
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
493 |
val (relevant, ok) = store.clean_output(name) |
|
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
494 |
if (relevant) {
|
|
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
495 |
if (ok) progress.echo("Cleaned " + name)
|
|
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
496 |
else progress.echo(name + " FAILED to clean") |
|
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
497 |
} |
| 48595 | 498 |
} |
499 |
} |
|
500 |
||
| 48425 | 501 |
// scheduler loop |
|
63082
6af03422535a
expose Sessions.Info in Build.Results
Lars Hupel <lars.hupel@mytum.de>
parents:
62946
diff
changeset
|
502 |
case class Result( |
| 66594 | 503 |
current: Boolean, |
| 68213 | 504 |
heap_digest: Option[String], |
| 66594 | 505 |
process: Option[Process_Result], |
506 |
info: Sessions.Info) |
|
| 62402 | 507 |
{
|
508 |
def ok: Boolean = |
|
509 |
process match {
|
|
510 |
case None => false |
|
511 |
case Some(res) => res.rc == 0 |
|
512 |
} |
|
513 |
} |
|
|
48639
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
wenzelm
parents:
48626
diff
changeset
|
514 |
|
|
56837
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
wenzelm
parents:
56831
diff
changeset
|
515 |
def sleep() |
|
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
wenzelm
parents:
56831
diff
changeset
|
516 |
{
|
|
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
wenzelm
parents:
56831
diff
changeset
|
517 |
try { Thread.sleep(500) }
|
| 56861 | 518 |
catch { case Exn.Interrupt() => Exn.Interrupt.impose() }
|
|
56837
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
wenzelm
parents:
56831
diff
changeset
|
519 |
} |
| 50366 | 520 |
|
| 64265 | 521 |
val numa_nodes = new NUMA.Nodes(numa_shuffling) |
522 |
||
| 48425 | 523 |
@tailrec def loop( |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
524 |
pending: Queue, |
| 62628 | 525 |
running: Map[String, (List[String], Job)], |
|
48639
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
wenzelm
parents:
48626
diff
changeset
|
526 |
results: Map[String, Result]): Map[String, Result] = |
| 48425 | 527 |
{
|
| 64265 | 528 |
def used_node(i: Int): Boolean = |
529 |
running.iterator.exists( |
|
530 |
{ case (_, (_, job)) => job.numa_node.isDefined && job.numa_node.get == i })
|
|
531 |
||
| 48425 | 532 |
if (pending.is_empty) results |
| 51253 | 533 |
else {
|
534 |
if (progress.stopped) |
|
535 |
for ((_, (_, job)) <- running) job.terminate |
|
536 |
||
| 48674 | 537 |
running.find({ case (_, (_, job)) => job.is_finished }) match {
|
| 62628 | 538 |
case Some((name, (input_heaps, job))) => |
| 50367 | 539 |
//{{{ finish job
|
| 48424 | 540 |
|
| 68217 | 541 |
val (process_result, heap_digest) = job.join |
| 48373 | 542 |
|
| 65294 | 543 |
val log_lines = process_result.out_lines.filterNot(_.startsWith("\f"))
|
|
62404
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
wenzelm
parents:
62403
diff
changeset
|
544 |
val process_result_tail = |
|
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
wenzelm
parents:
62403
diff
changeset
|
545 |
{
|
|
62409
e391528eff3b
proper option process_output_tail, more generous default;
wenzelm
parents:
62406
diff
changeset
|
546 |
val tail = job.info.options.int("process_output_tail")
|
| 62632 | 547 |
process_result.copy( |
548 |
out_lines = |
|
|
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
549 |
"(see also " + store.output_log(name).file.toString + ")" :: |
| 65294 | 550 |
(if (tail == 0) log_lines else log_lines.drop(log_lines.length - tail max 0))) |
|
62404
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
wenzelm
parents:
62403
diff
changeset
|
551 |
} |
|
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
wenzelm
parents:
62403
diff
changeset
|
552 |
|
|
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
553 |
|
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
554 |
// write log file |
| 68217 | 555 |
if (process_result.ok) {
|
556 |
File.write_gzip(store.output_log_gz(name), terminate_lines(log_lines)) |
|
557 |
} |
|
558 |
else File.write(store.output_log(name), terminate_lines(log_lines)) |
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
559 |
|
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
560 |
// write database |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
561 |
{
|
|
66944
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
562 |
val build_log = |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
563 |
Build_Log.Log_File(name, process_result.out_lines). |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
564 |
parse_session_info( |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
565 |
command_timings = true, |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
566 |
theory_timings = true, |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
567 |
ml_statistics = true, |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
568 |
task_statistics = true) |
|
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
569 |
|
| 68221 | 570 |
using(store.open_database(name, output = true))(db => |
|
65318
342efc382558
eliminated somewhat redundant inlined name (despite a7aa17a1f721);
wenzelm
parents:
65317
diff
changeset
|
571 |
store.write_session_info(db, name, |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
572 |
build_log = |
|
66944
05df740cb54b
more informative timeout message, notably for build_status;
wenzelm
parents:
66943
diff
changeset
|
573 |
if (process_result.timeout) build_log.error("Timeout") else build_log,
|
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
574 |
build = |
| 68213 | 575 |
Session_Info(sources_stamp(deps, name), input_heaps, heap_digest, |
| 66744 | 576 |
process_result.rc))) |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
577 |
} |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
578 |
|
|
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
579 |
// messages |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
580 |
process_result.err_lines.foreach(progress.echo(_)) |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
581 |
|
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
582 |
if (process_result.ok) |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
583 |
progress.echo("Finished " + name + " (" + process_result.timing.message_resources + ")")
|
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
584 |
else {
|
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
585 |
progress.echo(name + " FAILED") |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
586 |
if (!process_result.interrupted) progress.echo(process_result_tail.out) |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
587 |
} |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
588 |
|
|
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50686
diff
changeset
|
589 |
loop(pending - name, running - name, |
| 68213 | 590 |
results + (name -> Result(false, heap_digest, Some(process_result_tail), job.info))) |
| 50367 | 591 |
//}}} |
| 60215 | 592 |
case None if running.size < (max_jobs max 1) => |
| 50367 | 593 |
//{{{ check/start next job
|
| 48547 | 594 |
pending.dequeue(running.isDefinedAt(_)) match {
|
595 |
case Some((name, info)) => |
|
| 66848 | 596 |
val ancestor_results = |
| 68204 | 597 |
deps.sessions_structure.build_requirements(List(name)).filterNot(_ == name). |
| 66848 | 598 |
map(results(_)) |
| 68213 | 599 |
val ancestor_heaps = ancestor_results.flatMap(_.heap_digest) |
| 62628 | 600 |
|
| 65360 | 601 |
val do_output = build_heap || Sessions.is_pure(name) || queue.is_inner(name) |
| 48547 | 602 |
|
| 68213 | 603 |
val (current, heap_digest) = |
| 48547 | 604 |
{
|
| 68221 | 605 |
store.access_database(name) match {
|
|
68212
5a59fded83c7
clarified heap vs. database operations: discontinued correlation of directory;
wenzelm
parents:
68209
diff
changeset
|
606 |
case Some(db) => |
| 68216 | 607 |
using(db)(store.read_build(_, name)) match {
|
608 |
case Some(build) => |
|
609 |
val heap_digest = store.find_heap_digest(name) |
|
610 |
val current = |
|
611 |
!fresh_build && |
|
612 |
build.ok && |
|
613 |
build.sources == sources_stamp(deps, name) && |
|
614 |
build.input_heaps == ancestor_heaps && |
|
615 |
build.output_heap == heap_digest && |
|
616 |
!(do_output && heap_digest.isEmpty) |
|
617 |
(current, heap_digest) |
|
618 |
case None => (false, None) |
|
619 |
} |
|
| 62636 | 620 |
case None => (false, None) |
|
48504
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
wenzelm
parents:
48494
diff
changeset
|
621 |
} |
| 48547 | 622 |
} |
| 62628 | 623 |
val all_current = current && ancestor_results.forall(_.current) |
|
48528
784c6f63d79c
proper all_current, which regards parent status as well;
wenzelm
parents:
48511
diff
changeset
|
624 |
|
| 48547 | 625 |
if (all_current) |
| 62402 | 626 |
loop(pending - name, running, |
| 68213 | 627 |
results + (name -> Result(true, heap_digest, Some(Process_Result(0)), info))) |
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
628 |
else if (no_build) {
|
| 50366 | 629 |
if (verbose) progress.echo("Skipping " + name + " ...")
|
| 62402 | 630 |
loop(pending - name, running, |
| 68213 | 631 |
results + (name -> Result(false, heap_digest, Some(Process_Result(1)), info))) |
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
632 |
} |
| 62628 | 633 |
else if (ancestor_results.forall(_.ok) && !progress.stopped) {
|
|
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
634 |
progress.echo((if (do_output) "Building " else "Running ") + name + " ...") |
|
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
635 |
|
|
68220
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
636 |
store.clean_output(name) |
| 68221 | 637 |
using(store.open_database(name, output = true))(store.init_session_info(_, name)) |
|
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
638 |
|
| 64265 | 639 |
val numa_node = numa_nodes.next(used_node(_)) |
| 51220 | 640 |
val job = |
| 68204 | 641 |
new Job(progress, name, info, deps, store, do_output, |
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
642 |
verbose, pide, numa_node, queue.command_timings(name)) |
| 62628 | 643 |
loop(pending, running + (name -> (ancestor_heaps, job)), results) |
| 48547 | 644 |
} |
645 |
else {
|
|
| 50366 | 646 |
progress.echo(name + " CANCELLED") |
| 65253 | 647 |
loop(pending - name, running, |
| 68213 | 648 |
results + (name -> Result(false, heap_digest, None, info))) |
| 48547 | 649 |
} |
650 |
case None => sleep(); loop(pending, running, results) |
|
| 48425 | 651 |
} |
| 50367 | 652 |
///}}} |
| 48425 | 653 |
case None => sleep(); loop(pending, running, results) |
| 48373 | 654 |
} |
| 51253 | 655 |
} |
| 48425 | 656 |
} |
657 |
||
| 51220 | 658 |
|
659 |
/* build results */ |
|
660 |
||
| 62641 | 661 |
val results0 = |
| 48583 | 662 |
if (deps.is_empty) {
|
| 65827 | 663 |
progress.echo_warning("Nothing to build")
|
|
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
50686
diff
changeset
|
664 |
Map.empty[String, Result] |
| 48583 | 665 |
} |
666 |
else loop(queue, Map.empty, Map.empty) |
|
667 |
||
| 62641 | 668 |
val results = |
| 64265 | 669 |
new Results( |
670 |
(for ((name, result) <- results0.iterator) |
|
671 |
yield (name, (result.process, result.info))).toMap) |
|
| 62641 | 672 |
|
673 |
if (results.rc != 0 && (verbose || !no_build)) {
|
|
674 |
val unfinished = |
|
675 |
(for {
|
|
676 |
name <- results.sessions.iterator |
|
677 |
if !results(name).ok |
|
678 |
} yield name).toList.sorted |
|
679 |
progress.echo("Unfinished session(s): " + commas(unfinished))
|
|
680 |
} |
|
681 |
||
|
51418
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
682 |
|
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
683 |
/* global browser info */ |
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
684 |
|
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
685 |
if (!no_build) {
|
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
686 |
val browser_chapters = |
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
687 |
(for {
|
| 62641 | 688 |
(name, result) <- results0.iterator |
|
62944
3ee643c5ed00
more standard session build process, including browser_info;
wenzelm
parents:
62902
diff
changeset
|
689 |
if result.ok |
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
690 |
info = full_sessions(name) |
|
51418
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
691 |
if info.options.bool("browser_info")
|
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
692 |
} yield (info.chapter, (name, info.description))).toList.groupBy(_._1). |
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
693 |
map({ case (chapter, es) => (chapter, es.map(_._2)) }).filterNot(_._2.isEmpty)
|
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
694 |
|
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
695 |
for ((chapter, entries) <- browser_chapters) |
| 62632 | 696 |
Present.update_chapter_index(store.browser_info, chapter, entries) |
|
51418
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
697 |
|
| 62632 | 698 |
if (browser_chapters.nonEmpty) Present.make_global_index(store.browser_info) |
|
51418
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
699 |
} |
|
7b8ce8403340
more accurate handling of global browser info at the very end (without races), subject to no_build and info.browser_info;
wenzelm
parents:
51402
diff
changeset
|
700 |
|
| 62641 | 701 |
results |
| 48341 | 702 |
} |
703 |
||
704 |
||
| 62833 | 705 |
/* Isabelle tool wrapper */ |
| 48341 | 706 |
|
| 62833 | 707 |
val isabelle_tool = Isabelle_Tool("build", "build and manage Isabelle sessions", args =>
|
| 48341 | 708 |
{
|
| 62833 | 709 |
val build_options = Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS"))
|
| 62590 | 710 |
|
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
711 |
var base_sessions: List[String] = Nil |
| 62833 | 712 |
var select_dirs: List[Path] = Nil |
| 64265 | 713 |
var numa_shuffling = false |
| 65308 | 714 |
var pide = false |
| 62833 | 715 |
var requirements = false |
| 66745 | 716 |
var soft_build = false |
| 62833 | 717 |
var exclude_session_groups: List[String] = Nil |
718 |
var all_sessions = false |
|
719 |
var build_heap = false |
|
720 |
var clean_build = false |
|
721 |
var dirs: List[Path] = Nil |
|
| 66841 | 722 |
var fresh_build = false |
| 62833 | 723 |
var session_groups: List[String] = Nil |
724 |
var max_jobs = 1 |
|
725 |
var check_keywords: Set[String] = Set.empty |
|
726 |
var list_files = false |
|
727 |
var no_build = false |
|
| 67847 | 728 |
var options = Options.init(opts = build_options) |
| 62833 | 729 |
var system_mode = false |
730 |
var verbose = false |
|
731 |
var exclude_sessions: List[String] = Nil |
|
| 62590 | 732 |
|
| 62833 | 733 |
val getopts = Getopts("""
|
| 62590 | 734 |
Usage: isabelle build [OPTIONS] [SESSIONS ...] |
735 |
||
736 |
Options are: |
|
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
737 |
-B NAME include session NAME and all descendants |
| 62590 | 738 |
-D DIR include session directory and select its sessions |
| 64265 | 739 |
-N cyclic shuffling of NUMA CPU nodes (performance tuning) |
| 65308 | 740 |
-P build via PIDE protocol |
| 62590 | 741 |
-R operate on requirements of selected sessions |
| 66745 | 742 |
-S soft build: only observe changes of sources, not heap images |
| 62590 | 743 |
-X NAME exclude sessions from group NAME and all descendants |
744 |
-a select all sessions |
|
745 |
-b build heap images |
|
746 |
-c clean build |
|
747 |
-d DIR include session directory |
|
| 66841 | 748 |
-f fresh build |
| 62590 | 749 |
-g NAME select session group NAME |
750 |
-j INT maximum number of parallel jobs (default 1) |
|
751 |
-k KEYWORD check theory sources for conflicts with proposed keywords |
|
752 |
-l list session source files |
|
753 |
-n no build -- test dependencies only |
|
754 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
|
755 |
-s system build mode: produce output in ISABELLE_HOME |
|
756 |
-v verbose |
|
757 |
-x NAME exclude session NAME and all descendants |
|
758 |
||
| 62596 | 759 |
Build and manage Isabelle sessions, depending on implicit settings: |
760 |
||
| 64455 | 761 |
""" + Library.prefix_lines(" ", Build_Log.Settings.show()) + "\n",
|
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
762 |
"B:" -> (arg => base_sessions = base_sessions ::: List(arg)), |
| 62833 | 763 |
"D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))), |
| 64265 | 764 |
"N" -> (_ => numa_shuffling = true), |
| 65308 | 765 |
"P" -> (_ => pide = true), |
| 62833 | 766 |
"R" -> (_ => requirements = true), |
| 66745 | 767 |
"S" -> (_ => soft_build = true), |
| 62833 | 768 |
"X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)), |
769 |
"a" -> (_ => all_sessions = true), |
|
770 |
"b" -> (_ => build_heap = true), |
|
771 |
"c" -> (_ => clean_build = true), |
|
772 |
"d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))), |
|
| 66841 | 773 |
"f" -> (_ => fresh_build = true), |
| 62833 | 774 |
"g:" -> (arg => session_groups = session_groups ::: List(arg)), |
| 63805 | 775 |
"j:" -> (arg => max_jobs = Value.Int.parse(arg)), |
| 62833 | 776 |
"k:" -> (arg => check_keywords = check_keywords + arg), |
777 |
"l" -> (_ => list_files = true), |
|
778 |
"n" -> (_ => no_build = true), |
|
779 |
"o:" -> (arg => options = options + arg), |
|
780 |
"s" -> (_ => system_mode = true), |
|
781 |
"v" -> (_ => verbose = true), |
|
782 |
"x:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg))) |
|
| 62590 | 783 |
|
| 62833 | 784 |
val sessions = getopts(args) |
| 62590 | 785 |
|
| 64115 | 786 |
val progress = new Console_Progress(verbose = verbose) |
| 62590 | 787 |
|
| 64140 | 788 |
val start_date = Date.now() |
789 |
||
| 62833 | 790 |
if (verbose) {
|
791 |
progress.echo( |
|
| 64155 | 792 |
"Started at " + Build_Log.print_date(start_date) + |
| 64140 | 793 |
" (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + Isabelle_System.hostname() +")")
|
| 64081 | 794 |
progress.echo(Build_Log.Settings.show() + "\n") |
| 62833 | 795 |
} |
| 62590 | 796 |
|
| 62833 | 797 |
val results = |
798 |
progress.interrupt_handler {
|
|
| 67846 | 799 |
build(options, |
800 |
progress = progress, |
|
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
801 |
check_unknown_files = Mercurial.is_repository(Path.explode("~~")),
|
| 63224 | 802 |
build_heap = build_heap, |
803 |
clean_build = clean_build, |
|
804 |
dirs = dirs, |
|
805 |
select_dirs = select_dirs, |
|
| 65831 | 806 |
numa_shuffling = NUMA.enabled_warning(progress, numa_shuffling), |
| 63224 | 807 |
max_jobs = max_jobs, |
808 |
list_files = list_files, |
|
809 |
check_keywords = check_keywords, |
|
| 66841 | 810 |
fresh_build = fresh_build, |
| 63224 | 811 |
no_build = no_build, |
| 66745 | 812 |
soft_build = soft_build, |
| 63224 | 813 |
system_mode = system_mode, |
814 |
verbose = verbose, |
|
| 65308 | 815 |
pide = pide, |
| 63224 | 816 |
requirements = requirements, |
817 |
all_sessions = all_sessions, |
|
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
818 |
base_sessions = base_sessions, |
| 63224 | 819 |
exclude_session_groups = exclude_session_groups, |
820 |
exclude_sessions = exclude_sessions, |
|
821 |
session_groups = session_groups, |
|
822 |
sessions = sessions) |
|
| 62833 | 823 |
} |
| 64140 | 824 |
val end_date = Date.now() |
825 |
val elapsed_time = end_date.time - start_date.time |
|
| 62590 | 826 |
|
| 62833 | 827 |
if (verbose) {
|
| 64155 | 828 |
progress.echo("\nFinished at " + Build_Log.print_date(end_date))
|
| 62833 | 829 |
} |
| 62590 | 830 |
|
| 62833 | 831 |
val total_timing = |
832 |
(Timing.zero /: results.sessions.iterator.map(a => results(a).timing))(_ + _). |
|
833 |
copy(elapsed = elapsed_time) |
|
834 |
progress.echo(total_timing.message_resources) |
|
| 62590 | 835 |
|
| 62833 | 836 |
sys.exit(results.rc) |
837 |
}) |
|
| 68305 | 838 |
|
839 |
||
840 |
/* build logic image */ |
|
841 |
||
842 |
def build_logic(options: Options, logic: String, |
|
843 |
progress: Progress = No_Progress, |
|
844 |
build_heap: Boolean = false, |
|
845 |
dirs: List[Path] = Nil, |
|
846 |
system_mode: Boolean = false): Int = |
|
847 |
{
|
|
848 |
if (build(options, build_heap = build_heap, no_build = true, dirs = dirs, |
|
849 |
system_mode = system_mode, sessions = List(logic)).ok) 0 |
|
850 |
else {
|
|
851 |
progress.echo("Build started for Isabelle/" + logic + " ...")
|
|
| 68331 | 852 |
Build.build(options, progress = progress, build_heap = build_heap, dirs = dirs, |
853 |
system_mode = system_mode, sessions = List(logic)).rc |
|
| 68305 | 854 |
} |
855 |
} |
|
| 48276 | 856 |
} |