author | wenzelm |
Mon, 23 Jan 2023 16:15:45 +0100 | |
changeset 77055 | f56800b8b085 |
parent 77051 | e57ba228ec24 |
child 77072 | e8010cb36820 |
permissions | -rw-r--r-- |
64160 | 1 |
/* Title: Pure/Admin/build_history.scala |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
3 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
4 |
Build other history versions. |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
6 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
8 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
9 |
|
75393 | 10 |
object Build_History { |
64117 | 11 |
/* log files */ |
12 |
||
65588 | 13 |
val engine = "build_history" |
65596 | 14 |
val log_prefix = engine + "_" |
64117 | 15 |
|
16 |
||
64188 | 17 |
/* augment settings */ |
64050 | 18 |
|
64188 | 19 |
def augment_settings( |
20 |
other_isabelle: Other_Isabelle, |
|
21 |
threads: Int, |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
22 |
arch_64: Boolean, |
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
23 |
heap: Int, |
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
24 |
max_heap: Option[Int], |
75393 | 25 |
more_settings: List[String] |
26 |
): String = { |
|
27 |
val (ml_platform, ml_settings) = { |
|
73671 | 28 |
val cygwin_32 = "x86-cygwin" |
64188 | 29 |
val windows_32 = "x86-windows" |
30 |
val windows_64 = "x86_64-windows" |
|
69727 | 31 |
val windows_64_32 = "x86_64_32-windows" |
69166 | 32 |
val platform_32 = other_isabelle.getenv("ISABELLE_PLATFORM32") |
33 |
val platform_64 = other_isabelle.getenv("ISABELLE_PLATFORM64") |
|
69727 | 34 |
val platform_64_32 = platform_64.replace("x86_64-", "x86_64_32-") |
64049 | 35 |
|
64188 | 36 |
val polyml_home = |
69166 | 37 |
try { Path.explode(other_isabelle.getenv("ML_HOME")).dir } |
64188 | 38 |
catch { case ERROR(msg) => error("Bad ML_HOME: " + msg) } |
64049 | 39 |
|
64188 | 40 |
def ml_home(platform: String): Path = polyml_home + Path.explode(platform) |
64049 | 41 |
|
64188 | 42 |
def err(platform: String): Nothing = |
43 |
error("Platform " + platform + " unavailable on this machine") |
|
64050 | 44 |
|
64188 | 45 |
def check_dir(platform: String): Boolean = |
46 |
platform != "" && ml_home(platform).is_dir |
|
64050 | 47 |
|
64188 | 48 |
val ml_platform = |
49 |
if (Platform.is_windows && arch_64) { |
|
50 |
if (check_dir(windows_64)) windows_64 else err(windows_64) |
|
51 |
} |
|
52 |
else if (Platform.is_windows && !arch_64) { |
|
69727 | 53 |
if (check_dir(windows_64_32)) windows_64_32 |
73671 | 54 |
else if (check_dir(cygwin_32)) cygwin_32 |
69727 | 55 |
else if (check_dir(windows_32)) windows_32 |
73671 | 56 |
else err(windows_32) |
64188 | 57 |
} |
69727 | 58 |
else if (arch_64) { |
59 |
if (check_dir(platform_64)) platform_64 else err(platform_64) |
|
64188 | 60 |
} |
69727 | 61 |
else if (check_dir(platform_64_32)) platform_64_32 |
62 |
else platform_32 |
|
64050 | 63 |
|
64188 | 64 |
val ml_options = |
65 |
"--minheap " + heap + (if (max_heap.isDefined) " --maxheap " + max_heap.get else "") + |
|
66 |
" --gcthreads " + threads + |
|
67 |
(if (ml_platform.endsWith("-windows")) " --codepage utf8" else "") |
|
64050 | 68 |
|
64188 | 69 |
(ml_platform, |
70 |
List( |
|
71 |
"ML_HOME=" + File.bash_path(ml_home(ml_platform)), |
|
72 |
"ML_PLATFORM=" + quote(ml_platform), |
|
73 |
"ML_OPTIONS=" + quote(ml_options))) |
|
64050 | 74 |
} |
75 |
||
64188 | 76 |
val thread_settings = |
77 |
List( |
|
78 |
"ISABELLE_JAVA_SYSTEM_OPTIONS=\"$ISABELLE_JAVA_SYSTEM_OPTIONS -Disabelle.threads=" + threads + "\"", |
|
79 |
"ISABELLE_BUILD_OPTIONS=\"threads=" + threads + "\"") |
|
64050 | 80 |
|
64188 | 81 |
val settings = |
82 |
List(ml_settings, thread_settings) ::: |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
83 |
(if (more_settings.isEmpty) Nil else List(more_settings)) |
64050 | 84 |
|
64188 | 85 |
File.append(other_isabelle.etc_settings, "\n" + cat_lines(settings.map(terminate_lines(_)))) |
64050 | 86 |
|
64188 | 87 |
ml_platform |
64049 | 88 |
} |
89 |
||
90 |
||
91 |
||
75549 | 92 |
/** local build **/ |
64025 | 93 |
|
73522 | 94 |
private val default_user_home = Path.USER_HOME |
64301 | 95 |
private val default_multicore = (1, 1) |
64335 | 96 |
private val default_heap = 1500 |
64025 | 97 |
private val default_isabelle_identifier = "build_history" |
98 |
||
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
99 |
def local_build( |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
100 |
options: Options, |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
101 |
root: Path, |
67047 | 102 |
user_home: Path = default_user_home, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71632
diff
changeset
|
103 |
progress: Progress = new Progress, |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
104 |
afp: Boolean = false, |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
105 |
afp_partition: Int = 0, |
64025 | 106 |
isabelle_identifier: String = default_isabelle_identifier, |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
107 |
ml_statistics_step: Int = 1, |
73240
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
108 |
component_repository: String = Components.default_component_repository, |
69434 | 109 |
components_base: Path = Components.default_components_base, |
64026 | 110 |
fresh: Boolean = false, |
69304
1f4afcde3334
more robust hostname for Isabelle cronjobs: do not rely on target OS installation for resulting build_log database content;
wenzelm
parents:
69253
diff
changeset
|
111 |
hostname: String = "", |
64052 | 112 |
multicore_base: Boolean = false, |
64301 | 113 |
multicore_list: List[(Int, Int)] = List(default_multicore), |
64030 | 114 |
arch_64: Boolean = false, |
115 |
heap: Int = default_heap, |
|
64036 | 116 |
max_heap: Option[Int] = None, |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
117 |
init_settings: List[String] = Nil, |
64030 | 118 |
more_settings: List[String] = Nil, |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
119 |
more_preferences: List[String] = Nil, |
64026 | 120 |
verbose: Boolean = false, |
64297 | 121 |
build_tags: List[String] = Nil, |
75393 | 122 |
build_args: List[String] = Nil |
123 |
): List[(Process_Result, Path)] = { |
|
64031 | 124 |
/* sanity checks */ |
125 |
||
76365 | 126 |
if (File.eq(Path.ISABELLE_HOME, root)) { |
73522 | 127 |
error("Repository coincides with ISABELLE_HOME=" + Path.ISABELLE_HOME.expand) |
76365 | 128 |
} |
64046 | 129 |
|
76365 | 130 |
for ((threads, _) <- multicore_list if threads < 1) { |
64301 | 131 |
error("Bad threads value < 1: " + threads) |
76365 | 132 |
} |
133 |
for ((_, processes) <- multicore_list if processes < 1) { |
|
64301 | 134 |
error("Bad processes value < 1: " + processes) |
76365 | 135 |
} |
64036 | 136 |
|
64030 | 137 |
if (heap < 100) error("Bad heap value < 100: " + heap) |
138 |
||
76365 | 139 |
if (max_heap.isDefined && max_heap.get < heap) { |
64036 | 140 |
error("Bad max_heap value < heap: " + max_heap.get) |
76365 | 141 |
} |
64036 | 142 |
|
64031 | 143 |
System.getenv("ISABELLE_SETTINGS_PRESENT") match { |
144 |
case null | "" => |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
145 |
case _ => error("Cannot run Admin/build_other within existing Isabelle settings environment") |
64031 | 146 |
} |
147 |
||
148 |
||
75549 | 149 |
/* Isabelle + AFP directory */ |
64031 | 150 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
151 |
def directory(dir: Path): Mercurial.Hg_Sync.Directory = { |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
152 |
val directory = Mercurial.Hg_Sync.directory(dir) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
153 |
if (verbose) progress.echo(directory.log) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
154 |
directory |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
155 |
} |
64025 | 156 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
157 |
val isabelle_directory = directory(root) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
158 |
val afp_directory = if (afp) Some(directory(root + Path.explode("AFP"))) else None |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
159 |
|
66862 | 160 |
val (afp_build_args, afp_sessions) = |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
161 |
if (afp_directory.isEmpty) (Nil, Nil) |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
162 |
else { |
74036
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
163 |
val (opt, sessions) = { |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
164 |
if (afp_partition == 0) ("-d", Nil) |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
165 |
else { |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
166 |
try { |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
167 |
val afp_info = AFP.init(options, base_dir = afp_directory.get.root) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
168 |
("-d", afp_info.partition(afp_partition)) |
74036
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
169 |
} catch { case ERROR(_) => ("-D", Nil) } |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
170 |
} |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
171 |
} |
73184
a5998396051e
more robust: defer error in sessions structure to build process;
wenzelm
parents:
73183
diff
changeset
|
172 |
(List(opt, "~~/AFP/thys"), sessions) |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
173 |
} |
64025 | 174 |
|
64051 | 175 |
|
64052 | 176 |
/* main */ |
64043 | 177 |
|
67045 | 178 |
val other_isabelle = |
67047 | 179 |
Other_Isabelle(root, isabelle_identifier = isabelle_identifier, |
180 |
user_home = user_home, progress = progress) |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
181 |
|
69304
1f4afcde3334
more robust hostname for Isabelle cronjobs: do not rely on target OS installation for resulting build_log database content;
wenzelm
parents:
69253
diff
changeset
|
182 |
val build_host = proper_string(hostname) getOrElse Isabelle_System.hostname() |
64117 | 183 |
val build_history_date = Date.now() |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
184 |
val build_group_id = build_host + ":" + build_history_date.time.ms |
64117 | 185 |
|
64051 | 186 |
var first_build = true |
75393 | 187 |
for ((threads, processes) <- multicore_list) yield { |
64052 | 188 |
/* init settings */ |
189 |
||
69388 | 190 |
val component_settings = |
69434 | 191 |
other_isabelle.init_components( |
73240
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
192 |
component_repository = component_repository, |
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
193 |
components_base = components_base, |
77055 | 194 |
catalogs = Components.optional_catalogs) |
69388 | 195 |
other_isabelle.init_settings(component_settings ::: init_settings) |
73242 | 196 |
other_isabelle.resolve_components(echo = verbose) |
64117 | 197 |
val ml_platform = |
65845
b8ff63149256
proper init_settings, before inspecting ML_HOME etc;
wenzelm
parents:
65844
diff
changeset
|
198 |
augment_settings(other_isabelle, threads, arch_64, heap, max_heap, more_settings) |
64043 | 199 |
|
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
200 |
File.write(other_isabelle.etc_preferences, cat_lines(more_preferences)) |
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
201 |
|
68219 | 202 |
val isabelle_output = |
203 |
other_isabelle.isabelle_home_user + Path.explode("heaps") + |
|
69166 | 204 |
Path.explode(other_isabelle.getenv("ML_IDENTIFIER")) |
64052 | 205 |
val isabelle_output_log = isabelle_output + Path.explode("log") |
206 |
val isabelle_base_log = isabelle_output + Path.explode("../base_log") |
|
207 |
||
64051 | 208 |
if (first_build) { |
73242 | 209 |
other_isabelle.resolve_components(echo = verbose) |
64376
68ace7f3d78f
more thorough cleanup of lib/classes -- it may contain broken Pure.jar or copies of Scala libraries (in historic versions);
wenzelm
parents:
64353
diff
changeset
|
210 |
|
76365 | 211 |
if (fresh) { |
64376
68ace7f3d78f
more thorough cleanup of lib/classes -- it may contain broken Pure.jar or copies of Scala libraries (in historic versions);
wenzelm
parents:
64353
diff
changeset
|
212 |
Isabelle_System.rm_tree(other_isabelle.isabelle_home + Path.explode("lib/classes")) |
76365 | 213 |
} |
64051 | 214 |
other_isabelle.bash( |
77051 | 215 |
"env PATH=\"" + File.bash_path(Path.explode("~~/lib/dummy_stty")) + ":$PATH\" " + |
64376
68ace7f3d78f
more thorough cleanup of lib/classes -- it may contain broken Pure.jar or copies of Scala libraries (in historic versions);
wenzelm
parents:
64353
diff
changeset
|
216 |
"bin/isabelle jedit -b", redirect = true, echo = verbose).check |
64052 | 217 |
|
69253
8bfa615ddde4
proper ghc_setup / ocaml_setup on target Isabelle distribution (amending 2a17c481d05e);
wenzelm
parents:
69243
diff
changeset
|
218 |
for { |
8bfa615ddde4
proper ghc_setup / ocaml_setup on target Isabelle distribution (amending 2a17c481d05e);
wenzelm
parents:
69243
diff
changeset
|
219 |
tool <- List("ghc_setup", "ocaml_setup") |
8bfa615ddde4
proper ghc_setup / ocaml_setup on target Isabelle distribution (amending 2a17c481d05e);
wenzelm
parents:
69243
diff
changeset
|
220 |
if other_isabelle.getenv("ISABELLE_" + Word.uppercase(tool)) == "true" && |
8bfa615ddde4
proper ghc_setup / ocaml_setup on target Isabelle distribution (amending 2a17c481d05e);
wenzelm
parents:
69243
diff
changeset
|
221 |
(other_isabelle.isabelle_home + Path.explode("lib/Tools/" + tool)).is_file |
77044 | 222 |
} other_isabelle.bash("bin/isabelle " + tool, echo = verbose) |
69253
8bfa615ddde4
proper ghc_setup / ocaml_setup on target Isabelle distribution (amending 2a17c481d05e);
wenzelm
parents:
69243
diff
changeset
|
223 |
|
64213 | 224 |
Isabelle_System.rm_tree(isabelle_base_log) |
64051 | 225 |
} |
64025 | 226 |
|
64213 | 227 |
Isabelle_System.rm_tree(isabelle_output) |
72375 | 228 |
Isabelle_System.make_directory(isabelle_output) |
64052 | 229 |
|
76367 | 230 |
(other_isabelle.isabelle_home_user + Path.explode("mash_state")).file.delete |
231 |
||
65909 | 232 |
val log_path = |
233 |
other_isabelle.isabelle_home_user + |
|
234 |
Build_Log.log_subdir(build_history_date) + |
|
235 |
Build_Log.log_filename(Build_History.engine, build_history_date, |
|
236 |
List(build_host, ml_platform, "M" + threads) ::: build_tags) |
|
237 |
||
72375 | 238 |
Isabelle_System.make_directory(log_path.dir) |
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
239 |
|
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
240 |
val build_out = other_isabelle.isabelle_home_user + Path.explode("log/build.out") |
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
241 |
val build_out_progress = new File_Progress(build_out) |
65909 | 242 |
build_out.file.delete |
243 |
||
64052 | 244 |
|
245 |
/* build */ |
|
246 |
||
76365 | 247 |
if (multicore_base && !first_build && isabelle_base_log.is_dir) { |
64189 | 248 |
Isabelle_System.copy_dir(isabelle_base_log, isabelle_output_log) |
76365 | 249 |
} |
64052 | 250 |
|
64117 | 251 |
val build_start = Date.now() |
66862 | 252 |
val build_args1 = List("-v", "-j" + processes) ::: afp_build_args ::: build_args |
71967 | 253 |
|
254 |
val build_isabelle = |
|
67045 | 255 |
Other_Isabelle(root, isabelle_identifier = isabelle_identifier, |
71967 | 256 |
user_home = user_home, progress = build_out_progress) |
257 |
val build_result = |
|
77044 | 258 |
build_isabelle.bash("bin/isabelle build " + Bash.strings(build_args1 ::: afp_sessions), |
71967 | 259 |
redirect = true, echo = true, strict = false) |
260 |
||
64117 | 261 |
val build_end = Date.now() |
262 |
||
65646 | 263 |
val build_info: Build_Log.Build_Info = |
69366 | 264 |
Build_Log.Log_File(log_path.file_name, build_result.out_lines). |
65646 | 265 |
parse_build_info(ml_statistics = true) |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
266 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
267 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
268 |
/* output log */ |
64120 | 269 |
|
68221 | 270 |
val store = Sessions.store(options + "build_database_server=false") |
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
271 |
|
64117 | 272 |
val meta_info = |
65624 | 273 |
Properties.lines_nonempty(Build_Log.Prop.build_tags.name, build_tags) ::: |
274 |
Properties.lines_nonempty(Build_Log.Prop.build_args.name, build_args1) ::: |
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
275 |
List( |
65591 | 276 |
Build_Log.Prop.build_group_id.name -> build_group_id, |
277 |
Build_Log.Prop.build_id.name -> (build_host + ":" + build_start.time.ms), |
|
278 |
Build_Log.Prop.build_engine.name -> Build_History.engine, |
|
279 |
Build_Log.Prop.build_host.name -> build_host, |
|
280 |
Build_Log.Prop.build_start.name -> Build_Log.print_date(build_start), |
|
281 |
Build_Log.Prop.build_end.name -> Build_Log.print_date(build_end), |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
282 |
Build_Log.Prop.isabelle_version.name -> isabelle_directory.id) ::: |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
283 |
afp_directory.map(dir => Build_Log.Prop.afp_version.name -> dir.id).toList |
64117 | 284 |
|
66913 | 285 |
build_out_progress.echo("Reading session build info ...") |
286 |
val session_build_info = |
|
75394 | 287 |
build_info.finished_sessions.flatMap { session_name => |
288 |
val database = isabelle_output + store.database(session_name) |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
289 |
|
75394 | 290 |
if (database.is_file) { |
291 |
using(SQLite.open_database(database)) { db => |
|
292 |
val theory_timings = |
|
293 |
try { |
|
294 |
store.read_theory_timings(db, session_name).map(ps => |
|
295 |
Protocol.Theory_Timing_Marker((Build_Log.SESSION_NAME, session_name) :: ps)) |
|
296 |
} |
|
297 |
catch { case ERROR(_) => Nil } |
|
72014 | 298 |
|
75394 | 299 |
val session_sources = |
300 |
store.read_build(db, session_name).map(_.sources) match { |
|
301 |
case Some(sources) if sources.length == SHA1.digest_length => |
|
302 |
List("Sources " + session_name + " " + sources) |
|
303 |
case _ => Nil |
|
304 |
} |
|
66913 | 305 |
|
75394 | 306 |
theory_timings ::: session_sources |
66913 | 307 |
} |
75394 | 308 |
} |
309 |
else Nil |
|
310 |
} |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
311 |
|
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
312 |
build_out_progress.echo("Reading ML statistics ...") |
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
313 |
val ml_statistics = |
75394 | 314 |
build_info.finished_sessions.flatMap { session_name => |
315 |
val database = isabelle_output + store.database(session_name) |
|
316 |
val log_gz = isabelle_output + store.log_gz(session_name) |
|
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
317 |
|
75394 | 318 |
val properties = |
319 |
if (database.is_file) { |
|
320 |
using(SQLite.open_database(database))(db => |
|
321 |
store.read_ml_statistics(db, session_name)) |
|
322 |
} |
|
323 |
else if (log_gz.is_file) { |
|
324 |
Build_Log.Log_File(log_gz).parse_session_info(ml_statistics = true).ml_statistics |
|
325 |
} |
|
326 |
else Nil |
|
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
327 |
|
75394 | 328 |
val trimmed_properties = |
329 |
if (ml_statistics_step <= 0) Nil |
|
330 |
else if (ml_statistics_step == 1) properties |
|
331 |
else { |
|
332 |
(for { (ps, i) <- properties.iterator.zipWithIndex if i % ml_statistics_step == 0 } |
|
333 |
yield ps).toList |
|
334 |
} |
|
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
335 |
|
75394 | 336 |
trimmed_properties.map(ps => (Build_Log.SESSION_NAME -> session_name) :: ps) |
337 |
} |
|
64120 | 338 |
|
65937 | 339 |
build_out_progress.echo("Reading error messages ...") |
340 |
val session_errors = |
|
75394 | 341 |
build_info.failed_sessions.flatMap { session_name => |
342 |
val database = isabelle_output + store.database(session_name) |
|
343 |
val errors = |
|
344 |
if (database.is_file) { |
|
345 |
try { |
|
346 |
using(SQLite.open_database(database))(db => store.read_errors(db, session_name)) |
|
347 |
} // column "errors" could be missing |
|
348 |
catch { case _: java.sql.SQLException => Nil } |
|
349 |
} |
|
350 |
else Nil |
|
351 |
errors.map(msg => List(Build_Log.SESSION_NAME -> session_name, Markup.CONTENT -> msg)) |
|
352 |
} |
|
65937 | 353 |
|
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
354 |
build_out_progress.echo("Reading heap sizes ...") |
64120 | 355 |
val heap_sizes = |
75394 | 356 |
build_info.finished_sessions.flatMap { session_name => |
357 |
val heap = isabelle_output + Path.explode(session_name) |
|
76365 | 358 |
if (heap.is_file) { |
75394 | 359 |
Some("Heap " + session_name + " (" + Value.Long(heap.file.length) + " bytes)") |
76365 | 360 |
} |
75394 | 361 |
else None |
362 |
} |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
363 |
|
72575 | 364 |
build_out_progress.echo("Writing log file " + log_path.xz + " ...") |
365 |
File.write_xz(log_path.xz, |
|
64173 | 366 |
terminate_lines( |
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71620
diff
changeset
|
367 |
Protocol.Meta_Info_Marker(meta_info) :: build_result.out_lines ::: |
66913 | 368 |
session_build_info ::: |
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71620
diff
changeset
|
369 |
ml_statistics.map(Protocol.ML_Statistics_Marker.apply) ::: |
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71620
diff
changeset
|
370 |
session_errors.map(Protocol.Error_Message_Marker.apply) ::: |
76351
2cee31cd92f0
generic support for XZ and Zstd compression in Isabelle/Scala;
wenzelm
parents:
76136
diff
changeset
|
371 |
heap_sizes), Compress.Options_XZ(6)) |
64117 | 372 |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
373 |
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
374 |
/* next build */ |
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
375 |
|
76365 | 376 |
if (multicore_base && first_build && isabelle_output_log.is_dir) { |
64189 | 377 |
Isabelle_System.copy_dir(isabelle_output_log, isabelle_base_log) |
76365 | 378 |
} |
64052 | 379 |
|
64260 | 380 |
Isabelle_System.rm_tree(isabelle_output) |
381 |
||
64052 | 382 |
first_build = false |
383 |
||
72575 | 384 |
(build_result, log_path.xz) |
64051 | 385 |
} |
64025 | 386 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
387 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
388 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
389 |
/* command line entry point */ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
390 |
|
75393 | 391 |
private object Multicore { |
64301 | 392 |
private val Pat1 = """^(\d+)$""".r |
393 |
private val Pat2 = """^(\d+)x(\d+)$""".r |
|
394 |
||
395 |
def parse(s: String): (Int, Int) = |
|
396 |
s match { |
|
397 |
case Pat1(Value.Int(x)) => (x, 1) |
|
398 |
case Pat2(Value.Int(x), Value.Int(y)) => (x, y) |
|
399 |
case _ => error("Bad multicore configuration: " + quote(s)) |
|
400 |
} |
|
401 |
} |
|
402 |
||
75393 | 403 |
def main(args: Array[String]): Unit = { |
71632 | 404 |
Command_Line.tool { |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
405 |
var afp = false |
64052 | 406 |
var multicore_base = false |
69434 | 407 |
var components_base: Path = Components.default_components_base |
64030 | 408 |
var heap: Option[Int] = None |
64036 | 409 |
var max_heap: Option[Int] = None |
64301 | 410 |
var multicore_list = List(default_multicore) |
64025 | 411 |
var isabelle_identifier = default_isabelle_identifier |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
412 |
var afp_partition = 0 |
73240
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
413 |
var component_repository = Components.default_component_repository |
64030 | 414 |
var more_settings: List[String] = Nil |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
415 |
var more_preferences: List[String] = Nil |
64026 | 416 |
var fresh = false |
69304
1f4afcde3334
more robust hostname for Isabelle cronjobs: do not rely on target OS installation for resulting build_log database content;
wenzelm
parents:
69253
diff
changeset
|
417 |
var hostname = "" |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
418 |
var init_settings: List[String] = Nil |
64030 | 419 |
var arch_64 = false |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
420 |
var output_file = "" |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
421 |
var ml_statistics_step = 1 |
64297 | 422 |
var build_tags = List.empty[String] |
67047 | 423 |
var user_home = default_user_home |
64025 | 424 |
var verbose = false |
65950
34c4cd9abc1a
no exit code from build processes by default, e.g. relevant for non-strict results of remote_build_history;
wenzelm
parents:
65937
diff
changeset
|
425 |
var exit_code = false |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
426 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
427 |
val getopts = Getopts(""" |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
428 |
Usage: Admin/build_other [OPTIONS] ISABELLE_HOME [ARGS ...] |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
429 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
430 |
Options are: |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
431 |
-A include $ISABELLE_HOME/AFP directory |
64052 | 432 |
-B first multicore build serves as base for scheduling information |
69434 | 433 |
-C DIR base directory for Isabelle components (default: """ + |
434 |
Components.default_components_base + """) |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
435 |
-H SIZE minimal ML heap in MB (default: """ + default_heap + """ for x86, """ + |
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
436 |
default_heap * 2 + """ for x86_64) |
64301 | 437 |
-M MULTICORE multicore configurations (see below) |
64025 | 438 |
-N NAME alternative ISABELLE_IDENTIFIER (default: """ + default_isabelle_identifier + """) |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
439 |
-P NUMBER AFP partition number (0, 1, 2, default: 0=unrestricted) |
73240
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
440 |
-R URL remote repository for Isabelle components (default: """ + |
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
441 |
Components.default_component_repository + """) |
64036 | 442 |
-U SIZE maximal ML heap in MB (default: unbounded) |
64030 | 443 |
-e TEXT additional text for generated etc/settings |
64026 | 444 |
-f fresh build of Isabelle/Scala components (recommended) |
69304
1f4afcde3334
more robust hostname for Isabelle cronjobs: do not rely on target OS installation for resulting build_log database content;
wenzelm
parents:
69253
diff
changeset
|
445 |
-h NAME override local hostname |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
446 |
-i TEXT initial text for generated etc/settings |
64030 | 447 |
-m ARCH processor architecture (32=x86, 64=x86_64, default: x86) |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
448 |
-n no build: sync only |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
449 |
-o FILE output file for log names (default: stdout) |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
450 |
-p TEXT additional text for generated etc/preferences |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
451 |
-s NUMBER step size for ML statistics (0=none, 1=all, n=step, default: 1) |
64297 | 452 |
-t TAG free-form build tag (multiple occurrences possible) |
67047 | 453 |
-u DIR alternative USER_HOME directory |
64025 | 454 |
-v verbose |
65950
34c4cd9abc1a
no exit code from build processes by default, e.g. relevant for non-strict results of remote_build_history;
wenzelm
parents:
65937
diff
changeset
|
455 |
-x return overall exit code from build processes |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
456 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
457 |
Build Isabelle sessions from the history of another REPOSITORY clone, |
64026 | 458 |
passing ARGS directly to its isabelle build tool. |
64301 | 459 |
|
460 |
Each MULTICORE configuration consists of one or two numbers (default 1): |
|
461 |
THREADS or THREADSxPROCESSES, e.g. -M 1,2,4 or -M 1x4,2x2,4. |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
462 |
""", |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
463 |
"A" -> (_ => afp = true), |
64052 | 464 |
"B" -> (_ => multicore_base = true), |
69434 | 465 |
"C:" -> (arg => components_base = Path.explode(arg)), |
64030 | 466 |
"H:" -> (arg => heap = Some(Value.Int.parse(arg))), |
71601 | 467 |
"M:" -> (arg => multicore_list = space_explode(',', arg).map(Multicore.parse)), |
64025 | 468 |
"N:" -> (arg => isabelle_identifier = arg), |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
469 |
"P:" -> (arg => afp_partition = Value.Int.parse(arg)), |
73240
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
470 |
"R:" -> (arg => component_repository = arg), |
64036 | 471 |
"U:" -> (arg => max_heap = Some(Value.Int.parse(arg))), |
64030 | 472 |
"e:" -> (arg => more_settings = more_settings ::: List(arg)), |
64026 | 473 |
"f" -> (_ => fresh = true), |
69304
1f4afcde3334
more robust hostname for Isabelle cronjobs: do not rely on target OS installation for resulting build_log database content;
wenzelm
parents:
69253
diff
changeset
|
474 |
"h:" -> (arg => hostname = arg), |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
475 |
"i:" -> (arg => init_settings = init_settings ::: List(arg)), |
64030 | 476 |
"m:" -> |
477 |
{ |
|
478 |
case "32" | "x86" => arch_64 = false |
|
479 |
case "64" | "x86_64" => arch_64 = true |
|
480 |
case bad => error("Bad processor architecture: " + quote(bad)) |
|
481 |
}, |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
482 |
"o:" -> (arg => output_file = arg), |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
483 |
"p:" -> (arg => more_preferences = more_preferences ::: List(arg)), |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
484 |
"s:" -> (arg => ml_statistics_step = Value.Int.parse(arg)), |
64297 | 485 |
"t:" -> (arg => build_tags = build_tags ::: List(arg)), |
67047 | 486 |
"u:" -> (arg => user_home = Path.explode(arg)), |
65950
34c4cd9abc1a
no exit code from build processes by default, e.g. relevant for non-strict results of remote_build_history;
wenzelm
parents:
65937
diff
changeset
|
487 |
"v" -> (_ => verbose = true), |
34c4cd9abc1a
no exit code from build processes by default, e.g. relevant for non-strict results of remote_build_history;
wenzelm
parents:
65937
diff
changeset
|
488 |
"x" -> (_ => exit_code = true)) |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
489 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
490 |
val more_args = getopts(args) |
64026 | 491 |
val (root, build_args) = |
492 |
more_args match { |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
493 |
case root :: build_args => (Path.explode(root), build_args) |
64026 | 494 |
case _ => getopts.usage() |
495 |
} |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
496 |
|
64162 | 497 |
val progress = new Console_Progress(stderr = true) |
64346 | 498 |
|
64162 | 499 |
val results = |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
500 |
local_build(Options.init(), root, user_home = user_home, progress = progress, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
501 |
afp = afp, afp_partition = afp_partition, |
67047 | 502 |
isabelle_identifier = isabelle_identifier, ml_statistics_step = ml_statistics_step, |
73240
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
503 |
component_repository = component_repository, components_base = components_base, |
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
504 |
fresh = fresh, hostname = hostname, multicore_base = multicore_base, |
3e963d68d394
more robust ISABELLE_COMPONENT_REPOSITORY: use current value of managing process to avoid its fluctuation in ancient history;
wenzelm
parents:
73184
diff
changeset
|
505 |
multicore_list = multicore_list, arch_64 = arch_64, |
67047 | 506 |
heap = heap.getOrElse(if (arch_64) default_heap * 2 else default_heap), |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
507 |
max_heap = max_heap, init_settings = init_settings, more_settings = more_settings, |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
508 |
more_preferences = more_preferences, verbose = verbose, build_tags = build_tags, |
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
509 |
build_args = build_args) |
64162 | 510 |
|
76366 | 511 |
if (output_file.isEmpty) { |
512 |
for ((_, log_path) <- results) Output.writeln(log_path.implode, stdout = true) |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
513 |
} |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
514 |
else { |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
515 |
File.write(Path.explode(output_file), |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
516 |
cat_lines(for ((_, log_path) <- results) yield log_path.implode)) |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
517 |
} |
64472
c2191352e908
recovered Output.writeln for remote build_history (cf. ed8940d6295c), in order to have log files copied and removed;
wenzelm
parents:
64468
diff
changeset
|
518 |
|
74306 | 519 |
val rc = results.foldLeft(Process_Result.RC.ok) { case (rc, (res, _)) => rc max res.rc } |
520 |
if (rc != Process_Result.RC.ok && exit_code) sys.exit(rc) |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
521 |
} |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
522 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
523 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
524 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
525 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
526 |
/** remote build -- via rsync and ssh **/ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
527 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
528 |
def remote_build( |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
529 |
ssh: SSH.Session, |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
530 |
isabelle_self: Path, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
531 |
isabelle_other: Path, |
65928
38eb5d633b0b
avoid conflict with generated settings of other_isabelle;
wenzelm
parents:
65927
diff
changeset
|
532 |
isabelle_identifier: String = "remote_build_history", |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71632
diff
changeset
|
533 |
progress: Progress = new Progress, |
75528
96fb1f9a4042
more robust: protect_args does not work with rsync 2.x from macOS, and is not required in typical situations;
wenzelm
parents:
75525
diff
changeset
|
534 |
protect_args: Boolean = false, |
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
535 |
rev: String = "", |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
536 |
afp_repos: Option[Path] = None, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
537 |
afp_rev: String = "", |
64227 | 538 |
options: String = "", |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
539 |
args: String = "", |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
540 |
no_build: Boolean = false |
75393 | 541 |
): List[(String, Bytes)] = { |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
542 |
/* synchronize Isabelle + AFP repositories */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
543 |
|
75549 | 544 |
def sync(target: Path, accurate: Boolean = false, |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
545 |
rev: String = "", afp_rev: String = "", afp: Boolean = false |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
546 |
): Unit = { |
76136
1bb677cceea4
let rsync re-use ssh connection via control path;
wenzelm
parents:
76122
diff
changeset
|
547 |
val context = |
1bb677cceea4
let rsync re-use ssh connection via control path;
wenzelm
parents:
76122
diff
changeset
|
548 |
Rsync.Context(progress, ssh_port = ssh.port, ssh_control_path = ssh.control_path, |
1bb677cceea4
let rsync re-use ssh connection via control path;
wenzelm
parents:
76122
diff
changeset
|
549 |
protect_args = protect_args) |
75552
4aa3da02fd4d
sync session images, based on accidental local state;
wenzelm
parents:
75549
diff
changeset
|
550 |
Sync.sync(ssh.options, context, ssh.rsync_path(target), |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
551 |
thorough = accurate, preserve_jars = !accurate, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
552 |
rev = rev, afp_rev = afp_rev, afp_root = if (afp) afp_repos else None) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
553 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
554 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
555 |
def execute(command: String, args: String, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
556 |
echo: Boolean = false, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
557 |
strict: Boolean = true |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
558 |
): Unit = |
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
559 |
ssh.execute( |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
560 |
Isabelle_System.export_isabelle_identifier(isabelle_identifier) + |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
561 |
ssh.bash_path(isabelle_self + Path.explode(command)) + " " + args, |
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
562 |
progress_stdout = progress.echo_if(echo, _), |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
563 |
progress_stderr = progress.echo_if(echo, _), |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
564 |
strict = strict).check |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
565 |
|
75549 | 566 |
sync(isabelle_self) |
75520
65ecf4c5b868
removed obsolete self_update: always enabled, notably on lxbroy10 which is the only shared-home system (and still requires current isabelle_self);
wenzelm
parents:
75518
diff
changeset
|
567 |
execute("bin/isabelle", "components -I") |
65ecf4c5b868
removed obsolete self_update: always enabled, notably on lxbroy10 which is the only shared-home system (and still requires current isabelle_self);
wenzelm
parents:
75518
diff
changeset
|
568 |
execute("bin/isabelle", "components -a", echo = true) |
65ecf4c5b868
removed obsolete self_update: always enabled, notably on lxbroy10 which is the only shared-home system (and still requires current isabelle_self);
wenzelm
parents:
75518
diff
changeset
|
569 |
execute("bin/isabelle", "jedit -bf") |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
570 |
|
75549 | 571 |
sync(isabelle_other, accurate = true, |
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
572 |
rev = proper_string(rev) getOrElse "tip", |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
573 |
afp_rev = proper_string(afp_rev) getOrElse "tip", |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
574 |
afp = true) |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
575 |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
576 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
577 |
/* build */ |
73140 | 578 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
579 |
if (no_build) Nil |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
580 |
else { |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
581 |
ssh.with_tmp_dir { tmp_dir => |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
582 |
val output_file = tmp_dir + Path.explode("output") |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
583 |
val build_options = (if (afp_repos.isEmpty) "" else " -A") + " " + options |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
584 |
try { |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
585 |
execute("Admin/build_other", |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
586 |
"-o " + ssh.bash_path(output_file) + build_options + " " + |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
587 |
ssh.bash_path(isabelle_other) + " " + args, |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
588 |
echo = true, strict = false) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
589 |
} |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
590 |
catch { |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
591 |
case ERROR(msg) => |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
592 |
cat_error(msg, "The error(s) above occurred for Admin/build_other " + build_options) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
593 |
} |
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
594 |
|
75518
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
595 |
for (line <- split_lines(ssh.read(output_file))) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
596 |
yield { |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
597 |
val log = Path.explode(line) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
598 |
val bytes = ssh.read_bytes(log) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
599 |
ssh.rm(log) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
600 |
(log.file_name, bytes) |
cb4af8c6152f
clarified remote vs. local build_history: operate on hg_sync directory instead of repository;
wenzelm
parents:
75506
diff
changeset
|
601 |
} |
65929
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
602 |
} |
75394 | 603 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
604 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
605 |
} |