| author | wenzelm | 
| Thu, 04 May 2017 12:15:50 +0200 | |
| changeset 65712 | ddd6dfc28e80 | 
| parent 65532 | febfd9f78bd4 | 
| child 65827 | 3bba3856b56c | 
| 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  | 
||
| 48548 | 11  | 
import java.io.{BufferedInputStream, FileInputStream,
 | 
| 48494 | 12  | 
BufferedReader, InputStreamReader, IOException}  | 
13  | 
import java.util.zip.GZIPInputStream  | 
|
| 48335 | 14  | 
|
| 
48676
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
15  | 
import scala.collection.SortedSet  | 
| 
51397
 
03b586ee5930
support for 'chapter' specifications within session ROOT;
 
wenzelm 
parents: 
51300 
diff
changeset
 | 
16  | 
import scala.collection.mutable  | 
| 
48340
 
6f4fc030882a
allow explicit specification of additional session directories;
 
wenzelm 
parents: 
48339 
diff
changeset
 | 
17  | 
import scala.annotation.tailrec  | 
| 
48337
 
9c7f8e5805b4
cumulate semantic Session_Info, based on syntactic Session_Entry;
 
wenzelm 
parents: 
48336 
diff
changeset
 | 
18  | 
|
| 48335 | 19  | 
|
| 48276 | 20  | 
object Build  | 
21  | 
{
 | 
|
| 62631 | 22  | 
/** auxiliary **/  | 
| 48424 | 23  | 
|
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
24  | 
/* persistent build info */  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
25  | 
|
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
26  | 
sealed case class Session_Info(  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
27  | 
sources: List[String],  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
28  | 
input_heaps: List[String],  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
29  | 
output_heap: Option[String],  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
30  | 
return_code: Int)  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
31  | 
|
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
32  | 
|
| 65289 | 33  | 
/* 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
 | 
34  | 
|
| 62631 | 35  | 
private object Queue  | 
| 
48676
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
36  | 
  {
 | 
| 65289 | 37  | 
def load_timings(store: Sessions.Store, name: String): (List[Properties.T], Double) =  | 
38  | 
    {
 | 
|
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
39  | 
val no_timings: (List[Properties.T], Double) = (Nil, 0.0)  | 
| 65289 | 40  | 
|
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
41  | 
      store.find_database(name) match {
 | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
42  | 
case None => no_timings  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
43  | 
case Some(database) =>  | 
| 
 
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  | 
          {
 | 
| 65365 | 46  | 
            Output.warning("Ignoring bad database: " +
 | 
47  | 
database.expand + (if (msg == "") "" else "\n" + msg))  | 
|
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
48  | 
no_timings  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
49  | 
}  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
50  | 
          try {
 | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
51  | 
using(SQLite.open_database(database))(db =>  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
52  | 
            {
 | 
| 
65320
 
52861eebf58d
access table via session_name: db may in principle contain multiple entries;
 
wenzelm 
parents: 
65318 
diff
changeset
 | 
53  | 
val build_log = store.read_build_log(db, name, command_timings = true)  | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
54  | 
val session_timing = Markup.Elapsed.unapply(build_log.session_timing) getOrElse 0.0  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
55  | 
(build_log.command_timings, session_timing)  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
56  | 
})  | 
| 
 
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  | 
}  | 
| 65289 | 63  | 
}  | 
64  | 
}  | 
|
65  | 
||
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
66  | 
def apply(sessions: Sessions.T, 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
 | 
67  | 
    {
 | 
| 
65420
 
695d4e22345a
support for static session imports, without affect build hierarchy;
 
wenzelm 
parents: 
65419 
diff
changeset
 | 
68  | 
val graph = sessions.build_graph  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
69  | 
val names = graph.keys  | 
| 51220 | 70  | 
|
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
71  | 
val timings = names.map(name => (name, load_timings(store, name)))  | 
| 51220 | 72  | 
val command_timings =  | 
73  | 
        Map(timings.map({ case (name, (ts, _)) => (name, ts) }): _*).withDefaultValue(Nil)
 | 
|
74  | 
val session_timing =  | 
|
75  | 
        Map(timings.map({ case (name, (_, t)) => (name, t) }): _*).withDefaultValue(0.0)
 | 
|
| 
48678
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
76  | 
|
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
77  | 
def outdegree(name: String): Int = graph.imm_succs(name).size  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
78  | 
|
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
79  | 
object Ordering extends scala.math.Ordering[String]  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
80  | 
      {
 | 
| 
51227
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
81  | 
def compare_timing(name1: String, name2: String): Int =  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
82  | 
        {
 | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
83  | 
val t1 = session_timing(name1)  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
84  | 
val t2 = session_timing(name2)  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
85  | 
if (t1 == 0.0 || t2 == 0.0) 0  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
86  | 
else t1 compare t2  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
87  | 
}  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
88  | 
|
| 
48678
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
89  | 
def compare(name1: String, name2: String): Int =  | 
| 
51229
 
6e40d0bb89e3
prefer outdegree in comparison again (cf. 88c96e836ed6) -- NB: big jobs might hide behind small ones in this naive queuing scheme;
 
wenzelm 
parents: 
51227 
diff
changeset
 | 
90  | 
          outdegree(name2) compare outdegree(name1) match {
 | 
| 
48678
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
91  | 
case 0 =>  | 
| 
51229
 
6e40d0bb89e3
prefer outdegree in comparison again (cf. 88c96e836ed6) -- NB: big jobs might hide behind small ones in this naive queuing scheme;
 
wenzelm 
parents: 
51227 
diff
changeset
 | 
92  | 
              compare_timing(name2, name1) match {
 | 
| 51220 | 93  | 
case 0 =>  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
94  | 
                  sessions(name2).timeout compare sessions(name1).timeout match {
 | 
| 51220 | 95  | 
case 0 => name1 compare name2  | 
96  | 
case ord => ord  | 
|
97  | 
}  | 
|
| 
48678
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
98  | 
case ord => ord  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
99  | 
}  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
100  | 
case ord => ord  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
101  | 
}  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
102  | 
}  | 
| 
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
103  | 
|
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
104  | 
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
 | 
105  | 
}  | 
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
106  | 
}  | 
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
107  | 
|
| 65314 | 108  | 
private class Queue(  | 
| 62631 | 109  | 
graph: Graph[String, Sessions.Info],  | 
| 51220 | 110  | 
order: SortedSet[String],  | 
111  | 
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
 | 
112  | 
  {
 | 
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
113  | 
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
 | 
114  | 
|
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
115  | 
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
 | 
116  | 
|
| 
51227
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
117  | 
def - (name: String): Queue =  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
118  | 
new Queue(graph.del_node(name),  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
119  | 
order - name, // FIXME scala-2.10.0 TreeSet problem!?  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
120  | 
command_timings)  | 
| 
48676
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
121  | 
|
| 62631 | 122  | 
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
 | 
123  | 
    {
 | 
| 
51227
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
124  | 
val it = order.iterator.dropWhile(name =>  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
125  | 
skip(name)  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
126  | 
|| !graph.defined(name) // FIXME scala-2.10.0 TreeSet problem!?  | 
| 
 
88c96e836ed6
prefer comparison of session timing, if this is known already;
 
wenzelm 
parents: 
51223 
diff
changeset
 | 
127  | 
|| !graph.is_minimal(name))  | 
| 48680 | 128  | 
      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
 | 
129  | 
else None  | 
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
130  | 
}  | 
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
131  | 
}  | 
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
132  | 
|
| 
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
133  | 
|
| 65313 | 134  | 
/* PIDE protocol handler */  | 
135  | 
||
136  | 
class Handler(progress: Progress, session: Session, session_name: String)  | 
|
137  | 
extends Session.Protocol_Handler  | 
|
138  | 
  {
 | 
|
139  | 
val result_error: Promise[String] = Future.promise  | 
|
140  | 
||
141  | 
    override def exit() { result_error.cancel }
 | 
|
142  | 
||
143  | 
private def build_session_finished(msg: Prover.Protocol_Output): Boolean =  | 
|
144  | 
    {
 | 
|
145  | 
val error_message =  | 
|
| 
65344
 
b99283eed13c
clarified YXML vs. symbol encoding: operate on whole message;
 
wenzelm 
parents: 
65320 
diff
changeset
 | 
146  | 
        try { Pretty.string_of(Symbol.decode_yxml(msg.text)) }
 | 
| 65313 | 147  | 
        catch { case ERROR(msg) => msg }
 | 
148  | 
result_error.fulfill(error_message)  | 
|
149  | 
session.send_stop()  | 
|
150  | 
true  | 
|
151  | 
}  | 
|
152  | 
||
153  | 
private def loading_theory(msg: Prover.Protocol_Output): Boolean =  | 
|
154  | 
      msg.properties match {
 | 
|
155  | 
case Markup.Loading_Theory(name) =>  | 
|
156  | 
progress.theory(session_name, name)  | 
|
157  | 
true  | 
|
158  | 
case _ => false  | 
|
159  | 
}  | 
|
160  | 
||
161  | 
val functions =  | 
|
162  | 
List(  | 
|
163  | 
Markup.BUILD_SESSION_FINISHED -> build_session_finished _,  | 
|
164  | 
Markup.LOADING_THEORY -> loading_theory _)  | 
|
165  | 
}  | 
|
166  | 
||
167  | 
||
| 65308 | 168  | 
/* job: running prover process */  | 
| 48341 | 169  | 
|
| 65308 | 170  | 
private class Job(progress: Progress,  | 
171  | 
name: String,  | 
|
172  | 
val info: Sessions.Info,  | 
|
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
173  | 
sessions: Sessions.T,  | 
| 65313 | 174  | 
deps: Sessions.Deps,  | 
| 65308 | 175  | 
store: Sessions.Store,  | 
176  | 
do_output: Boolean,  | 
|
177  | 
verbose: Boolean,  | 
|
178  | 
pide: Boolean,  | 
|
179  | 
val numa_node: Option[Int],  | 
|
180  | 
command_timings: List[Properties.T])  | 
|
| 48418 | 181  | 
  {
 | 
| 62633 | 182  | 
val output = store.output_dir + Path.basic(name)  | 
| 48674 | 183  | 
def output_path: Option[Path] = if (do_output) Some(output) else None  | 
| 62633 | 184  | 
output.file.delete  | 
| 48674 | 185  | 
|
| 65312 | 186  | 
val options =  | 
187  | 
      numa_node match {
 | 
|
188  | 
case None => info.options  | 
|
189  | 
        case Some(n) => info.options.string("ML_process_policy") = NUMA.policy(n)
 | 
|
190  | 
}  | 
|
191  | 
||
| 59445 | 192  | 
    private val graph_file = Isabelle_System.tmp_file("session_graph", "pdf")
 | 
| 
65506
 
359fc6266a00
more robust error (amending 2c27c3d1fd3b): responsibility is gradually moved from ML to Scala;
 
wenzelm 
parents: 
65471 
diff
changeset
 | 
193  | 
isabelle.graphview.Graph_File.write(options, graph_file, deps(name).session_graph)  | 
| 59445 | 194  | 
|
| 62573 | 195  | 
private val future_result: Future[Process_Result] =  | 
| 
61559
 
313eca3fa847
more direct task future implementation, with proper cancel operation;
 
wenzelm 
parents: 
61556 
diff
changeset
 | 
196  | 
      Future.thread("build") {
 | 
| 65308 | 197  | 
        val parent = info.parent.getOrElse("")
 | 
| 65441 | 198  | 
val base = deps(name)  | 
| 65308 | 199  | 
val args_yxml =  | 
200  | 
YXML.string_of_body(  | 
|
| 
62944
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
201  | 
            {
 | 
| 
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
202  | 
import XML.Encode._  | 
| 
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
203  | 
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
 | 
204  | 
pair(Path.encode, pair(list(pair(Path.encode, Path.encode)), pair(string,  | 
| 65307 | 205  | 
pair(string, pair(string, pair(string, pair(Path.encode,  | 
| 65517 | 206  | 
pair(list(pair(Options.encode, list(pair(string, properties)))),  | 
| 
65471
 
05e5bffcf1d8
clarified loaded_theories: map to qualified theory name;
 
wenzelm 
parents: 
65457 
diff
changeset
 | 
207  | 
pair(list(pair(string, string)), pair(list(pair(string, string)),  | 
| 
 
05e5bffcf1d8
clarified loaded_theories: map to qualified theory name;
 
wenzelm 
parents: 
65457 
diff
changeset
 | 
208  | 
list(pair(string, string))))))))))))))))(  | 
| 
62944
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
209  | 
(Symbol.codes, (command_timings, (do_output, (verbose,  | 
| 
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
210  | 
(store.browser_info, (info.document_files, (File.standard_path(graph_file),  | 
| 65307 | 211  | 
(parent, (info.chapter, (name, (Path.current,  | 
| 
65431
 
4a3e6cda3b94
provide session base for "isabelle build" and "isabelle console" ML process;
 
wenzelm 
parents: 
65422 
diff
changeset
 | 
212  | 
(info.theories,  | 
| 
65471
 
05e5bffcf1d8
clarified loaded_theories: map to qualified theory name;
 
wenzelm 
parents: 
65457 
diff
changeset
 | 
213  | 
(base.global_theories.toList, (base.loaded_theories.toList,  | 
| 
 
05e5bffcf1d8
clarified loaded_theories: map to qualified theory name;
 
wenzelm 
parents: 
65457 
diff
changeset
 | 
214  | 
base.dest_known_theories)))))))))))))))  | 
| 65308 | 215  | 
})  | 
216  | 
||
217  | 
val env =  | 
|
218  | 
Isabelle_System.settings() +  | 
|
| 65312 | 219  | 
            ("ISABELLE_ML_DEBUGGER" -> options.bool("ML_debugger").toString)
 | 
| 65308 | 220  | 
|
221  | 
def save_heap: String =  | 
|
222  | 
"ML_Heap.share_common_data (); ML_Heap.save_child " +  | 
|
223  | 
ML_Syntax.print_string0(File.platform_path(output))  | 
|
| 
62944
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
224  | 
|
| 65360 | 225  | 
        if (pide && !Sessions.is_pure(name)) {
 | 
| 65532 | 226  | 
val resources = new Resources(deps(parent))  | 
| 65313 | 227  | 
val session = new Session(options, resources)  | 
228  | 
val handler = new Handler(progress, session, name)  | 
|
| 65315 | 229  | 
session.init_protocol_handler(handler)  | 
| 65313 | 230  | 
|
| 65317 | 231  | 
val session_result = Future.promise[Process_Result]  | 
| 65313 | 232  | 
|
233  | 
Isabelle_Process.start(session, options, logic = parent,  | 
|
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
234  | 
cwd = info.dir.file, env = env, sessions = Some(sessions), store = store,  | 
| 65313 | 235  | 
phase_changed =  | 
236  | 
            {
 | 
|
237  | 
              case Session.Ready => session.protocol_command("build_session", args_yxml)
 | 
|
| 65317 | 238  | 
case Session.Terminated(result) => session_result.fulfill(result)  | 
| 65313 | 239  | 
case _ =>  | 
240  | 
})  | 
|
241  | 
||
| 65317 | 242  | 
val result = session_result.join  | 
| 65313 | 243  | 
          handler.result_error.join match {
 | 
| 65317 | 244  | 
case "" => result  | 
245  | 
case msg =>  | 
|
246  | 
result.copy(  | 
|
247  | 
rc = result.rc max 1,  | 
|
248  | 
out_lines = result.out_lines ::: split_lines(Output.error_text(msg)))  | 
|
| 65313 | 249  | 
}  | 
| 65308 | 250  | 
}  | 
251  | 
        else {
 | 
|
252  | 
          val args_file = Isabelle_System.tmp_file("build")
 | 
|
253  | 
File.write(args_file, args_yxml)  | 
|
254  | 
||
255  | 
val eval =  | 
|
256  | 
            "Command_Line.tool0 (fn () => (" +
 | 
|
257  | 
"Build.build " + ML_Syntax.print_string0(File.standard_path(args_file)) +  | 
|
258  | 
(if (do_output) "; " + save_heap else "") + "));"  | 
|
| 64265 | 259  | 
|
| 65308 | 260  | 
val process =  | 
| 65360 | 261  | 
            if (Sessions.is_pure(name)) {
 | 
| 65312 | 262  | 
ML_Process(options, raw_ml_system = true, cwd = info.dir.file,  | 
| 65308 | 263  | 
args =  | 
264  | 
                  (for ((root, _) <- Thy_Header.ml_roots) yield List("--use", root)).flatten :::
 | 
|
265  | 
                  List("--eval", eval),
 | 
|
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
266  | 
env = env, sessions = Some(sessions), store = store,  | 
| 
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
267  | 
cleanup = () => args_file.delete)  | 
| 65308 | 268  | 
}  | 
269  | 
            else {
 | 
|
| 65312 | 270  | 
              ML_Process(options, parent, List("--eval", eval), cwd = info.dir.file,
 | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
271  | 
env = env, sessions = Some(sessions), store = store,  | 
| 
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
272  | 
cleanup = () => args_file.delete)  | 
| 65308 | 273  | 
}  | 
| 64265 | 274  | 
|
| 65308 | 275  | 
process.result(  | 
276  | 
progress_stdout = (line: String) =>  | 
|
277  | 
              Library.try_unprefix("\floading_theory = ", line) match {
 | 
|
278  | 
case Some(theory) => progress.theory(name, theory)  | 
|
279  | 
case None =>  | 
|
280  | 
},  | 
|
281  | 
progress_limit =  | 
|
| 65312 | 282  | 
              options.int("process_output_limit") match {
 | 
| 65308 | 283  | 
case 0 => None  | 
284  | 
case m => Some(m * 1000000L)  | 
|
285  | 
},  | 
|
286  | 
strict = false)  | 
|
287  | 
}  | 
|
| 50845 | 288  | 
}  | 
| 48674 | 289  | 
|
| 62572 | 290  | 
def terminate: Unit = future_result.cancel  | 
291  | 
def is_finished: Boolean = future_result.is_finished  | 
|
| 48674 | 292  | 
|
| 62569 | 293  | 
@volatile private var was_timeout = false  | 
| 56779 | 294  | 
private val timeout_request: Option[Event_Timer.Request] =  | 
295  | 
    {
 | 
|
| 62569 | 296  | 
if (info.timeout > Time.zero)  | 
297  | 
        Some(Event_Timer.request(Time.now() + info.timeout) { terminate; was_timeout = true })
 | 
|
| 48674 | 298  | 
else None  | 
| 56779 | 299  | 
}  | 
| 48674 | 300  | 
|
| 62400 | 301  | 
def join: Process_Result =  | 
| 50845 | 302  | 
    {
 | 
| 62572 | 303  | 
val result = future_result.join  | 
| 50845 | 304  | 
|
| 
62944
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
305  | 
if (result.ok)  | 
| 62633 | 306  | 
Present.finish(progress, store.browser_info, graph_file, info, name)  | 
| 61372 | 307  | 
|
| 59445 | 308  | 
graph_file.delete  | 
| 56779 | 309  | 
timeout_request.foreach(_.cancel)  | 
| 48674 | 310  | 
|
| 62572 | 311  | 
      if (result.interrupted) {
 | 
312  | 
        if (was_timeout) result.error(Output.error_text("Timeout")).was_timeout
 | 
|
313  | 
        else result.error(Output.error_text("Interrupt"))
 | 
|
| 
52063
 
fd533ac64390
timeout counts as regular error, with rc = 1 (cf. special Exn.Interrupt vs. regular TimeLimit.TimeOut in Isabelle/ML);
 
wenzelm 
parents: 
51987 
diff
changeset
 | 
314  | 
}  | 
| 62572 | 315  | 
else result  | 
| 48674 | 316  | 
}  | 
| 48364 | 317  | 
}  | 
318  | 
||
| 48424 | 319  | 
|
| 62631 | 320  | 
|
| 62641 | 321  | 
/** build with results **/  | 
| 48424 | 322  | 
|
| 63996 | 323  | 
class Results private[Build](results: Map[String, (Option[Process_Result], Sessions.Info)])  | 
| 62403 | 324  | 
  {
 | 
325  | 
def sessions: Set[String] = results.keySet  | 
|
| 
63082
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
326  | 
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
 | 
327  | 
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
 | 
328  | 
def info(name: String): Sessions.Info = results(name)._2  | 
| 65253 | 329  | 
val rc =  | 
330  | 
(0 /: results.iterator.map(  | 
|
331  | 
        { case (_, (Some(r), _)) => r.rc case (_, (None, _)) => 1 }))(_ max _)
 | 
|
| 62641 | 332  | 
def ok: Boolean = rc == 0  | 
| 62406 | 333  | 
|
334  | 
override def toString: String = rc.toString  | 
|
| 62403 | 335  | 
}  | 
336  | 
||
| 62641 | 337  | 
def build(  | 
| 
50404
 
898cac1dad5e
avoid startup within GUI thread -- it is only required later for dialog;
 
wenzelm 
parents: 
50367 
diff
changeset
 | 
338  | 
options: Options,  | 
| 64909 | 339  | 
progress: Progress = No_Progress,  | 
| 
48511
 
37999ee01156
remove old output heaps, to ensure that result is valid wrt. check_stamps;
 
wenzelm 
parents: 
48509 
diff
changeset
 | 
340  | 
build_heap: Boolean = false,  | 
| 48595 | 341  | 
clean_build: Boolean = false,  | 
| 56890 | 342  | 
dirs: List[Path] = Nil,  | 
343  | 
select_dirs: List[Path] = Nil,  | 
|
| 64265 | 344  | 
numa_shuffling: Boolean = false,  | 
| 48509 | 345  | 
max_jobs: Int = 1,  | 
| 48903 | 346  | 
list_files: Boolean = false,  | 
| 
59891
 
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
 
wenzelm 
parents: 
59811 
diff
changeset
 | 
347  | 
check_keywords: Set[String] = Set.empty,  | 
| 48509 | 348  | 
no_build: Boolean = false,  | 
349  | 
system_mode: Boolean = false,  | 
|
350  | 
verbose: Boolean = false,  | 
|
| 65308 | 351  | 
pide: Boolean = false,  | 
| 63224 | 352  | 
requirements: Boolean = false,  | 
353  | 
all_sessions: Boolean = false,  | 
|
354  | 
exclude_session_groups: List[String] = Nil,  | 
|
| 
59892
 
2a616319c171
added isabelle build option -x, to exclude sessions;
 
wenzelm 
parents: 
59891 
diff
changeset
 | 
355  | 
exclude_sessions: List[String] = Nil,  | 
| 63224 | 356  | 
session_groups: List[String] = Nil,  | 
| 65422 | 357  | 
sessions: List[String] = Nil,  | 
358  | 
selection: Sessions.Selection = Sessions.Selection.empty): Results =  | 
|
| 63224 | 359  | 
  {
 | 
360  | 
/* session selection and dependencies */  | 
|
| 51220 | 361  | 
|
| 62714 | 362  | 
    val build_options = options.int.update("completion_limit", 0).bool.update("ML_statistics", true)
 | 
| 65422 | 363  | 
|
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
364  | 
val full_sessions = Sessions.load(build_options, dirs, select_dirs)  | 
| 65422 | 365  | 
|
366  | 
val (selected, selected_sessions) =  | 
|
367  | 
full_sessions.selection(  | 
|
368  | 
Sessions.Selection(requirements, all_sessions, exclude_session_groups,  | 
|
369  | 
exclude_sessions, session_groups, sessions) + selection)  | 
|
370  | 
||
| 65251 | 371  | 
val deps =  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
372  | 
Sessions.deps(selected_sessions, progress = progress, inlined_files = true,  | 
| 65406 | 373  | 
verbose = verbose, list_files = list_files, check_keywords = check_keywords,  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
374  | 
global_theories = full_sessions.global_theories)  | 
| 48368 | 375  | 
|
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
376  | 
def sources_stamp(name: String): List[String] =  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
377  | 
(selected_sessions(name).meta_digest :: deps.sources(name)).map(_.toString).sorted  | 
| 
48504
 
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
 
wenzelm 
parents: 
48494 
diff
changeset
 | 
378  | 
|
| 51220 | 379  | 
|
380  | 
/* main build process */  | 
|
381  | 
||
| 65289 | 382  | 
val store = Sessions.store(system_mode)  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
383  | 
val queue = Queue(selected_sessions, store)  | 
| 65289 | 384  | 
|
| 62632 | 385  | 
store.prepare_output()  | 
| 48373 | 386  | 
|
| 48595 | 387  | 
// optional cleanup  | 
388  | 
    if (clean_build) {
 | 
|
| 
65420
 
695d4e22345a
support for static session imports, without affect build hierarchy;
 
wenzelm 
parents: 
65419 
diff
changeset
 | 
389  | 
      for (name <- full_sessions.build_descendants(selected)) {
 | 
| 48595 | 390  | 
val files =  | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
391  | 
List(Path.basic(name), store.database(name), store.log(name), store.log_gz(name)).  | 
| 62632 | 392  | 
map(store.output_dir + _).filter(_.is_file)  | 
| 59319 | 393  | 
        if (files.nonEmpty) progress.echo("Cleaning " + name + " ...")
 | 
| 50366 | 394  | 
if (!files.forall(p => p.file.delete)) progress.echo(name + " FAILED to delete")  | 
| 48595 | 395  | 
}  | 
396  | 
}  | 
|
397  | 
||
| 48425 | 398  | 
// scheduler loop  | 
| 
63082
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
399  | 
case class Result(  | 
| 
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
400  | 
current: Boolean, heap_stamp: Option[String],  | 
| 
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
401  | 
process: Option[Process_Result], info: Sessions.Info)  | 
| 62402 | 402  | 
    {
 | 
403  | 
def ok: Boolean =  | 
|
404  | 
        process match {
 | 
|
405  | 
case None => false  | 
|
406  | 
case Some(res) => res.rc == 0  | 
|
407  | 
}  | 
|
408  | 
}  | 
|
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
409  | 
|
| 
56837
 
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
 
wenzelm 
parents: 
56831 
diff
changeset
 | 
410  | 
def sleep()  | 
| 
 
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
 
wenzelm 
parents: 
56831 
diff
changeset
 | 
411  | 
    {
 | 
| 
 
5a598f1eecfd
more robust interrupt handling for Scala_Console, which uses JVM Thread.interrupt instead of POSIX SIGINT;
 
wenzelm 
parents: 
56831 
diff
changeset
 | 
412  | 
      try { Thread.sleep(500) }
 | 
| 56861 | 413  | 
      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
 | 
414  | 
}  | 
| 50366 | 415  | 
|
| 64265 | 416  | 
val numa_nodes = new NUMA.Nodes(numa_shuffling)  | 
417  | 
||
| 48425 | 418  | 
@tailrec def loop(  | 
| 
48676
 
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
 
wenzelm 
parents: 
48675 
diff
changeset
 | 
419  | 
pending: Queue,  | 
| 62628 | 420  | 
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
 | 
421  | 
results: Map[String, Result]): Map[String, Result] =  | 
| 48425 | 422  | 
    {
 | 
| 64265 | 423  | 
def used_node(i: Int): Boolean =  | 
424  | 
running.iterator.exists(  | 
|
425  | 
          { case (_, (_, job)) => job.numa_node.isDefined && job.numa_node.get == i })
 | 
|
426  | 
||
| 48425 | 427  | 
if (pending.is_empty) results  | 
| 51253 | 428  | 
      else {
 | 
429  | 
if (progress.stopped)  | 
|
430  | 
for ((_, (_, job)) <- running) job.terminate  | 
|
431  | 
||
| 48674 | 432  | 
        running.find({ case (_, (_, job)) => job.is_finished }) match {
 | 
| 62628 | 433  | 
case Some((name, (input_heaps, job))) =>  | 
| 50367 | 434  | 
            //{{{ finish job
 | 
| 48424 | 435  | 
|
| 62401 | 436  | 
val process_result = job.join  | 
| 62573 | 437  | 
process_result.err_lines.foreach(progress.echo(_))  | 
438  | 
if (process_result.ok)  | 
|
439  | 
              progress.echo("Finished " + name + " (" + process_result.timing.message_resources + ")")
 | 
|
| 48373 | 440  | 
|
| 65294 | 441  | 
            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
 | 
442  | 
val process_result_tail =  | 
| 
 
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
 
wenzelm 
parents: 
62403 
diff
changeset
 | 
443  | 
            {
 | 
| 
62409
 
e391528eff3b
proper option process_output_tail, more generous default;
 
wenzelm 
parents: 
62406 
diff
changeset
 | 
444  | 
              val tail = job.info.options.int("process_output_tail")
 | 
| 62632 | 445  | 
process_result.copy(  | 
446  | 
out_lines =  | 
|
| 65278 | 447  | 
"(see also " + (store.output_dir + store.log(name)).file.toString + ")" ::  | 
| 65294 | 448  | 
(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
 | 
449  | 
}  | 
| 
 
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
 
wenzelm 
parents: 
62403 
diff
changeset
 | 
450  | 
|
| 62636 | 451  | 
val heap_stamp =  | 
| 62401 | 452  | 
              if (process_result.ok) {
 | 
| 65278 | 453  | 
(store.output_dir + store.log(name)).file.delete  | 
| 62636 | 454  | 
val heap_stamp =  | 
| 
62704
 
478b49f0d726
proper SHA1 digest as annex to heap file: Poly/ML reads precise segment length;
 
wenzelm 
parents: 
62643 
diff
changeset
 | 
455  | 
for (path <- job.output_path if path.is_file)  | 
| 
 
478b49f0d726
proper SHA1 digest as annex to heap file: Poly/ML reads precise segment length;
 
wenzelm 
parents: 
62643 
diff
changeset
 | 
456  | 
yield Sessions.write_heap_digest(path)  | 
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
457  | 
|
| 65294 | 458  | 
File.write_gzip(store.output_dir + store.log_gz(name), terminate_lines(log_lines))  | 
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
459  | 
|
| 62636 | 460  | 
heap_stamp  | 
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
461  | 
}  | 
| 
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
462  | 
              else {
 | 
| 62632 | 463  | 
(store.output_dir + Path.basic(name)).file.delete  | 
| 65278 | 464  | 
(store.output_dir + store.log_gz(name)).file.delete  | 
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
465  | 
|
| 65294 | 466  | 
File.write(store.output_dir + store.log(name), terminate_lines(log_lines))  | 
| 50366 | 467  | 
progress.echo(name + " FAILED")  | 
| 
62404
 
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
 
wenzelm 
parents: 
62403 
diff
changeset
 | 
468  | 
if (!process_result.interrupted) progress.echo(process_result_tail.out)  | 
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
469  | 
|
| 62636 | 470  | 
None  | 
| 
48639
 
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
 
wenzelm 
parents: 
48626 
diff
changeset
 | 
471  | 
}  | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
472  | 
|
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
473  | 
// write database  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
474  | 
            {
 | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
475  | 
val database = store.output_dir + store.database(name)  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
476  | 
database.file.delete  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
477  | 
|
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
478  | 
using(SQLite.open_database(database))(db =>  | 
| 
65318
 
342efc382558
eliminated somewhat redundant inlined name (despite a7aa17a1f721);
 
wenzelm 
parents: 
65317 
diff
changeset
 | 
479  | 
store.write_session_info(db, name,  | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
480  | 
build_log =  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
481  | 
Build_Log.Log_File(name, process_result.out_lines).  | 
| 
65318
 
342efc382558
eliminated somewhat redundant inlined name (despite a7aa17a1f721);
 
wenzelm 
parents: 
65317 
diff
changeset
 | 
482  | 
parse_session_info(  | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
483  | 
command_timings = true, ml_statistics = true, task_statistics = true),  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
484  | 
build =  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
485  | 
Session_Info(sources_stamp(name), input_heaps, heap_stamp, process_result.rc)))  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
486  | 
}  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
487  | 
|
| 
50707
 
5b2bf7611662
maintain session index on Scala side, for more determistic results;
 
wenzelm 
parents: 
50686 
diff
changeset
 | 
488  | 
loop(pending - name, running - name,  | 
| 
63082
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
489  | 
results + (name -> Result(false, heap_stamp, Some(process_result_tail), job.info)))  | 
| 50367 | 490  | 
//}}}  | 
| 60215 | 491  | 
case None if running.size < (max_jobs max 1) =>  | 
| 50367 | 492  | 
            //{{{ check/start next job
 | 
| 48547 | 493  | 
            pending.dequeue(running.isDefinedAt(_)) match {
 | 
494  | 
case Some((name, info)) =>  | 
|
| 
65420
 
695d4e22345a
support for static session imports, without affect build hierarchy;
 
wenzelm 
parents: 
65419 
diff
changeset
 | 
495  | 
val ancestor_results = selected_sessions.build_ancestors(name).map(results(_))  | 
| 62636 | 496  | 
val ancestor_heaps = ancestor_results.flatMap(_.heap_stamp)  | 
| 62628 | 497  | 
|
| 65360 | 498  | 
val do_output = build_heap || Sessions.is_pure(name) || queue.is_inner(name)  | 
| 48547 | 499  | 
|
| 62636 | 500  | 
val (current, heap_stamp) =  | 
| 48547 | 501  | 
                {
 | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
502  | 
                  store.find_database_heap(name) match {
 | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
503  | 
case Some((database, heap_stamp)) =>  | 
| 
65320
 
52861eebf58d
access table via session_name: db may in principle contain multiple entries;
 
wenzelm 
parents: 
65318 
diff
changeset
 | 
504  | 
                      using(SQLite.open_database(database))(store.read_build(_, name)) match {
 | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
505  | 
case Some(build) =>  | 
| 62628 | 506  | 
val current =  | 
| 
65291
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
507  | 
build.sources == sources_stamp(name) &&  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
508  | 
build.input_heaps == ancestor_heaps &&  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
509  | 
build.output_heap == heap_stamp &&  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
510  | 
!(do_output && heap_stamp.isEmpty) &&  | 
| 
 
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
 
wenzelm 
parents: 
65289 
diff
changeset
 | 
511  | 
build.return_code == 0  | 
| 62636 | 512  | 
(current, heap_stamp)  | 
513  | 
case None => (false, None)  | 
|
| 48547 | 514  | 
}  | 
| 62636 | 515  | 
case None => (false, None)  | 
| 
48504
 
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
 
wenzelm 
parents: 
48494 
diff
changeset
 | 
516  | 
}  | 
| 48547 | 517  | 
}  | 
| 62628 | 518  | 
val all_current = current && ancestor_results.forall(_.current)  | 
| 
48528
 
784c6f63d79c
proper all_current, which regards parent status as well;
 
wenzelm 
parents: 
48511 
diff
changeset
 | 
519  | 
|
| 48547 | 520  | 
if (all_current)  | 
| 62402 | 521  | 
loop(pending - name, running,  | 
| 
63082
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
522  | 
results + (name -> Result(true, heap_stamp, Some(Process_Result(0)), info)))  | 
| 
48678
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
523  | 
                else if (no_build) {
 | 
| 50366 | 524  | 
                  if (verbose) progress.echo("Skipping " + name + " ...")
 | 
| 62402 | 525  | 
loop(pending - name, running,  | 
| 
63082
 
6af03422535a
expose Sessions.Info in Build.Results
 
Lars Hupel <lars.hupel@mytum.de> 
parents: 
62946 
diff
changeset
 | 
526  | 
results + (name -> Result(false, heap_stamp, Some(Process_Result(1)), info)))  | 
| 
48678
 
ff27af15530c
queue ordering by descending outdegree and timeout;
 
wenzelm 
parents: 
48676 
diff
changeset
 | 
527  | 
}  | 
| 62628 | 528  | 
                else if (ancestor_results.forall(_.ok) && !progress.stopped) {
 | 
| 64265 | 529  | 
val numa_node = numa_nodes.next(used_node(_))  | 
| 50366 | 530  | 
progress.echo((if (do_output) "Building " else "Running ") + name + " ...")  | 
| 51220 | 531  | 
val job =  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
532  | 
new Job(progress, name, info, selected_sessions, deps, store, do_output,  | 
| 
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
533  | 
verbose, pide, numa_node, queue.command_timings(name))  | 
| 62628 | 534  | 
loop(pending, running + (name -> (ancestor_heaps, job)), results)  | 
| 48547 | 535  | 
}  | 
536  | 
                else {
 | 
|
| 50366 | 537  | 
progress.echo(name + " CANCELLED")  | 
| 65253 | 538  | 
loop(pending - name, running,  | 
539  | 
results + (name -> Result(false, heap_stamp, None, info)))  | 
|
| 48547 | 540  | 
}  | 
541  | 
case None => sleep(); loop(pending, running, results)  | 
|
| 48425 | 542  | 
}  | 
| 50367 | 543  | 
///}}}  | 
| 48425 | 544  | 
case None => sleep(); loop(pending, running, results)  | 
| 48373 | 545  | 
}  | 
| 51253 | 546  | 
}  | 
| 48425 | 547  | 
}  | 
548  | 
||
| 51220 | 549  | 
|
550  | 
/* build results */  | 
|
551  | 
||
| 62641 | 552  | 
val results0 =  | 
| 48583 | 553  | 
      if (deps.is_empty) {
 | 
| 
56782
 
433cf57550fa
more systematic Isabelle output, like in classic Isabelle/ML (without markup);
 
wenzelm 
parents: 
56780 
diff
changeset
 | 
554  | 
        progress.echo(Output.warning_text("Nothing to build"))
 | 
| 
50707
 
5b2bf7611662
maintain session index on Scala side, for more determistic results;
 
wenzelm 
parents: 
50686 
diff
changeset
 | 
555  | 
Map.empty[String, Result]  | 
| 48583 | 556  | 
}  | 
557  | 
else loop(queue, Map.empty, Map.empty)  | 
|
558  | 
||
| 62641 | 559  | 
val results =  | 
| 64265 | 560  | 
new Results(  | 
561  | 
(for ((name, result) <- results0.iterator)  | 
|
562  | 
yield (name, (result.process, result.info))).toMap)  | 
|
| 62641 | 563  | 
|
564  | 
    if (results.rc != 0 && (verbose || !no_build)) {
 | 
|
565  | 
val unfinished =  | 
|
566  | 
        (for {
 | 
|
567  | 
name <- results.sessions.iterator  | 
|
568  | 
if !results(name).ok  | 
|
569  | 
} yield name).toList.sorted  | 
|
570  | 
      progress.echo("Unfinished session(s): " + commas(unfinished))
 | 
|
571  | 
}  | 
|
572  | 
||
| 
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
 | 
573  | 
|
| 
 
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
 | 
574  | 
/* 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
 | 
575  | 
|
| 
 
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
 | 
576  | 
    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
 | 
577  | 
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
 | 
578  | 
        (for {
 | 
| 62641 | 579  | 
(name, result) <- results0.iterator  | 
| 
62944
 
3ee643c5ed00
more standard session build process, including browser_info;
 
wenzelm 
parents: 
62902 
diff
changeset
 | 
580  | 
if result.ok  | 
| 
65415
 
8cd54b18b68b
clarified signature: tree structure is not essential;
 
wenzelm 
parents: 
65406 
diff
changeset
 | 
581  | 
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
 | 
582  | 
          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
 | 
583  | 
} 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
 | 
584  | 
            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
 | 
585  | 
|
| 
 
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
 | 
586  | 
for ((chapter, entries) <- browser_chapters)  | 
| 62632 | 587  | 
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
 | 
588  | 
|
| 62632 | 589  | 
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
 | 
590  | 
}  | 
| 
 
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
 | 
591  | 
|
| 62641 | 592  | 
results  | 
| 48341 | 593  | 
}  | 
594  | 
||
595  | 
||
| 62833 | 596  | 
/* Isabelle tool wrapper */  | 
| 48341 | 597  | 
|
| 62833 | 598  | 
  val isabelle_tool = Isabelle_Tool("build", "build and manage Isabelle sessions", args =>
 | 
| 48341 | 599  | 
  {
 | 
| 62833 | 600  | 
    val build_options = Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS"))
 | 
| 62590 | 601  | 
|
| 62833 | 602  | 
var select_dirs: List[Path] = Nil  | 
| 64265 | 603  | 
var numa_shuffling = false  | 
| 65308 | 604  | 
var pide = false  | 
| 62833 | 605  | 
var requirements = false  | 
606  | 
var exclude_session_groups: List[String] = Nil  | 
|
607  | 
var all_sessions = false  | 
|
608  | 
var build_heap = false  | 
|
609  | 
var clean_build = false  | 
|
610  | 
var dirs: List[Path] = Nil  | 
|
611  | 
var session_groups: List[String] = Nil  | 
|
612  | 
var max_jobs = 1  | 
|
613  | 
var check_keywords: Set[String] = Set.empty  | 
|
614  | 
var list_files = false  | 
|
615  | 
var no_build = false  | 
|
616  | 
var options = (Options.init() /: build_options)(_ + _)  | 
|
617  | 
var system_mode = false  | 
|
618  | 
var verbose = false  | 
|
619  | 
var exclude_sessions: List[String] = Nil  | 
|
| 62590 | 620  | 
|
| 62833 | 621  | 
    val getopts = Getopts("""
 | 
| 62590 | 622  | 
Usage: isabelle build [OPTIONS] [SESSIONS ...]  | 
623  | 
||
624  | 
Options are:  | 
|
625  | 
-D DIR include session directory and select its sessions  | 
|
| 64265 | 626  | 
-N cyclic shuffling of NUMA CPU nodes (performance tuning)  | 
| 65308 | 627  | 
-P build via PIDE protocol  | 
| 62590 | 628  | 
-R operate on requirements of selected sessions  | 
629  | 
-X NAME exclude sessions from group NAME and all descendants  | 
|
630  | 
-a select all sessions  | 
|
631  | 
-b build heap images  | 
|
632  | 
-c clean build  | 
|
633  | 
-d DIR include session directory  | 
|
634  | 
-g NAME select session group NAME  | 
|
635  | 
-j INT maximum number of parallel jobs (default 1)  | 
|
636  | 
-k KEYWORD check theory sources for conflicts with proposed keywords  | 
|
637  | 
-l list session source files  | 
|
638  | 
-n no build -- test dependencies only  | 
|
639  | 
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME)  | 
|
640  | 
-s system build mode: produce output in ISABELLE_HOME  | 
|
641  | 
-v verbose  | 
|
642  | 
-x NAME exclude session NAME and all descendants  | 
|
643  | 
||
| 62596 | 644  | 
Build and manage Isabelle sessions, depending on implicit settings:  | 
645  | 
||
| 64455 | 646  | 
""" + Library.prefix_lines("  ", Build_Log.Settings.show()) + "\n",
 | 
| 62833 | 647  | 
"D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))),  | 
| 64265 | 648  | 
"N" -> (_ => numa_shuffling = true),  | 
| 65308 | 649  | 
"P" -> (_ => pide = true),  | 
| 62833 | 650  | 
"R" -> (_ => requirements = true),  | 
651  | 
"X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)),  | 
|
652  | 
"a" -> (_ => all_sessions = true),  | 
|
653  | 
"b" -> (_ => build_heap = true),  | 
|
654  | 
"c" -> (_ => clean_build = true),  | 
|
655  | 
"d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))),  | 
|
656  | 
"g:" -> (arg => session_groups = session_groups ::: List(arg)),  | 
|
| 63805 | 657  | 
"j:" -> (arg => max_jobs = Value.Int.parse(arg)),  | 
| 62833 | 658  | 
"k:" -> (arg => check_keywords = check_keywords + arg),  | 
659  | 
"l" -> (_ => list_files = true),  | 
|
660  | 
"n" -> (_ => no_build = true),  | 
|
661  | 
"o:" -> (arg => options = options + arg),  | 
|
662  | 
"s" -> (_ => system_mode = true),  | 
|
663  | 
"v" -> (_ => verbose = true),  | 
|
664  | 
"x:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg)))  | 
|
| 62590 | 665  | 
|
| 62833 | 666  | 
val sessions = getopts(args)  | 
| 62590 | 667  | 
|
| 64115 | 668  | 
val progress = new Console_Progress(verbose = verbose)  | 
| 62590 | 669  | 
|
| 64140 | 670  | 
val start_date = Date.now()  | 
671  | 
||
| 62833 | 672  | 
    if (verbose) {
 | 
673  | 
progress.echo(  | 
|
| 64155 | 674  | 
"Started at " + Build_Log.print_date(start_date) +  | 
| 64140 | 675  | 
          " (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + Isabelle_System.hostname() +")")
 | 
| 64081 | 676  | 
progress.echo(Build_Log.Settings.show() + "\n")  | 
| 62833 | 677  | 
}  | 
| 62590 | 678  | 
|
| 62833 | 679  | 
val results =  | 
680  | 
      progress.interrupt_handler {
 | 
|
| 63224 | 681  | 
build(options, progress,  | 
682  | 
build_heap = build_heap,  | 
|
683  | 
clean_build = clean_build,  | 
|
684  | 
dirs = dirs,  | 
|
685  | 
select_dirs = select_dirs,  | 
|
| 64265 | 686  | 
numa_shuffling = NUMA.enabled_warning(numa_shuffling),  | 
| 63224 | 687  | 
max_jobs = max_jobs,  | 
688  | 
list_files = list_files,  | 
|
689  | 
check_keywords = check_keywords,  | 
|
690  | 
no_build = no_build,  | 
|
691  | 
system_mode = system_mode,  | 
|
692  | 
verbose = verbose,  | 
|
| 65308 | 693  | 
pide = pide,  | 
| 63224 | 694  | 
requirements = requirements,  | 
695  | 
all_sessions = all_sessions,  | 
|
696  | 
exclude_session_groups = exclude_session_groups,  | 
|
697  | 
exclude_sessions = exclude_sessions,  | 
|
698  | 
session_groups = session_groups,  | 
|
699  | 
sessions = sessions)  | 
|
| 62833 | 700  | 
}  | 
| 64140 | 701  | 
val end_date = Date.now()  | 
702  | 
val elapsed_time = end_date.time - start_date.time  | 
|
| 62590 | 703  | 
|
| 62833 | 704  | 
    if (verbose) {
 | 
| 64155 | 705  | 
      progress.echo("\nFinished at " + Build_Log.print_date(end_date))
 | 
| 62833 | 706  | 
}  | 
| 62590 | 707  | 
|
| 62833 | 708  | 
val total_timing =  | 
709  | 
(Timing.zero /: results.sessions.iterator.map(a => results(a).timing))(_ + _).  | 
|
710  | 
copy(elapsed = elapsed_time)  | 
|
711  | 
progress.echo(total_timing.message_resources)  | 
|
| 62590 | 712  | 
|
| 62833 | 713  | 
sys.exit(results.rc)  | 
714  | 
})  | 
|
| 48276 | 715  | 
}  |