author | wenzelm |
Sun, 12 Feb 2023 13:45:06 +0100 | |
changeset 77257 | 68a7ad1385bc |
parent 77256 | 25e923c57af7 |
child 77259 | 61fc2afe4c8b |
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 |
||
75393 | 11 |
object Build { |
62631 | 12 |
/** auxiliary **/ |
48424 | 13 |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
14 |
/* persistent build info */ |
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
15 |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
16 |
sealed case class Session_Info( |
77207
d98a99e4eea9
proper Shasum.digest, to emulate old form from build_history database;
wenzelm
parents:
77206
diff
changeset
|
17 |
sources: SHA1.Shasum, |
d98a99e4eea9
proper Shasum.digest, to emulate old form from build_history database;
wenzelm
parents:
77206
diff
changeset
|
18 |
input_heaps: SHA1.Shasum, |
d98a99e4eea9
proper Shasum.digest, to emulate old form from build_history database;
wenzelm
parents:
77206
diff
changeset
|
19 |
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
|
20 |
return_code: Int, |
ff164add75cd
maintain "uuid" column in session build database, to identity the original build process uniquely;
wenzelm
parents:
75948
diff
changeset
|
21 |
uuid: String |
75393 | 22 |
) { |
66747 | 23 |
def ok: Boolean = return_code == 0 |
24 |
} |
|
65291
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
25 |
|
57c85c83c11b
maintain persistent session info in SQLite database instead of log file;
wenzelm
parents:
65289
diff
changeset
|
26 |
|
62631 | 27 |
|
62641 | 28 |
/** build with results **/ |
48424 | 29 |
|
76198
fb4215da4919
clarified presentation_sessions: work with partial results;
wenzelm
parents:
76197
diff
changeset
|
30 |
class Results private[Build]( |
76206
769a7cd5a16a
clarified signature: re-use store/cache from build results;
wenzelm
parents:
76202
diff
changeset
|
31 |
val store: Sessions.Store, |
76209 | 32 |
val deps: Sessions.Deps, |
76901 | 33 |
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
|
34 |
results: Map[String, Process_Result] |
76198
fb4215da4919
clarified presentation_sessions: work with partial results;
wenzelm
parents:
76197
diff
changeset
|
35 |
) { |
76206
769a7cd5a16a
clarified signature: re-use store/cache from build results;
wenzelm
parents:
76202
diff
changeset
|
36 |
def cache: Term.Cache = store.cache |
769a7cd5a16a
clarified signature: re-use store/cache from build results;
wenzelm
parents:
76202
diff
changeset
|
37 |
|
77250
22016642d6af
clarified data structure: use static info from deps, not dynamic results;
wenzelm
parents:
77246
diff
changeset
|
38 |
def info(name: String): Sessions.Info = deps.sessions_structure(name) |
62403 | 39 |
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
|
40 |
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
|
41 |
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
|
42 |
val rc: Int = results.valuesIterator.map(_.strict.rc).foldLeft(Process_Result.RC.ok)(_ max _) |
74306 | 43 |
def ok: Boolean = rc == Process_Result.RC.ok |
62406 | 44 |
|
76202 | 45 |
def unfinished: List[String] = sessions.iterator.filterNot(apply(_).ok).toList.sorted |
76199 | 46 |
|
62406 | 47 |
override def toString: String = rc.toString |
62403 | 48 |
} |
49 |
||
62641 | 50 |
def build( |
50404
898cac1dad5e
avoid startup within GUI thread -- it is only required later for dialog;
wenzelm
parents:
50367
diff
changeset
|
51 |
options: Options, |
71981 | 52 |
selection: Sessions.Selection = Sessions.Selection.empty, |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
53 |
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
|
54 |
progress: Progress = new Progress, |
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
55 |
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
|
56 |
build_heap: Boolean = false, |
48595 | 57 |
clean_build: Boolean = false, |
56890 | 58 |
dirs: List[Path] = Nil, |
59 |
select_dirs: List[Path] = Nil, |
|
66968
9991671c98aa
allow to augment session context via explicit session infos;
wenzelm
parents:
66962
diff
changeset
|
60 |
infos: List[Sessions.Info] = Nil, |
64265 | 61 |
numa_shuffling: Boolean = false, |
48509 | 62 |
max_jobs: Int = 1, |
48903 | 63 |
list_files: Boolean = false, |
59891
9ce697050455
added isabelle build option -k, for fast off-line checking of theory sources;
wenzelm
parents:
59811
diff
changeset
|
64 |
check_keywords: Set[String] = Set.empty, |
66841 | 65 |
fresh_build: Boolean = false, |
48509 | 66 |
no_build: Boolean = false, |
66745 | 67 |
soft_build: Boolean = false, |
48509 | 68 |
verbose: Boolean = false, |
73805
b73777a0c076
allow build session setup, e.g. for protocol handlers;
wenzelm
parents:
73804
diff
changeset
|
69 |
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
|
70 |
augment_options: String => List[Options.Spec] = _ => Nil, |
75393 | 71 |
session_setup: (String, Session) => Unit = (_, _) => () |
72 |
): Results = { |
|
71677 | 73 |
val build_options = |
71679
eeaa4021f080
proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents:
71677
diff
changeset
|
74 |
options + |
eeaa4021f080
proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents:
71677
diff
changeset
|
75 |
"completion_limit=0" + |
eeaa4021f080
proper "editor_tracing_messages=0" as in "isabelle dump";
wenzelm
parents:
71677
diff
changeset
|
76 |
"editor_tracing_messages=0" + |
72728
caa182bdab7a
clarified options: batch-build has pide_reports disabled by default (requires significant resources);
wenzelm
parents:
72693
diff
changeset
|
77 |
("pide_reports=" + options.bool("build_pide_reports")) |
51220 | 78 |
|
69854
cc0b3e177b49
system option "system_heaps" supersedes various command-line options for "system build mode";
wenzelm
parents:
69811
diff
changeset
|
79 |
val store = Sessions.store(build_options) |
66745 | 80 |
|
69369
6ecc85955e04
prefer "Isabelle DejaVu Sans", even for headless batch-build (session_graph.pdf);
wenzelm
parents:
68957
diff
changeset
|
81 |
Isabelle_Fonts.init() |
6ecc85955e04
prefer "Isabelle DejaVu Sans", even for headless batch-build (session_graph.pdf);
wenzelm
parents:
68957
diff
changeset
|
82 |
|
66745 | 83 |
|
84 |
/* session selection and dependencies */ |
|
65422 | 85 |
|
66961 | 86 |
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
|
87 |
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
|
88 |
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
|
89 |
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
|
90 |
|
75948 | 91 |
val build_deps = { |
66745 | 92 |
val deps0 = |
71896
ce06d6456cc8
clarified signature --- fit within limit of 22 arguments;
wenzelm
parents:
71895
diff
changeset
|
93 |
Sessions.deps(full_sessions.selection(selection), |
66962
e1bde71bace6
clarified signature: global_theories is always required;
wenzelm
parents:
66961
diff
changeset
|
94 |
progress = progress, inlined_files = true, verbose = verbose, |
e1bde71bace6
clarified signature: global_theories is always required;
wenzelm
parents:
66961
diff
changeset
|
95 |
list_files = list_files, check_keywords = check_keywords).check_errors |
66745 | 96 |
|
66841 | 97 |
if (soft_build && !fresh_build) { |
66745 | 98 |
val outdated = |
68204 | 99 |
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
|
100 |
store.try_open_database(name) match { |
68214 | 101 |
case Some(db) => |
68216 | 102 |
using(db)(store.read_build(_, name)) match { |
66745 | 103 |
case Some(build) |
77204 | 104 |
if build.ok && build.sources == deps0.sources_shasum(name) => None |
66745 | 105 |
case _ => Some(name) |
106 |
} |
|
107 |
case None => Some(name) |
|
108 |
}) |
|
68204 | 109 |
|
110 |
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
|
111 |
progress = progress, inlined_files = true).check_errors |
66745 | 112 |
} |
68204 | 113 |
else deps0 |
66745 | 114 |
} |
115 |
||
116 |
||
117 |
/* check unknown files */ |
|
48504
21dfd6c04482
actually check source vs. target stamps, based on information from log files;
wenzelm
parents:
48494
diff
changeset
|
118 |
|
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
119 |
if (check_unknown_files) { |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
120 |
val source_files = |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
121 |
(for { |
75948 | 122 |
(_, base) <- build_deps.session_bases.iterator |
75741 | 123 |
(path, _) <- base.session_sources.iterator |
65832
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
124 |
} yield path).toList |
76670
b04d45bebbc5
discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents:
76669
diff
changeset
|
125 |
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
|
126 |
case Nil => |
b04d45bebbc5
discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents:
76669
diff
changeset
|
127 |
case unknown_files => |
b04d45bebbc5
discontinued somewhat pointless dependency: avoid illusion of extra accuracy (see also 09fb749d1a1e and 0f750a6dc754);
wenzelm
parents:
76669
diff
changeset
|
128 |
progress.echo_warning("Unknown files (not part of the underlying Mercurial repository):" + |
76883 | 129 |
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
|
130 |
} |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
131 |
} |
2fb85623c386
implicitly check for unknown files (not part of a Mercurial repository);
wenzelm
parents:
65831
diff
changeset
|
132 |
|
51220 | 133 |
|
77257 | 134 |
/* build process and results */ |
51220 | 135 |
|
77257 | 136 |
val build_context = Build_Process.Context(store, build_deps, progress = progress) |
77254
8d34f53871b4
clarified signature: make dynamic Queue from static Context;
wenzelm
parents:
77253
diff
changeset
|
137 |
|
68219 | 138 |
store.prepare_output_dir() |
48373 | 139 |
|
48595 | 140 |
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
|
141 |
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
|
142 |
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
|
143 |
if (relevant) { |
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
144 |
if (ok) progress.echo("Cleaned " + name) |
8fc4e3d1df86
clarified store.clean_output: cleanup user_output_dir even in system_mode;
wenzelm
parents:
68219
diff
changeset
|
145 |
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
|
146 |
} |
48595 | 147 |
} |
148 |
} |
|
149 |
||
75393 | 150 |
val results = { |
76200 | 151 |
val build_results = |
75948 | 152 |
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
|
153 |
progress.echo_warning("Nothing to build") |
77257 | 154 |
Map.empty[String, Build_Process.Result] |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72662
diff
changeset
|
155 |
} |
77257 | 156 |
else { |
157 |
Isabelle_Thread.uninterruptible { |
|
158 |
Build_Process.main(build_context, build_heap = build_heap, |
|
159 |
numa_shuffling = numa_shuffling, max_jobs = max_jobs, fresh_build = fresh_build, |
|
160 |
no_build = no_build, verbose = verbose, session_setup = session_setup) |
|
161 |
} |
|
162 |
} |
|
48583 | 163 |
|
76901 | 164 |
val sessions_ok: List[String] = |
165 |
(for { |
|
166 |
name <- build_deps.sessions_structure.build_topological_order.iterator |
|
167 |
result <- build_results.get(name) |
|
168 |
if result.ok |
|
169 |
} yield name).toList |
|
170 |
||
76200 | 171 |
val results = |
172 |
(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
|
173 |
yield (name, result.process_result)).toMap |
76196 | 174 |
|
76901 | 175 |
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
|
176 |
} |
62641 | 177 |
|
69811
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
178 |
if (export_files) { |
76196 | 179 |
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
|
180 |
val info = results.info(name) |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
181 |
if (info.export_files.nonEmpty) { |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
182 |
progress.echo("Exporting " + info.name + " ...") |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
183 |
for ((dir, prune, pats) <- info.export_files) { |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
184 |
Export.export_files(store, name, info.dir + dir, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
185 |
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
|
186 |
export_prune = prune, |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
187 |
export_patterns = pats) |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
188 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
189 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
190 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
191 |
} |
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
192 |
|
76901 | 193 |
val presentation_sessions = |
194 |
results.sessions_ok.filter(name => browser_info.enabled(results.info(name))) |
|
76230 | 195 |
if (presentation_sessions.nonEmpty && !progress.stopped) { |
196 |
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
|
197 |
progress = progress, verbose = verbose) |
fb4215da4919
clarified presentation_sessions: work with partial results;
wenzelm
parents:
76197
diff
changeset
|
198 |
} |
fb4215da4919
clarified presentation_sessions: work with partial results;
wenzelm
parents:
76197
diff
changeset
|
199 |
|
76196 | 200 |
if (!results.ok && (verbose || !no_build)) { |
76199 | 201 |
progress.echo("Unfinished session(s): " + commas(results.unfinished)) |
62641 | 202 |
} |
203 |
||
204 |
results |
|
48341 | 205 |
} |
206 |
||
207 |
||
62833 | 208 |
/* Isabelle tool wrapper */ |
48341 | 209 |
|
72763 | 210 |
val isabelle_tool = Isabelle_Tool("build", "build and manage Isabelle sessions", |
75394 | 211 |
Scala_Project.here, |
212 |
{ args => |
|
213 |
val build_options = Word.explode(Isabelle_System.getenv("ISABELLE_BUILD_OPTIONS")) |
|
62590 | 214 |
|
75394 | 215 |
var base_sessions: List[String] = Nil |
216 |
var select_dirs: List[Path] = Nil |
|
217 |
var numa_shuffling = false |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
218 |
var browser_info = Browser_Info.Config.none |
75394 | 219 |
var requirements = false |
220 |
var soft_build = false |
|
221 |
var exclude_session_groups: List[String] = Nil |
|
222 |
var all_sessions = false |
|
223 |
var build_heap = false |
|
224 |
var clean_build = false |
|
225 |
var dirs: List[Path] = Nil |
|
226 |
var export_files = false |
|
227 |
var fresh_build = false |
|
228 |
var session_groups: List[String] = Nil |
|
229 |
var max_jobs = 1 |
|
230 |
var check_keywords: Set[String] = Set.empty |
|
231 |
var list_files = false |
|
232 |
var no_build = false |
|
233 |
var options = Options.init(opts = build_options) |
|
234 |
var verbose = false |
|
235 |
var exclude_sessions: List[String] = Nil |
|
62590 | 236 |
|
75394 | 237 |
val getopts = Getopts(""" |
62590 | 238 |
Usage: isabelle build [OPTIONS] [SESSIONS ...] |
239 |
||
240 |
Options are: |
|
66737
2edc0c42c883
option -B for "isabelle build" and "isabelle imports";
wenzelm
parents:
66736
diff
changeset
|
241 |
-B NAME include session NAME and all descendants |
62590 | 242 |
-D DIR include session directory and select its sessions |
64265 | 243 |
-N cyclic shuffling of NUMA CPU nodes (performance tuning) |
72648 | 244 |
-P DIR enable HTML/PDF presentation in directory (":" for default) |
71807 | 245 |
-R refer to requirements of selected sessions |
66745 | 246 |
-S soft build: only observe changes of sources, not heap images |
62590 | 247 |
-X NAME exclude sessions from group NAME and all descendants |
248 |
-a select all sessions |
|
249 |
-b build heap images |
|
250 |
-c clean build |
|
251 |
-d DIR include session directory |
|
69811
18f61ce86425
clarified 'export_files' in session ROOT: require explicit "isabelle build -e";
wenzelm
parents:
69777
diff
changeset
|
252 |
-e export files from session specification into file-system |
66841 | 253 |
-f fresh build |
62590 | 254 |
-g NAME select session group NAME |
255 |
-j INT maximum number of parallel jobs (default 1) |
|
256 |
-k KEYWORD check theory sources for conflicts with proposed keywords |
|
257 |
-l list session source files |
|
76919 | 258 |
-n no build -- take existing build databases |
62590 | 259 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
260 |
-v verbose |
|
261 |
-x NAME exclude session NAME and all descendants |
|
262 |
||
62596 | 263 |
Build and manage Isabelle sessions, depending on implicit settings: |
264 |
||
73736 | 265 |
""" + Library.indent_lines(2, Build_Log.Settings.show()) + "\n", |
75394 | 266 |
"B:" -> (arg => base_sessions = base_sessions ::: List(arg)), |
267 |
"D:" -> (arg => select_dirs = select_dirs ::: List(Path.explode(arg))), |
|
268 |
"N" -> (_ => numa_shuffling = true), |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
269 |
"P:" -> (arg => browser_info = Browser_Info.Config.make(arg)), |
75394 | 270 |
"R" -> (_ => requirements = true), |
271 |
"S" -> (_ => soft_build = true), |
|
272 |
"X:" -> (arg => exclude_session_groups = exclude_session_groups ::: List(arg)), |
|
273 |
"a" -> (_ => all_sessions = true), |
|
274 |
"b" -> (_ => build_heap = true), |
|
275 |
"c" -> (_ => clean_build = true), |
|
276 |
"d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))), |
|
277 |
"e" -> (_ => export_files = true), |
|
278 |
"f" -> (_ => fresh_build = true), |
|
279 |
"g:" -> (arg => session_groups = session_groups ::: List(arg)), |
|
280 |
"j:" -> (arg => max_jobs = Value.Int.parse(arg)), |
|
281 |
"k:" -> (arg => check_keywords = check_keywords + arg), |
|
282 |
"l" -> (_ => list_files = true), |
|
283 |
"n" -> (_ => no_build = true), |
|
284 |
"o:" -> (arg => options = options + arg), |
|
285 |
"v" -> (_ => verbose = true), |
|
286 |
"x:" -> (arg => exclude_sessions = exclude_sessions ::: List(arg))) |
|
62590 | 287 |
|
75394 | 288 |
val sessions = getopts(args) |
62590 | 289 |
|
75394 | 290 |
val progress = new Console_Progress(verbose = verbose) |
62590 | 291 |
|
75394 | 292 |
val start_date = Date.now() |
64140 | 293 |
|
75394 | 294 |
if (verbose) { |
295 |
progress.echo( |
|
296 |
"Started at " + Build_Log.print_date(start_date) + |
|
297 |
" (" + Isabelle_System.getenv("ML_IDENTIFIER") + " on " + Isabelle_System.hostname() +")") |
|
298 |
progress.echo(Build_Log.Settings.show() + "\n") |
|
299 |
} |
|
62590 | 300 |
|
75394 | 301 |
val results = |
302 |
progress.interrupt_handler { |
|
303 |
build(options, |
|
304 |
selection = Sessions.Selection( |
|
305 |
requirements = requirements, |
|
306 |
all_sessions = all_sessions, |
|
307 |
base_sessions = base_sessions, |
|
308 |
exclude_session_groups = exclude_session_groups, |
|
309 |
exclude_sessions = exclude_sessions, |
|
310 |
session_groups = session_groups, |
|
311 |
sessions = sessions), |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
312 |
browser_info = browser_info, |
75394 | 313 |
progress = progress, |
314 |
check_unknown_files = Mercurial.is_repository(Path.ISABELLE_HOME), |
|
315 |
build_heap = build_heap, |
|
316 |
clean_build = clean_build, |
|
317 |
dirs = dirs, |
|
318 |
select_dirs = select_dirs, |
|
319 |
numa_shuffling = NUMA.enabled_warning(progress, numa_shuffling), |
|
320 |
max_jobs = max_jobs, |
|
321 |
list_files = list_files, |
|
322 |
check_keywords = check_keywords, |
|
323 |
fresh_build = fresh_build, |
|
324 |
no_build = no_build, |
|
325 |
soft_build = soft_build, |
|
326 |
verbose = verbose, |
|
327 |
export_files = export_files) |
|
328 |
} |
|
329 |
val end_date = Date.now() |
|
330 |
val elapsed_time = end_date.time - start_date.time |
|
331 |
||
332 |
if (verbose) { |
|
333 |
progress.echo("\nFinished at " + Build_Log.print_date(end_date)) |
|
62833 | 334 |
} |
62590 | 335 |
|
75394 | 336 |
val total_timing = |
337 |
results.sessions.iterator.map(a => results(a).timing).foldLeft(Timing.zero)(_ + _). |
|
338 |
copy(elapsed = elapsed_time) |
|
339 |
progress.echo(total_timing.message_resources) |
|
62590 | 340 |
|
75394 | 341 |
sys.exit(results.rc) |
342 |
}) |
|
68305 | 343 |
|
344 |
||
345 |
/* build logic image */ |
|
346 |
||
347 |
def build_logic(options: Options, logic: String, |
|
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71718
diff
changeset
|
348 |
progress: Progress = new Progress, |
68305 | 349 |
build_heap: Boolean = false, |
350 |
dirs: List[Path] = Nil, |
|
70791 | 351 |
fresh: Boolean = false, |
75393 | 352 |
strict: Boolean = false |
353 |
): Int = { |
|
71896
ce06d6456cc8
clarified signature --- fit within limit of 22 arguments;
wenzelm
parents:
71895
diff
changeset
|
354 |
val selection = Sessions.Selection.session(logic) |
69540 | 355 |
val rc = |
71981 | 356 |
if (!fresh && build(options, selection = selection, |
74306 | 357 |
build_heap = build_heap, no_build = true, dirs = dirs).ok) Process_Result.RC.ok |
69540 | 358 |
else { |
359 |
progress.echo("Build started for Isabelle/" + logic + " ...") |
|
71981 | 360 |
Build.build(options, selection = selection, progress = progress, |
361 |
build_heap = build_heap, fresh_build = fresh, dirs = dirs).rc |
|
69540 | 362 |
} |
74306 | 363 |
if (strict && rc != Process_Result.RC.ok) error("Failed to build Isabelle/" + logic) else rc |
68305 | 364 |
} |
48276 | 365 |
} |