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