author | wenzelm |
Sun, 21 Aug 2022 13:16:44 +0200 | |
changeset 75948 | f0a8b7ae9192 |
parent 75947 | 45f08f13354a |
child 75967 | ff164add75cd |
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 |
||
73364 | 11 |
import scala.collection.immutable.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 |
|
75393 | 15 |
object Build { |
62631 | 16 |
/** auxiliary **/ |
48424 | 17 |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
18 |
/* persistent build info */ |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
19 |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
20 |
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
|
21 |
sources: String, |
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
22 |
input_heaps: List[String], |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
23 |
output_heap: Option[String], |
75393 | 24 |
return_code: Int |
25 |
) { |
|
66747 | 26 |
def ok: Boolean = return_code == 0 |
27 |
} |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
28 |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
29 |
|
65289 | 30 |
/* 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
|
31 |
|
75393 | 32 |
private object Queue { |
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
33 |
type Timings = (List[Properties.T], Double) |
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
34 |
|
75393 | 35 |
def load_timings(progress: Progress, store: Sessions.Store, session_name: String): Timings = { |
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
36 |
val no_timings: Timings = (Nil, 0.0) |
65289 | 37 |
|
72634
5cea0993ee4f
clarified access to single database server vs. collection of database files;
wenzelm
parents:
72624
diff
changeset
|
38 |
store.try_open_database(session_name) match { |
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
39 |
case None => no_timings |
68214 | 40 |
case Some(db) => |
75393 | 41 |
def ignore_error(msg: String) = { |
75793 | 42 |
progress.echo_warning("Ignoring bad database " + db + |
43 |
" for session " + quote(session_name) + (if (msg == "") "" else ":\n" + msg)) |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
44 |
no_timings |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
45 |
} |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
46 |
try { |
71669 | 47 |
val command_timings = store.read_command_timings(db, session_name) |
68214 | 48 |
val session_timing = |
71669 | 49 |
store.read_session_timing(db, session_name) match { |
68214 | 50 |
case Markup.Elapsed(t) => t |
51 |
case _ => 0.0 |
|
52 |
} |
|
53 |
(command_timings, session_timing) |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
54 |
} |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
55 |
catch { |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
56 |
case ERROR(msg) => ignore_error(msg) |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
57 |
case exn: java.lang.Error => ignore_error(Exn.message(exn)) |
75783 | 58 |
case _: XML.Error => ignore_error("XML.Error") |
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
59 |
} |
73367 | 60 |
finally { db.close() } |
65289 | 61 |
} |
62 |
} |
|
63 |
||
75393 | 64 |
def make_session_timing( |
65 |
sessions_structure: Sessions.Structure, |
|
66 |
timing: Map[String, Double] |
|
67 |
) : Map[String, Double] = { |
|
68731 | 68 |
val maximals = sessions_structure.build_graph.maximals.toSet |
75393 | 69 |
def desc_timing(session_name: String): Double = { |
71669 | 70 |
if (maximals.contains(session_name)) timing(session_name) |
68487 | 71 |
else { |
71669 | 72 |
val descendants = sessions_structure.build_descendants(List(session_name)).toSet |
68731 | 73 |
val g = sessions_structure.build_graph.restrict(descendants) |
75394 | 74 |
(0.0 :: g.maximals.flatMap { desc => |
68487 | 75 |
val ps = g.all_preds(List(desc)) |
71895 | 76 |
if (ps.exists(p => !timing.isDefinedAt(p))) None |
68487 | 77 |
else Some(ps.map(timing(_)).sum) |
75394 | 78 |
}).max |
68487 | 79 |
} |
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
80 |
} |
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
81 |
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
|
82 |
} |
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
83 |
|
75393 | 84 |
def apply( |
85 |
progress: Progress, |
|
86 |
sessions_structure: Sessions.Structure, |
|
87 |
store: Sessions.Store |
|
88 |
) : Queue = { |
|
68731 | 89 |
val graph = sessions_structure.build_graph |
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
90 |
val names = graph.keys |
51220 | 91 |
|
65831 | 92 |
val timings = names.map(name => (name, load_timings(progress, store, name))) |
51220 | 93 |
val command_timings = |
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
94 |
timings.map({ case (name, (ts, _)) => (name, ts) }).toMap.withDefaultValue(Nil) |
51220 | 95 |
val session_timing = |
68731 | 96 |
make_session_timing(sessions_structure, |
97 |
timings.map({ case (name, (_, t)) => (name, t) }).toMap) |
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
98 |
|
75393 | 99 |
object Ordering extends scala.math.Ordering[String] { |
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
100 |
def compare(name1: String, name2: String): Int = |
73365 | 101 |
session_timing(name2) compare session_timing(name1) match { |
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
102 |
case 0 => |
68731 | 103 |
sessions_structure(name2).timeout compare sessions_structure(name1).timeout match { |
68486
6984a55f3cba
clarified queue ordering: take session descendants into account, notably for "slow" AFP sessions;
wenzelm
parents:
68331
diff
changeset
|
104 |
case 0 => name1 compare name2 |
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
105 |
case ord => ord |
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
106 |
} |
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
107 |
case ord => ord |
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
108 |
} |
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
109 |
} |
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
110 |
|
65415
8cd54b18b68b
clarified signature: tree structure is not essential;
wenzelm
parents:
65406
diff
changeset
|
111 |
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
|
112 |
} |
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
113 |
} |
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
114 |
|
65314 | 115 |
private class Queue( |
62631 | 116 |
graph: Graph[String, Sessions.Info], |
51220 | 117 |
order: SortedSet[String], |
75393 | 118 |
val command_timings: String => List[Properties.T] |
119 |
) { |
|
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
120 |
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
|
121 |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
122 |
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
|
123 |
|
51227
88c96e836ed6
prefer comparison of session timing, if this is known already;
wenzelm
parents:
51223
diff
changeset
|
124 |
def - (name: String): Queue = |
73365 | 125 |
new Queue(graph.del_node(name), order - name, command_timings) |
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
126 |
|
75393 | 127 |
def dequeue(skip: String => Boolean): Option[(String, Sessions.Info)] = { |
73365 | 128 |
val it = order.iterator.dropWhile(name => skip(name) || !graph.is_minimal(name)) |
73344 | 129 |
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
|
130 |
else None |
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 |
|
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
134 |
|
62631 | 135 |
|
62641 | 136 |
/** build with results **/ |
48424 | 137 |
|
75393 | 138 |
class Results private[Build](results: Map[String, (Option[Process_Result], Sessions.Info)]) { |
62403 | 139 |
def sessions: Set[String] = results.keySet |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
140 |
def infos: List[Sessions.Info] = results.values.map(_._2).toList |
63082
6af03422535a
expose Sessions.Info in Build.Results
Lars Hupel <lars.hupel@mytum.de>
parents:
62946
diff
changeset
|
141 |
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
|
142 |
def apply(name: String): Process_Result = results(name)._1.getOrElse(Process_Result(1)) |
74701
2bc24136bdeb
clarified order: prefer bottom-up construction of partial content;
wenzelm
parents:
74700
diff
changeset
|
143 |
def get_info(name: String): Option[Sessions.Info] = results.get(name).map(_._2) |
2bc24136bdeb
clarified order: prefer bottom-up construction of partial content;
wenzelm
parents:
74700
diff
changeset
|
144 |
def info(name: String): Sessions.Info = get_info(name).get |
71601 | 145 |
val rc: Int = |
73359 | 146 |
results.iterator.map({ case (_, (Some(r), _)) => r.rc case (_, (None, _)) => 1 }). |
74306 | 147 |
foldLeft(Process_Result.RC.ok)(_ max _) |
148 |
def ok: Boolean = rc == Process_Result.RC.ok |
|
62406 | 149 |
|
150 |
override def toString: String = rc.toString |
|
62403 | 151 |
} |
152 |
||
72021 | 153 |
def session_finished(session_name: String, process_result: Process_Result): String = |
154 |
"Finished " + session_name + " (" + process_result.timing.message_resources + ")" |
|
72013 | 155 |
|
75393 | 156 |
def session_timing(session_name: String, build_log: Build_Log.Session_Info): String = { |
72021 | 157 |
val props = build_log.session_timing |
158 |
val threads = Markup.Session_Timing.Threads.unapply(props) getOrElse 1 |
|
74782 | 159 |
val timing = Markup.Timing_Properties.get(props) |
72015 | 160 |
"Timing " + session_name + " (" + threads + " threads, " + timing.message_factor + ")" |
72021 | 161 |
} |
72018 | 162 |
|
62641 | 163 |
def build( |
50404
898cac1dad5e
avoid startup within GUI thread -- it is only required later for dialog;
wenzelm
parents:
50367
diff
changeset
|
164 |
options: Options, |
71981 | 165 |
selection: Sessions.Selection = Sessions.Selection.empty, |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
166 |
browser_info: Browser_Info.Config = Browser_Info.Config.none, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
167 |
progress: Progress = new Progress, |
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
168 |
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
|
169 |
build_heap: Boolean = false, |
48595 | 170 |
clean_build: Boolean = false, |
56890 | 171 |
dirs: List[Path] = Nil, |
172 |
select_dirs: List[Path] = Nil, |
|
66968
9991671c98aa
allow to augment session context via explicit session infos;
wenzelm
parents:
66962
diff
changeset
|
173 |
infos: List[Sessions.Info] = Nil, |
64265 | 174 |
numa_shuffling: Boolean = false, |
48509 | 175 |
max_jobs: Int = 1, |
48903 | 176 |
list_files: Boolean = false, |
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59811
diff
changeset
|
177 |
check_keywords: Set[String] = Set.empty, |
66841 | 178 |
fresh_build: Boolean = false, |
48509 | 179 |
no_build: Boolean = false, |
66745 | 180 |
soft_build: Boolean = false, |
48509 | 181 |
verbose: Boolean = false, |
73805
b73777a0c076
allow build session setup, e.g. for protocol handlers;
wenzelm
parents:
73804
diff
changeset
|
182 |
export_files: Boolean = false, |
75393 | 183 |
session_setup: (String, Session) => Unit = (_, _) => () |
184 |
): Results = { |
|
71677 | 185 |
val build_options = |
71679
eeaa4021f080
proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents:
71677
diff
changeset
|
186 |
options + |
eeaa4021f080
proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents:
71677
diff
changeset
|
187 |
"completion_limit=0" + |
eeaa4021f080
proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents:
71677
diff
changeset
|
188 |
"editor_tracing_messages=0" + |
72728
caa182bdab7a
clarified options: batch-build has pide_reports disabled by default (requires significant resources);
wenzelm
parents:
72693
diff
changeset
|
189 |
("pide_reports=" + options.bool("build_pide_reports")) |
51220 | 190 |
|
69854
cc0b3e177b49
system option "system_heaps" supersedes various command-line options for "system build mode";
wenzelm
parents:
69811
diff
changeset
|
191 |
val store = Sessions.store(build_options) |
66745 | 192 |
|
69369
6ecc85955e04
prefer "Isabelle DejaVu Sans", even for headless batch-build (session_graph.pdf);
wenzelm
parents:
68957
diff
changeset
|
193 |
Isabelle_Fonts.init() |
6ecc85955e04
prefer "Isabelle DejaVu Sans", even for headless batch-build (session_graph.pdf);
wenzelm
parents:
68957
diff
changeset
|
194 |
|
66745 | 195 |
|
196 |
/* session selection and dependencies */ |
|
65422 | 197 |
|
66961 | 198 |
val full_sessions = |
67026 | 199 |
Sessions.load_structure(build_options, dirs = dirs, select_dirs = select_dirs, infos = infos) |
65422 | 200 |
|
73012
238ddf525da4
clarified HTML presentation, e.g. avoid bulky jobs like HOL or HOL-Analysis in applications;
wenzelm
parents:
72993
diff
changeset
|
201 |
val full_sessions_selection = full_sessions.imports_selection(selection) |
74808 | 202 |
val full_sessions_selected = full_sessions_selection.toSet |
73012
238ddf525da4
clarified HTML presentation, e.g. avoid bulky jobs like HOL or HOL-Analysis in applications;
wenzelm
parents:
72993
diff
changeset
|
203 |
|
75393 | 204 |
def sources_stamp(deps: Sessions.Deps, session_name: String): String = { |
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
|
205 |
val digests = |
71669 | 206 |
full_sessions(session_name).meta_digest :: |
75741 | 207 |
deps.session_sources(session_name) ::: |
71669 | 208 |
deps.imported_sources(session_name) |
72654 | 209 |
SHA1.digest_set(digests).toString |
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
|
210 |
} |
66745 | 211 |
|
75948 | 212 |
val build_deps = { |
66745 | 213 |
val deps0 = |
71896
ce06d6456cc8
clarified signature --- fit within limit of 22 arguments;
wenzelm
parents:
71895
diff
changeset
|
214 |
Sessions.deps(full_sessions.selection(selection), |
66962
e1bde71bace6
clarified signature: global_theories is always required;
wenzelm
parents:
66961
diff
changeset
|
215 |
progress = progress, inlined_files = true, verbose = verbose, |
e1bde71bace6
clarified signature: global_theories is always required;
wenzelm
parents:
66961
diff
changeset
|
216 |
list_files = list_files, check_keywords = check_keywords).check_errors |
66745 | 217 |
|
66841 | 218 |
if (soft_build && !fresh_build) { |
66745 | 219 |
val outdated = |
68204 | 220 |
deps0.sessions_structure.build_topological_order.flatMap(name => |
72634
5cea0993ee4f
clarified access to single database server vs. collection of database files;
wenzelm
parents:
72624
diff
changeset
|
221 |
store.try_open_database(name) match { |
68214 | 222 |
case Some(db) => |
68216 | 223 |
using(db)(store.read_build(_, name)) match { |
66745 | 224 |
case Some(build) |
66747 | 225 |
if build.ok && build.sources == sources_stamp(deps0, name) => None |
66745 | 226 |
case _ => Some(name) |
227 |
} |
|
228 |
case None => Some(name) |
|
229 |
}) |
|
68204 | 230 |
|
231 |
Sessions.deps(full_sessions.selection(Sessions.Selection(sessions = outdated)), |
|
70671
cb1776c8e216
clarified signature: retain global session information, unaffected by later restriction;
wenzelm
parents:
70509
diff
changeset
|
232 |
progress = progress, inlined_files = true).check_errors |
66745 | 233 |
} |
68204 | 234 |
else deps0 |
66745 | 235 |
} |
236 |
||
75948 | 237 |
val build_sessions = build_deps.sessions_structure |
238 |
||
74800 | 239 |
val presentation_sessions = |
240 |
(for { |
|
75948 | 241 |
session_name <- build_sessions.build_topological_order.iterator |
242 |
info <- build_sessions.get(session_name) |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
243 |
if full_sessions_selected(session_name) && browser_info.enabled(info) } |
75947 | 244 |
yield session_name).toList |
74800 | 245 |
|
66745 | 246 |
|
247 |
/* check unknown files */ |
|
48504
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
wenzelm
parents:
48494
diff
changeset
|
248 |
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
249 |
if (check_unknown_files) { |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
250 |
val source_files = |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
251 |
(for { |
75948 | 252 |
(_, base) <- build_deps.session_bases.iterator |
75741 | 253 |
(path, _) <- base.session_sources.iterator |
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
254 |
} yield path).toList |
67098 | 255 |
val exclude_files = List(Path.explode("$POLYML_EXE")).map(_.canonical_file) |
256 |
val unknown_files = |
|
67782
7e223a05e6d8
clarified notion of unknown files: ignore files outside of a Mercurial repository;
wenzelm
parents:
67493
diff
changeset
|
257 |
Mercurial.check_files(source_files)._2. |
67098 | 258 |
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
|
259 |
if (unknown_files.nonEmpty) { |
67782
7e223a05e6d8
clarified notion of unknown files: ignore files outside of a Mercurial repository;
wenzelm
parents:
67493
diff
changeset
|
260 |
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
|
261 |
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
|
262 |
} |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
263 |
} |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
264 |
|
51220 | 265 |
|
266 |
/* main build process */ |
|
267 |
||
75948 | 268 |
val queue = Queue(progress, build_sessions, store) |
65289 | 269 |
|
68219 | 270 |
store.prepare_output_dir() |
48373 | 271 |
|
48595 | 272 |
if (clean_build) { |
73012
238ddf525da4
clarified HTML presentation, e.g. avoid bulky jobs like HOL or HOL-Analysis in applications;
wenzelm
parents:
72993
diff
changeset
|
273 |
for (name <- full_sessions.imports_descendants(full_sessions_selection)) { |
68220
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
274 |
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
|
275 |
if (relevant) { |
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
276 |
if (ok) progress.echo("Cleaned " + name) |
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
277 |
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
|
278 |
} |
48595 | 279 |
} |
280 |
} |
|
281 |
||
48425 | 282 |
// scheduler loop |
63082
6af03422535a
expose Sessions.Info in Build.Results
Lars Hupel <lars.hupel@mytum.de>
parents:
62946
diff
changeset
|
283 |
case class Result( |
66594 | 284 |
current: Boolean, |
68213 | 285 |
heap_digest: Option[String], |
66594 | 286 |
process: Option[Process_Result], |
75393 | 287 |
info: Sessions.Info |
288 |
) { |
|
62402 | 289 |
def ok: Boolean = |
290 |
process match { |
|
291 |
case None => false |
|
74306 | 292 |
case Some(res) => res.ok |
62402 | 293 |
} |
294 |
} |
|
48639
675988e64bf9
store parent heap stamp as well -- needs to be propagated through the build hierarchy;
wenzelm
parents:
48626
diff
changeset
|
295 |
|
73340 | 296 |
def sleep(): Unit = |
73702
7202e12cb324
tuned signature --- following hints by IntelliJ IDEA;
wenzelm
parents:
73522
diff
changeset
|
297 |
Isabelle_Thread.interrupt_handler(_ => progress.stop()) { Time.seconds(0.5).sleep() } |
50366 | 298 |
|
73777
52e43a93d51f
clarified system_log: make this work independently of the particular "isabelle build" command-line (e.g. "isabelle mirabelle");
wenzelm
parents:
73774
diff
changeset
|
299 |
val log = |
52e43a93d51f
clarified system_log: make this work independently of the particular "isabelle build" command-line (e.g. "isabelle mirabelle");
wenzelm
parents:
73774
diff
changeset
|
300 |
build_options.string("system_log") match { |
52e43a93d51f
clarified system_log: make this work independently of the particular "isabelle build" command-line (e.g. "isabelle mirabelle");
wenzelm
parents:
73774
diff
changeset
|
301 |
case "" => No_Logger |
74827
c1b5d6e6ff74
clarified system option standard values: avoid oddities like "isabelle build -o document_output" producing directories named "true";
wenzelm
parents:
74818
diff
changeset
|
302 |
case "-" => Logger.make(progress) |
73777
52e43a93d51f
clarified system_log: make this work independently of the particular "isabelle build" command-line (e.g. "isabelle mirabelle");
wenzelm
parents:
73774
diff
changeset
|
303 |
case log_file => Logger.make(Some(Path.explode(log_file))) |
52e43a93d51f
clarified system_log: make this work independently of the particular "isabelle build" command-line (e.g. "isabelle mirabelle");
wenzelm
parents:
73774
diff
changeset
|
304 |
} |
52e43a93d51f
clarified system_log: make this work independently of the particular "isabelle build" command-line (e.g. "isabelle mirabelle");
wenzelm
parents:
73774
diff
changeset
|
305 |
|
64265 | 306 |
val numa_nodes = new NUMA.Nodes(numa_shuffling) |
307 |
||
48425 | 308 |
@tailrec def loop( |
48676
3ef82491cdd6
clarified Session_Tree (with proper integrity check) vs. Queue (with provision for alternative ordering);
wenzelm
parents:
48675
diff
changeset
|
309 |
pending: Queue, |
72662 | 310 |
running: Map[String, (List[String], Build_Job)], |
75393 | 311 |
results: Map[String, Result] |
312 |
): Map[String, Result] = { |
|
64265 | 313 |
def used_node(i: Int): Boolean = |
314 |
running.iterator.exists( |
|
315 |
{ case (_, (_, job)) => job.numa_node.isDefined && job.numa_node.get == i }) |
|
316 |
||
48425 | 317 |
if (pending.is_empty) results |
51253 | 318 |
else { |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
319 |
if (progress.stopped) { |
73367 | 320 |
for ((_, (_, job)) <- running) job.terminate() |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
321 |
} |
51253 | 322 |
|
48674 | 323 |
running.find({ case (_, (_, job)) => job.is_finished }) match { |
71669 | 324 |
case Some((session_name, (input_heaps, job))) => |
50367 | 325 |
//{{{ finish job |
48424 | 326 |
|
68217 | 327 |
val (process_result, heap_digest) = job.join |
48373 | 328 |
|
71623
b3bddebe44ca
clarified signature: more explicit type Protocol_Message.Marker;
wenzelm
parents:
71614
diff
changeset
|
329 |
val log_lines = process_result.out_lines.filterNot(Protocol_Message.Marker.test) |
75393 | 330 |
val process_result_tail = { |
62409
e391528eff3b
proper option process_output_tail, more generous default;
wenzelm
parents:
62406
diff
changeset
|
331 |
val tail = job.info.options.int("process_output_tail") |
62632 | 332 |
process_result.copy( |
333 |
out_lines = |
|
71669 | 334 |
"(see also " + store.output_log(session_name).file.toString + ")" :: |
65294 | 335 |
(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
|
336 |
} |
13a0f537e232
retain tail out_lines as printed, but not the whole log content;
wenzelm
parents:
62403
diff
changeset
|
337 |
|
72017 | 338 |
val build_log = |
339 |
Build_Log.Log_File(session_name, process_result.out_lines). |
|
340 |
parse_session_info( |
|
341 |
command_timings = true, |
|
342 |
theory_timings = true, |
|
343 |
ml_statistics = true, |
|
344 |
task_statistics = true) |
|
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
345 |
|
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
346 |
// write log file |
68217 | 347 |
if (process_result.ok) { |
71669 | 348 |
File.write_gzip(store.output_log_gz(session_name), terminate_lines(log_lines)) |
68217 | 349 |
} |
71669 | 350 |
else File.write(store.output_log(session_name), terminate_lines(log_lines)) |
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
351 |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
352 |
// write database |
72017 | 353 |
using(store.open_database(session_name, output = true))(db => |
354 |
store.write_session_info(db, session_name, |
|
355 |
build_log = |
|
356 |
if (process_result.timeout) build_log.error("Timeout") else build_log, |
|
357 |
build = |
|
75948 | 358 |
Session_Info(sources_stamp(build_deps, session_name), input_heaps, heap_digest, |
72017 | 359 |
process_result.rc))) |
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
360 |
|
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
361 |
// messages |
71601 | 362 |
process_result.err_lines.foreach(progress.echo) |
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
363 |
|
72013 | 364 |
if (process_result.ok) { |
72022
45865bb06182
clarified message --- as in former ML version (see 940195fbb282);
wenzelm
parents:
72021
diff
changeset
|
365 |
if (verbose) progress.echo(session_timing(session_name, build_log)) |
72021 | 366 |
progress.echo(session_finished(session_name, process_result)) |
72013 | 367 |
} |
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
368 |
else { |
71669 | 369 |
progress.echo(session_name + " FAILED") |
66666
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
370 |
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
|
371 |
} |
1a620647285c
clarified messages: after writing all files (see also 27f90319a499 and 57c85c83c11b);
wenzelm
parents:
66595
diff
changeset
|
372 |
|
71669 | 373 |
loop(pending - session_name, running - session_name, |
374 |
results + |
|
375 |
(session_name -> Result(false, heap_digest, Some(process_result_tail), job.info))) |
|
50367 | 376 |
//}}} |
60215 | 377 |
case None if running.size < (max_jobs max 1) => |
50367 | 378 |
//{{{ check/start next job |
71601 | 379 |
pending.dequeue(running.isDefinedAt) match { |
71669 | 380 |
case Some((session_name, info)) => |
66848 | 381 |
val ancestor_results = |
75948 | 382 |
build_sessions.build_requirements(List(session_name)). |
71669 | 383 |
filterNot(_ == session_name).map(results(_)) |
68213 | 384 |
val ancestor_heaps = ancestor_results.flatMap(_.heap_digest) |
62628 | 385 |
|
71669 | 386 |
val do_store = |
387 |
build_heap || Sessions.is_pure(session_name) || queue.is_inner(session_name) |
|
48547 | 388 |
|
75393 | 389 |
val (current, heap_digest) = { |
72634
5cea0993ee4f
clarified access to single database server vs. collection of database files;
wenzelm
parents:
72624
diff
changeset
|
390 |
store.try_open_database(session_name) match { |
68212
5a59fded83c7
clarified heap vs. database operations: discontinued correlation of directory;
wenzelm
parents:
68209
diff
changeset
|
391 |
case Some(db) => |
71669 | 392 |
using(db)(store.read_build(_, session_name)) match { |
68216 | 393 |
case Some(build) => |
71669 | 394 |
val heap_digest = store.find_heap_digest(session_name) |
68216 | 395 |
val current = |
396 |
!fresh_build && |
|
397 |
build.ok && |
|
75948 | 398 |
build.sources == sources_stamp(build_deps, session_name) && |
68216 | 399 |
build.input_heaps == ancestor_heaps && |
400 |
build.output_heap == heap_digest && |
|
71614 | 401 |
!(do_store && heap_digest.isEmpty) |
68216 | 402 |
(current, heap_digest) |
403 |
case None => (false, None) |
|
404 |
} |
|
62636 | 405 |
case None => (false, None) |
48504
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
wenzelm
parents:
48494
diff
changeset
|
406 |
} |
48547 | 407 |
} |
62628 | 408 |
val all_current = current && ancestor_results.forall(_.current) |
48528
784c6f63d79c
proper all_current, which regards parent status as well;
wenzelm
parents:
48511
diff
changeset
|
409 |
|
48547 | 410 |
if (all_current) |
71669 | 411 |
loop(pending - session_name, running, |
412 |
results + |
|
413 |
(session_name -> Result(true, heap_digest, Some(Process_Result(0)), info))) |
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
414 |
else if (no_build) { |
71894 | 415 |
progress.echo_if(verbose, "Skipping " + session_name + " ...") |
71669 | 416 |
loop(pending - session_name, running, |
417 |
results + |
|
418 |
(session_name -> Result(false, heap_digest, Some(Process_Result(1)), info))) |
|
48678
ff27af15530c
queue ordering by descending outdegree and timeout;
wenzelm
parents:
48676
diff
changeset
|
419 |
} |
62628 | 420 |
else if (ancestor_results.forall(_.ok) && !progress.stopped) { |
71669 | 421 |
progress.echo((if (do_store) "Building " else "Running ") + session_name + " ...") |
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
422 |
|
71669 | 423 |
store.clean_output(session_name) |
424 |
using(store.open_database(session_name, output = true))( |
|
425 |
store.init_session_info(_, session_name)) |
|
68086
9e1c670301b8
cleanup session output before starting build job;
wenzelm
parents:
67852
diff
changeset
|
426 |
|
71601 | 427 |
val numa_node = numa_nodes.next(used_node) |
51220 | 428 |
val job = |
75948 | 429 |
new Build_Job(progress, session_name, info, build_deps, store, do_store, |
73805
b73777a0c076
allow build session setup, e.g. for protocol handlers;
wenzelm
parents:
73804
diff
changeset
|
430 |
log, session_setup, numa_node, queue.command_timings(session_name)) |
71669 | 431 |
loop(pending, running + (session_name -> (ancestor_heaps, job)), results) |
48547 | 432 |
} |
433 |
else { |
|
71669 | 434 |
progress.echo(session_name + " CANCELLED") |
435 |
loop(pending - session_name, running, |
|
436 |
results + (session_name -> Result(false, heap_digest, None, info))) |
|
48547 | 437 |
} |
438 |
case None => sleep(); loop(pending, running, results) |
|
48425 | 439 |
} |
50367 | 440 |
///}}} |
48425 | 441 |
case None => sleep(); loop(pending, running, results) |
48373 | 442 |
} |
51253 | 443 |
} |
48425 | 444 |
} |
445 |
||
51220 | 446 |
|
447 |
/* build results */ |
|
448 |
||
75393 | 449 |
val results = { |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
450 |
val results0 = |
75948 | 451 |
if (build_deps.is_empty) { |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
452 |
progress.echo_warning("Nothing to build") |
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
453 |
Map.empty[String, Result] |
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
454 |
} |
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
455 |
else Isabelle_Thread.uninterruptible { loop(queue, Map.empty, Map.empty) } |
48583 | 456 |
|
64265 | 457 |
new Results( |
458 |
(for ((name, result) <- results0.iterator) |
|
459 |
yield (name, (result.process, result.info))).toMap) |
|
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
460 |
} |
62641 | 461 |
|
69811
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
462 |
if (export_files) { |
71896
ce06d6456cc8
clarified signature --- fit within limit of 22 arguments;
wenzelm
parents:
71895
diff
changeset
|
463 |
for (name <- full_sessions.imports_selection(selection).iterator if results(name).ok) { |
69811
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
464 |
val info = results.info(name) |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
465 |
if (info.export_files.nonEmpty) { |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
466 |
progress.echo("Exporting " + info.name + " ...") |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
467 |
for ((dir, prune, pats) <- info.export_files) { |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
468 |
Export.export_files(store, name, info.dir + dir, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
469 |
progress = if (verbose) progress else new Progress, |
69811
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
470 |
export_prune = prune, |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
471 |
export_patterns = pats) |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
472 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
473 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
474 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
475 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
476 |
|
74306 | 477 |
if (results.rc != Process_Result.RC.ok && (verbose || !no_build)) { |
62641 | 478 |
val unfinished = |
479 |
(for { |
|
480 |
name <- results.sessions.iterator |
|
481 |
if !results(name).ok |
|
482 |
} yield name).toList.sorted |
|
483 |
progress.echo("Unfinished session(s): " + commas(unfinished)) |
|
484 |
} |
|
485 |
||
75947 | 486 |
if (!no_build && !progress.stopped && results.ok && presentation_sessions.nonEmpty) { |
75948 | 487 |
Browser_Info.build(browser_info, store, build_deps, presentation_sessions, |
75947 | 488 |
progress = progress, verbose = verbose) |
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
|
489 |
} |
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
|
490 |
|
62641 | 491 |
results |
48341 | 492 |
} |
493 |
||
494 |
||
62833 | 495 |
/* Isabelle tool wrapper */ |
48341 | 496 |
|
72763 | 497 |
val isabelle_tool = Isabelle_Tool("build", "build and manage Isabelle sessions", |
75394 | 498 |
Scala_Project.here, |
499 |
{ args => |
|
500 |
val build_options = Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS")) |
|
62590 | 501 |
|
75394 | 502 |
var base_sessions: List[String] = Nil |
503 |
var select_dirs: List[Path] = Nil |
|
504 |
var numa_shuffling = false |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
505 |
var browser_info = Browser_Info.Config.none |
75394 | 506 |
var requirements = false |
507 |
var soft_build = false |
|
508 |
var exclude_session_groups: List[String] = Nil |
|
509 |
var all_sessions = false |
|
510 |
var build_heap = false |
|
511 |
var clean_build = false |
|
512 |
var dirs: List[Path] = Nil |
|
513 |
var export_files = false |
|
514 |
var fresh_build = false |
|
515 |
var session_groups: List[String] = Nil |
|
516 |
var max_jobs = 1 |
|
517 |
var check_keywords: Set[String] = Set.empty |
|
518 |
var list_files = false |
|
519 |
var no_build = false |
|
520 |
var options = Options.init(opts = build_options) |
|
521 |
var verbose = false |
|
522 |
var exclude_sessions: List[String] = Nil |
|
62590 | 523 |
|
75394 | 524 |
val getopts = Getopts(""" |
62590 | 525 |
Usage: isabelle build [OPTIONS] [SESSIONS ...] |
526 |
||
527 |
Options are: |
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
528 |
-B NAME include session NAME and all descendants |
62590 | 529 |
-D DIR include session directory and select its sessions |
64265 | 530 |
-N cyclic shuffling of NUMA CPU nodes (performance tuning) |
72648 | 531 |
-P DIR enable HTML/PDF presentation in directory (":" for default) |
71807 | 532 |
-R refer to requirements of selected sessions |
66745 | 533 |
-S soft build: only observe changes of sources, not heap images |
62590 | 534 |
-X NAME exclude sessions from group NAME and all descendants |
535 |
-a select all sessions |
|
536 |
-b build heap images |
|
537 |
-c clean build |
|
538 |
-d DIR include session directory |
|
69811
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
539 |
-e export files from session specification into file-system |
66841 | 540 |
-f fresh build |
62590 | 541 |
-g NAME select session group NAME |
542 |
-j INT maximum number of parallel jobs (default 1) |
|
543 |
-k KEYWORD check theory sources for conflicts with proposed keywords |
|
544 |
-l list session source files |
|
545 |
-n no build -- test dependencies only |
|
546 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
|
547 |
-v verbose |
|
548 |
-x NAME exclude session NAME and all descendants |
|
549 |
||
62596 | 550 |
Build and manage Isabelle sessions, depending on implicit settings: |
551 |
||
73736 | 552 |
""" + Library.indent_lines(2, Build_Log.Settings.show()) + "\n", |
75394 | 553 |
"B:" -> (arg => base_sessions = base_sessions ::: List(arg)), |
554 |
"D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))), |
|
555 |
"N" -> (_ => numa_shuffling = true), |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
556 |
"P:" -> (arg => browser_info = Browser_Info.Config.make(arg)), |
75394 | 557 |
"R" -> (_ => requirements = true), |
558 |
"S" -> (_ => soft_build = true), |
|
559 |
"X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)), |
|
560 |
"a" -> (_ => all_sessions = true), |
|
561 |
"b" -> (_ => build_heap = true), |
|
562 |
"c" -> (_ => clean_build = true), |
|
563 |
"d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))), |
|
564 |
"e" -> (_ => export_files = true), |
|
565 |
"f" -> (_ => fresh_build = true), |
|
566 |
"g:" -> (arg => session_groups = session_groups ::: List(arg)), |
|
567 |
"j:" -> (arg => max_jobs = Value.Int.parse(arg)), |
|
568 |
"k:" -> (arg => check_keywords = check_keywords + arg), |
|
569 |
"l" -> (_ => list_files = true), |
|
570 |
"n" -> (_ => no_build = true), |
|
571 |
"o:" -> (arg => options = options + arg), |
|
572 |
"v" -> (_ => verbose = true), |
|
573 |
"x:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg))) |
|
62590 | 574 |
|
75394 | 575 |
val sessions = getopts(args) |
62590 | 576 |
|
75394 | 577 |
val progress = new Console_Progress(verbose = verbose) |
62590 | 578 |
|
75394 | 579 |
val start_date = Date.now() |
64140 | 580 |
|
75394 | 581 |
if (verbose) { |
582 |
progress.echo( |
|
583 |
"Started at " + Build_Log.print_date(start_date) + |
|
584 |
" (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + Isabelle_System.hostname() +")") |
|
585 |
progress.echo(Build_Log.Settings.show() + "\n") |
|
586 |
} |
|
62590 | 587 |
|
75394 | 588 |
val results = |
589 |
progress.interrupt_handler { |
|
590 |
build(options, |
|
591 |
selection = Sessions.Selection( |
|
592 |
requirements = requirements, |
|
593 |
all_sessions = all_sessions, |
|
594 |
base_sessions = base_sessions, |
|
595 |
exclude_session_groups = exclude_session_groups, |
|
596 |
exclude_sessions = exclude_sessions, |
|
597 |
session_groups = session_groups, |
|
598 |
sessions = sessions), |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
599 |
browser_info = browser_info, |
75394 | 600 |
progress = progress, |
601 |
check_unknown_files = Mercurial.is_repository(Path.ISABELLE_HOME), |
|
602 |
build_heap = build_heap, |
|
603 |
clean_build = clean_build, |
|
604 |
dirs = dirs, |
|
605 |
select_dirs = select_dirs, |
|
606 |
numa_shuffling = NUMA.enabled_warning(progress, numa_shuffling), |
|
607 |
max_jobs = max_jobs, |
|
608 |
list_files = list_files, |
|
609 |
check_keywords = check_keywords, |
|
610 |
fresh_build = fresh_build, |
|
611 |
no_build = no_build, |
|
612 |
soft_build = soft_build, |
|
613 |
verbose = verbose, |
|
614 |
export_files = export_files) |
|
615 |
} |
|
616 |
val end_date = Date.now() |
|
617 |
val elapsed_time = end_date.time - start_date.time |
|
618 |
||
619 |
if (verbose) { |
|
620 |
progress.echo("\nFinished at " + Build_Log.print_date(end_date)) |
|
62833 | 621 |
} |
62590 | 622 |
|
75394 | 623 |
val total_timing = |
624 |
results.sessions.iterator.map(a => results(a).timing).foldLeft(Timing.zero)(_ + _). |
|
625 |
copy(elapsed = elapsed_time) |
|
626 |
progress.echo(total_timing.message_resources) |
|
62590 | 627 |
|
75394 | 628 |
sys.exit(results.rc) |
629 |
}) |
|
68305 | 630 |
|
631 |
||
632 |
/* build logic image */ |
|
633 |
||
634 |
def build_logic(options: Options, logic: String, |
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
635 |
progress: Progress = new Progress, |
68305 | 636 |
build_heap: Boolean = false, |
637 |
dirs: List[Path] = Nil, |
|
70791 | 638 |
fresh: Boolean = false, |
75393 | 639 |
strict: Boolean = false |
640 |
): Int = { |
|
71896
ce06d6456cc8
clarified signature --- fit within limit of 22 arguments;
wenzelm
parents:
71895
diff
changeset
|
641 |
val selection = Sessions.Selection.session(logic) |
69540 | 642 |
val rc = |
71981 | 643 |
if (!fresh && build(options, selection = selection, |
74306 | 644 |
build_heap = build_heap, no_build = true, dirs = dirs).ok) Process_Result.RC.ok |
69540 | 645 |
else { |
646 |
progress.echo("Build started for Isabelle/" + logic + " ...") |
|
71981 | 647 |
Build.build(options, selection = selection, progress = progress, |
648 |
build_heap = build_heap, fresh_build = fresh, dirs = dirs).rc |
|
69540 | 649 |
} |
74306 | 650 |
if (strict && rc != Process_Result.RC.ok) error("Failed to build Isabelle/" + logic) else rc |
68305 | 651 |
} |
48276 | 652 |
} |