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