author | wenzelm |
Fri, 01 Apr 2022 17:06:10 +0200 | |
changeset 75393 | 87ebf5a50283 |
parent 74306 | a117c076aa22 |
child 75394 | 42267c650205 |
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 |
||
64050 | 92 |
/** build_history **/ |
64025 | 93 |
|
73522 | 94 |
private val default_user_home = Path.USER_HOME |
64025 | 95 |
private val default_rev = "tip" |
64301 | 96 |
private val default_multicore = (1, 1) |
64335 | 97 |
private val default_heap = 1500 |
64025 | 98 |
private val default_isabelle_identifier = "build_history" |
99 |
||
100 |
def build_history( |
|
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
101 |
options: Options, |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
102 |
root: Path, |
67047 | 103 |
user_home: Path = default_user_home, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71632
diff
changeset
|
104 |
progress: Progress = new Progress, |
64025 | 105 |
rev: String = default_rev, |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
106 |
afp_rev: Option[String] = None, |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
107 |
afp_partition: Int = 0, |
64025 | 108 |
isabelle_identifier: String = default_isabelle_identifier, |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
109 |
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
|
110 |
component_repository: String = Components.default_component_repository, |
69434 | 111 |
components_base: Path = Components.default_components_base, |
64026 | 112 |
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
|
113 |
hostname: String = "", |
64052 | 114 |
multicore_base: Boolean = false, |
64301 | 115 |
multicore_list: List[(Int, Int)] = List(default_multicore), |
64030 | 116 |
arch_64: Boolean = false, |
117 |
heap: Int = default_heap, |
|
64036 | 118 |
max_heap: Option[Int] = None, |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
119 |
init_settings: List[String] = Nil, |
64030 | 120 |
more_settings: List[String] = Nil, |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
121 |
more_preferences: List[String] = Nil, |
64026 | 122 |
verbose: Boolean = false, |
64297 | 123 |
build_tags: List[String] = Nil, |
75393 | 124 |
build_args: List[String] = Nil |
125 |
): List[(Process_Result, Path)] = { |
|
64031 | 126 |
/* sanity checks */ |
127 |
||
73522 | 128 |
if (File.eq(Path.ISABELLE_HOME, root)) |
129 |
error("Repository coincides with ISABELLE_HOME=" + Path.ISABELLE_HOME.expand) |
|
64046 | 130 |
|
64301 | 131 |
for ((threads, _) <- multicore_list if threads < 1) |
132 |
error("Bad threads value < 1: " + threads) |
|
133 |
for ((_, processes) <- multicore_list if processes < 1) |
|
134 |
error("Bad processes value < 1: " + processes) |
|
64036 | 135 |
|
64030 | 136 |
if (heap < 100) error("Bad heap value < 100: " + heap) |
137 |
||
64036 | 138 |
if (max_heap.isDefined && max_heap.get < heap) |
139 |
error("Bad max_heap value < heap: " + max_heap.get) |
|
140 |
||
64031 | 141 |
System.getenv("ISABELLE_SETTINGS_PRESENT") match { |
142 |
case null | "" => |
|
143 |
case _ => error("Cannot run build_history within existing Isabelle settings environment") |
|
144 |
} |
|
145 |
||
146 |
||
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
147 |
/* checkout Isabelle + AFP repository */ |
64031 | 148 |
|
75393 | 149 |
def checkout(dir: Path, version: String): String = { |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
150 |
val hg = Mercurial.repository(dir) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
151 |
hg.update(rev = version, clean = true) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
152 |
progress.echo_if(verbose, hg.log(version, options = "-l1")) |
66866 | 153 |
hg.id(rev = version) |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
154 |
} |
64025 | 155 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
156 |
val isabelle_version = checkout(root, rev) |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
157 |
|
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
158 |
val afp_repos = root + Path.explode("AFP") |
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
159 |
val afp_version = afp_rev.map(checkout(afp_repos, _)) |
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
160 |
|
66862 | 161 |
val (afp_build_args, afp_sessions) = |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
162 |
if (afp_rev.isEmpty) (Nil, Nil) |
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
163 |
else { |
74036
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
164 |
val (opt, sessions) = { |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
165 |
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
|
166 |
else { |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
167 |
try { |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
168 |
val afp = AFP.init(options, afp_repos) |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
169 |
("-d", afp.partition(afp_partition)) |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
170 |
} 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
|
171 |
} |
57768f30d17c
more robust: avoid -D ~~/AFP/thys after crash of AFP.init (notably in AFP/1001c0dfced0);
wenzelm
parents:
74035
diff
changeset
|
172 |
} |
73184
a5998396051e
more robust: defer error in sessions structure to build process;
wenzelm
parents:
73183
diff
changeset
|
173 |
(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
|
174 |
} |
64025 | 175 |
|
64051 | 176 |
|
64052 | 177 |
/* main */ |
64043 | 178 |
|
67045 | 179 |
val other_isabelle = |
67047 | 180 |
Other_Isabelle(root, isabelle_identifier = isabelle_identifier, |
181 |
user_home = user_home, progress = progress) |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
182 |
|
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
|
183 |
val build_host = proper_string(hostname) getOrElse Isabelle_System.hostname() |
64117 | 184 |
val build_history_date = Date.now() |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
185 |
val build_group_id = build_host + ":" + build_history_date.time.ms |
64117 | 186 |
|
64051 | 187 |
var first_build = true |
75393 | 188 |
for ((threads, processes) <- multicore_list) yield { |
64052 | 189 |
/* init settings */ |
190 |
||
69388 | 191 |
val component_settings = |
69434 | 192 |
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
|
193 |
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
|
194 |
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
|
195 |
catalogs = List("main", "optional")) |
69388 | 196 |
other_isabelle.init_settings(component_settings ::: init_settings) |
73242 | 197 |
other_isabelle.resolve_components(echo = verbose) |
64117 | 198 |
val ml_platform = |
65845
b8ff63149256
proper init_settings, before inspecting ML_HOME etc;
wenzelm
parents:
65844
diff
changeset
|
199 |
augment_settings(other_isabelle, threads, arch_64, heap, max_heap, more_settings) |
64043 | 200 |
|
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
201 |
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
|
202 |
|
68219 | 203 |
val isabelle_output = |
204 |
other_isabelle.isabelle_home_user + Path.explode("heaps") + |
|
69166 | 205 |
Path.explode(other_isabelle.getenv("ML_IDENTIFIER")) |
64052 | 206 |
val isabelle_output_log = isabelle_output + Path.explode("log") |
207 |
val isabelle_base_log = isabelle_output + Path.explode("../base_log") |
|
208 |
||
64051 | 209 |
if (first_build) { |
73242 | 210 |
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
|
211 |
|
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 |
if (fresh) |
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
|
213 |
Isabelle_System.rm_tree(other_isabelle.isabelle_home + Path.explode("lib/classes")) |
64051 | 214 |
other_isabelle.bash( |
215 |
"env PATH=\"" + File.bash_path(Path.explode("~~/lib/dummy_stty").expand) + ":$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 |
8bfa615ddde4
proper ghc_setup / ocaml_setup on target Isabelle distribution (amending 2a17c481d05e);
wenzelm
parents:
69243
diff
changeset
|
222 |
} other_isabelle(tool, echo = verbose) |
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 |
|
65909 | 230 |
val log_path = |
231 |
other_isabelle.isabelle_home_user + |
|
232 |
Build_Log.log_subdir(build_history_date) + |
|
233 |
Build_Log.log_filename(Build_History.engine, build_history_date, |
|
234 |
List(build_host, ml_platform, "M" + threads) ::: build_tags) |
|
235 |
||
72375 | 236 |
Isabelle_System.make_directory(log_path.dir) |
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
237 |
|
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
238 |
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
|
239 |
val build_out_progress = new File_Progress(build_out) |
65909 | 240 |
build_out.file.delete |
241 |
||
64052 | 242 |
|
243 |
/* build */ |
|
244 |
||
245 |
if (multicore_base && !first_build && isabelle_base_log.is_dir) |
|
64189 | 246 |
Isabelle_System.copy_dir(isabelle_base_log, isabelle_output_log) |
64052 | 247 |
|
64117 | 248 |
val build_start = Date.now() |
66862 | 249 |
val build_args1 = List("-v", "-j" + processes) ::: afp_build_args ::: build_args |
71967 | 250 |
|
251 |
val build_isabelle = |
|
67045 | 252 |
Other_Isabelle(root, isabelle_identifier = isabelle_identifier, |
71967 | 253 |
user_home = user_home, progress = build_out_progress) |
254 |
val build_result = |
|
255 |
build_isabelle("build " + Bash.strings(build_args1 ::: afp_sessions), |
|
256 |
redirect = true, echo = true, strict = false) |
|
257 |
||
64117 | 258 |
val build_end = Date.now() |
259 |
||
65646 | 260 |
val build_info: Build_Log.Build_Info = |
69366 | 261 |
Build_Log.Log_File(log_path.file_name, build_result.out_lines). |
65646 | 262 |
parse_build_info(ml_statistics = true) |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
263 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
264 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
265 |
/* output log */ |
64120 | 266 |
|
68221 | 267 |
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
|
268 |
|
64117 | 269 |
val meta_info = |
65624 | 270 |
Properties.lines_nonempty(Build_Log.Prop.build_tags.name, build_tags) ::: |
271 |
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
|
272 |
List( |
65591 | 273 |
Build_Log.Prop.build_group_id.name -> build_group_id, |
274 |
Build_Log.Prop.build_id.name -> (build_host + ":" + build_start.time.ms), |
|
275 |
Build_Log.Prop.build_engine.name -> Build_History.engine, |
|
276 |
Build_Log.Prop.build_host.name -> build_host, |
|
277 |
Build_Log.Prop.build_start.name -> Build_Log.print_date(build_start), |
|
278 |
Build_Log.Prop.build_end.name -> Build_Log.print_date(build_end), |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
279 |
Build_Log.Prop.isabelle_version.name -> isabelle_version) ::: |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
280 |
afp_version.map(Build_Log.Prop.afp_version.name -> _).toList |
64117 | 281 |
|
66913 | 282 |
build_out_progress.echo("Reading session build info ...") |
283 |
val session_build_info = |
|
75393 | 284 |
build_info.finished_sessions.flatMap(session_name => { |
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
285 |
val database = isabelle_output + store.database(session_name) |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
286 |
|
66913 | 287 |
if (database.is_file) { |
75393 | 288 |
using(SQLite.open_database(database))(db => { |
72014 | 289 |
val theory_timings = |
290 |
try { |
|
291 |
store.read_theory_timings(db, session_name).map(ps => |
|
292 |
Protocol.Theory_Timing_Marker((Build_Log.SESSION_NAME, session_name) :: ps)) |
|
293 |
} |
|
294 |
catch { case ERROR(_) => Nil } |
|
295 |
||
66913 | 296 |
val session_sources = |
297 |
store.read_build(db, session_name).map(_.sources) match { |
|
298 |
case Some(sources) if sources.length == SHA1.digest_length => |
|
299 |
List("Sources " + session_name + " " + sources) |
|
300 |
case _ => Nil |
|
301 |
} |
|
302 |
||
72020 | 303 |
theory_timings ::: session_sources |
66913 | 304 |
}) |
305 |
} |
|
306 |
else Nil |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
307 |
}) |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
308 |
|
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
309 |
build_out_progress.echo("Reading ML statistics ...") |
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
310 |
val ml_statistics = |
75393 | 311 |
build_info.finished_sessions.flatMap(session_name => { |
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
312 |
val database = isabelle_output + store.database(session_name) |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
313 |
val log_gz = isabelle_output + store.log_gz(session_name) |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
314 |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
315 |
val properties = |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
316 |
if (database.is_file) { |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
317 |
using(SQLite.open_database(database))(db => |
65935 | 318 |
store.read_ml_statistics(db, session_name)) |
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
319 |
} |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
320 |
else if (log_gz.is_file) { |
65318
342efc382558
eliminated somewhat redundant inlined name (despite a7aa17a1f721);
wenzelm
parents:
65296
diff
changeset
|
321 |
Build_Log.Log_File(log_gz).parse_session_info(ml_statistics = true).ml_statistics |
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
322 |
} |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
323 |
else Nil |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
324 |
|
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
325 |
val trimmed_properties = |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
326 |
if (ml_statistics_step <= 0) Nil |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
327 |
else if (ml_statistics_step == 1) properties |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
328 |
else { |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
329 |
(for { (ps, i) <- properties.iterator.zipWithIndex if i % ml_statistics_step == 0 } |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
330 |
yield ps).toList |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
331 |
} |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
332 |
|
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
333 |
trimmed_properties.map(ps => (Build_Log.SESSION_NAME -> session_name) :: ps) |
64120 | 334 |
}) |
335 |
||
65937 | 336 |
build_out_progress.echo("Reading error messages ...") |
337 |
val session_errors = |
|
75393 | 338 |
build_info.failed_sessions.flatMap(session_name => { |
65937 | 339 |
val database = isabelle_output + store.database(session_name) |
340 |
val errors = |
|
341 |
if (database.is_file) { |
|
342 |
try { |
|
343 |
using(SQLite.open_database(database))(db => store.read_errors(db, session_name)) |
|
344 |
} // column "errors" could be missing |
|
345 |
catch { case _: java.sql.SQLException => Nil } |
|
346 |
} |
|
347 |
else Nil |
|
348 |
errors.map(msg => List(Build_Log.SESSION_NAME -> session_name, Markup.CONTENT -> msg)) |
|
349 |
}) |
|
350 |
||
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
351 |
build_out_progress.echo("Reading heap sizes ...") |
64120 | 352 |
val heap_sizes = |
75393 | 353 |
build_info.finished_sessions.flatMap(session_name => { |
64120 | 354 |
val heap = isabelle_output + Path.explode(session_name) |
355 |
if (heap.is_file) |
|
356 |
Some("Heap " + session_name + " (" + Value.Long(heap.file.length) + " bytes)") |
|
357 |
else None |
|
358 |
}) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
359 |
|
72575 | 360 |
build_out_progress.echo("Writing log file " + log_path.xz + " ...") |
361 |
File.write_xz(log_path.xz, |
|
64173 | 362 |
terminate_lines( |
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71620
diff
changeset
|
363 |
Protocol.Meta_Info_Marker(meta_info) :: build_result.out_lines ::: |
66913 | 364 |
session_build_info ::: |
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71620
diff
changeset
|
365 |
ml_statistics.map(Protocol.ML_Statistics_Marker.apply) ::: |
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71620
diff
changeset
|
366 |
session_errors.map(Protocol.Error_Message_Marker.apply) ::: |
64253 | 367 |
heap_sizes), XZ.options(6)) |
64117 | 368 |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
369 |
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
370 |
/* next build */ |
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
371 |
|
64052 | 372 |
if (multicore_base && first_build && isabelle_output_log.is_dir) |
64189 | 373 |
Isabelle_System.copy_dir(isabelle_output_log, isabelle_base_log) |
64052 | 374 |
|
64260 | 375 |
Isabelle_System.rm_tree(isabelle_output) |
376 |
||
64052 | 377 |
first_build = false |
378 |
||
72575 | 379 |
(build_result, log_path.xz) |
64051 | 380 |
} |
64025 | 381 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
382 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
383 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
384 |
/* command line entry point */ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
385 |
|
75393 | 386 |
private object Multicore { |
64301 | 387 |
private val Pat1 = """^(\d+)$""".r |
388 |
private val Pat2 = """^(\d+)x(\d+)$""".r |
|
389 |
||
390 |
def parse(s: String): (Int, Int) = |
|
391 |
s match { |
|
392 |
case Pat1(Value.Int(x)) => (x, 1) |
|
393 |
case Pat2(Value.Int(x), Value.Int(y)) => (x, y) |
|
394 |
case _ => error("Bad multicore configuration: " + quote(s)) |
|
395 |
} |
|
396 |
} |
|
397 |
||
75393 | 398 |
def main(args: Array[String]): Unit = { |
71632 | 399 |
Command_Line.tool { |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
400 |
var afp_rev: Option[String] = None |
64052 | 401 |
var multicore_base = false |
69434 | 402 |
var components_base: Path = Components.default_components_base |
64030 | 403 |
var heap: Option[Int] = None |
64036 | 404 |
var max_heap: Option[Int] = None |
64301 | 405 |
var multicore_list = List(default_multicore) |
64025 | 406 |
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
|
407 |
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
|
408 |
var component_repository = Components.default_component_repository |
64030 | 409 |
var more_settings: List[String] = Nil |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
410 |
var more_preferences: List[String] = Nil |
64026 | 411 |
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
|
412 |
var hostname = "" |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
413 |
var init_settings: List[String] = Nil |
64030 | 414 |
var arch_64 = false |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
415 |
var output_file = "" |
64025 | 416 |
var rev = default_rev |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
417 |
var ml_statistics_step = 1 |
64297 | 418 |
var build_tags = List.empty[String] |
67047 | 419 |
var user_home = default_user_home |
64025 | 420 |
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
|
421 |
var exit_code = false |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
422 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
423 |
val getopts = Getopts(""" |
67047 | 424 |
Usage: Admin/build_history [OPTIONS] REPOSITORY [ARGS ...] |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
425 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
426 |
Options are: |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
427 |
-A REV include $ISABELLE_HOME/AFP repository at given revision |
64052 | 428 |
-B first multicore build serves as base for scheduling information |
69434 | 429 |
-C DIR base directory for Isabelle components (default: """ + |
430 |
Components.default_components_base + """) |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
431 |
-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
|
432 |
default_heap * 2 + """ for x86_64) |
64301 | 433 |
-M MULTICORE multicore configurations (see below) |
64025 | 434 |
-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
|
435 |
-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
|
436 |
-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
|
437 |
Components.default_component_repository + """) |
64036 | 438 |
-U SIZE maximal ML heap in MB (default: unbounded) |
64030 | 439 |
-e TEXT additional text for generated etc/settings |
64026 | 440 |
-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
|
441 |
-h NAME override local hostname |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
442 |
-i TEXT initial text for generated etc/settings |
64030 | 443 |
-m ARCH processor architecture (32=x86, 64=x86_64, default: x86) |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
444 |
-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
|
445 |
-p TEXT additional text for generated etc/preferences |
64026 | 446 |
-r REV update to revision (default: """ + default_rev + """) |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
447 |
-s NUMBER step size for ML statistics (0=none, 1=all, n=step, default: 1) |
64297 | 448 |
-t TAG free-form build tag (multiple occurrences possible) |
67047 | 449 |
-u DIR alternative USER_HOME directory |
64025 | 450 |
-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
|
451 |
-x return overall exit code from build processes |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
452 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
453 |
Build Isabelle sessions from the history of another REPOSITORY clone, |
64026 | 454 |
passing ARGS directly to its isabelle build tool. |
64301 | 455 |
|
456 |
Each MULTICORE configuration consists of one or two numbers (default 1): |
|
457 |
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
|
458 |
""", |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
459 |
"A:" -> (arg => afp_rev = Some(arg)), |
64052 | 460 |
"B" -> (_ => multicore_base = true), |
69434 | 461 |
"C:" -> (arg => components_base = Path.explode(arg)), |
64030 | 462 |
"H:" -> (arg => heap = Some(Value.Int.parse(arg))), |
71601 | 463 |
"M:" -> (arg => multicore_list = space_explode(',', arg).map(Multicore.parse)), |
64025 | 464 |
"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
|
465 |
"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
|
466 |
"R:" -> (arg => component_repository = arg), |
64036 | 467 |
"U:" -> (arg => max_heap = Some(Value.Int.parse(arg))), |
64030 | 468 |
"e:" -> (arg => more_settings = more_settings ::: List(arg)), |
64026 | 469 |
"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
|
470 |
"h:" -> (arg => hostname = arg), |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
471 |
"i:" -> (arg => init_settings = init_settings ::: List(arg)), |
64030 | 472 |
"m:" -> |
473 |
{ |
|
474 |
case "32" | "x86" => arch_64 = false |
|
475 |
case "64" | "x86_64" => arch_64 = true |
|
476 |
case bad => error("Bad processor architecture: " + quote(bad)) |
|
477 |
}, |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
478 |
"o:" -> (arg => output_file = arg), |
71998
f43b08980f56
support generated preferences, i.e. non-strict system options;
wenzelm
parents:
71967
diff
changeset
|
479 |
"p:" -> (arg => more_preferences = more_preferences ::: List(arg)), |
64025 | 480 |
"r:" -> (arg => rev = arg), |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
481 |
"s:" -> (arg => ml_statistics_step = Value.Int.parse(arg)), |
64297 | 482 |
"t:" -> (arg => build_tags = build_tags ::: List(arg)), |
67047 | 483 |
"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
|
484 |
"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
|
485 |
"x" -> (_ => exit_code = true)) |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
486 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
487 |
val more_args = getopts(args) |
64026 | 488 |
val (root, build_args) = |
489 |
more_args match { |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
490 |
case root :: build_args => (Path.explode(root), build_args) |
64026 | 491 |
case _ => getopts.usage() |
492 |
} |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
493 |
|
64162 | 494 |
val progress = new Console_Progress(stderr = true) |
64346 | 495 |
|
64162 | 496 |
val results = |
67047 | 497 |
build_history(Options.init(), root, user_home = user_home, progress = progress, rev = rev, |
498 |
afp_rev = afp_rev, afp_partition = afp_partition, |
|
499 |
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
|
500 |
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
|
501 |
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
|
502 |
multicore_list = multicore_list, arch_64 = arch_64, |
67047 | 503 |
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
|
504 |
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
|
505 |
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
|
506 |
build_args = build_args) |
64162 | 507 |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
508 |
if (output_file == "") { |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
509 |
for ((_, log_path) <- results) |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
510 |
Output.writeln(log_path.implode, stdout = true) |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
511 |
} |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
512 |
else { |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
513 |
File.write(Path.explode(output_file), |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
514 |
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
|
515 |
} |
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
|
516 |
|
74306 | 517 |
val rc = results.foldLeft(Process_Result.RC.ok) { case (rc, (res, _)) => rc max res.rc } |
518 |
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
|
519 |
} |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
520 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
521 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
522 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
523 |
|
64225 | 524 |
/** remote build_history -- via command-line **/ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
525 |
|
64225 | 526 |
def remote_build_history( |
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
527 |
ssh: SSH.Session, |
64227 | 528 |
isabelle_repos_self: Path, |
529 |
isabelle_repos_other: Path, |
|
73611 | 530 |
isabelle_repository: Mercurial.Server = Isabelle_System.isabelle_repository, |
531 |
afp_repository: Mercurial.Server = Isabelle_System.afp_repository, |
|
65928
38eb5d633b0b
avoid conflict with generated settings of other_isabelle;
wenzelm
parents:
65927
diff
changeset
|
532 |
isabelle_identifier: String = "remote_build_history", |
64227 | 533 |
self_update: Boolean = false, |
71726
a5fda30edae2
clarified signature: more uniform treatment of stopped/interrupted state;
wenzelm
parents:
71632
diff
changeset
|
534 |
progress: Progress = new Progress, |
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
535 |
rev: String = "", |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
536 |
afp_rev: Option[String] = None, |
64227 | 537 |
options: String = "", |
75393 | 538 |
args: String = "" |
539 |
): List[(String, Bytes)] = { |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
540 |
/* Isabelle self repository */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
541 |
|
67754
197366313aaf
self_update implies push_isabelle_home (see also 4c253e84ae62);
wenzelm
parents:
67753
diff
changeset
|
542 |
val self_hg = |
73611 | 543 |
Mercurial.setup_repository(isabelle_repository.root, isabelle_repos_self, ssh = ssh) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
544 |
|
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
545 |
def execute(cmd: String, args: String, echo: Boolean = false, strict: Boolean = true): Unit = |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
546 |
ssh.execute( |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
547 |
Isabelle_System.export_isabelle_identifier(isabelle_identifier) + |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
548 |
ssh.bash_path(isabelle_repos_self + Path.explode(cmd)) + " " + args, |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
549 |
progress_stdout = progress.echo_if(echo, _), |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
550 |
progress_stderr = progress.echo_if(echo, _), |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
551 |
strict = strict).check |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
552 |
|
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
553 |
if (self_update) { |
73522 | 554 |
val hg = Mercurial.repository(Path.ISABELLE_HOME) |
67756
d2fe32ebe3c7
clarified self_update: imitate visible directory state on remote side;
wenzelm
parents:
67754
diff
changeset
|
555 |
hg.push(self_hg.root_url, force = true) |
d2fe32ebe3c7
clarified self_update: imitate visible directory state on remote side;
wenzelm
parents:
67754
diff
changeset
|
556 |
self_hg.update(rev = hg.parent(), clean = true) |
67754
197366313aaf
self_update implies push_isabelle_home (see also 4c253e84ae62);
wenzelm
parents:
67753
diff
changeset
|
557 |
|
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
558 |
execute("bin/isabelle", "components -I") |
66878 | 559 |
execute("bin/isabelle", "components -a", echo = true) |
74035 | 560 |
execute("bin/isabelle", "jedit -bf") |
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
561 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
562 |
|
67773 | 563 |
val rev_id = self_hg.id(rev) |
564 |
||
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
565 |
|
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
566 |
/* Isabelle other + AFP repository */ |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
567 |
|
66570 | 568 |
if (Mercurial.is_repository(isabelle_repos_other, ssh = ssh)) { |
66107
8c8e77dbe6fe
more robust: do not touch unrelated directory isabelle_repos_other (i.e. bad argument);
wenzelm
parents:
66106
diff
changeset
|
569 |
ssh.rm_tree(isabelle_repos_other) |
8c8e77dbe6fe
more robust: do not touch unrelated directory isabelle_repos_other (i.e. bad argument);
wenzelm
parents:
66106
diff
changeset
|
570 |
} |
73006 | 571 |
|
572 |
Mercurial.clone_repository( |
|
573 |
ssh.bash_path(isabelle_repos_self), isabelle_repos_other, rev = rev_id, ssh = ssh) |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
574 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
575 |
val afp_options = |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
576 |
if (afp_rev.isEmpty) "" |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
577 |
else { |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
578 |
val afp_repos = isabelle_repos_other + Path.explode("AFP") |
73611 | 579 |
Mercurial.setup_repository(afp_repository.root, afp_repos, ssh = ssh) |
73140 | 580 |
" -A " + Bash.string(afp_rev.get) |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
581 |
} |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
582 |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
583 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
584 |
/* Admin/build_history */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
585 |
|
75393 | 586 |
ssh.with_tmp_dir(tmp_dir => { |
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
587 |
val output_file = tmp_dir + Path.explode("output") |
64346 | 588 |
|
73140 | 589 |
val rev_options = if (rev == "") "" else " -r " + Bash.string(rev_id) |
590 |
||
591 |
try { |
|
592 |
execute("Admin/build_history", |
|
593 |
"-o " + ssh.bash_path(output_file) + rev_options + afp_options + " " + options + " " + |
|
594 |
ssh.bash_path(isabelle_repos_other) + " " + args, |
|
595 |
echo = true, strict = false) |
|
596 |
} |
|
597 |
catch { |
|
598 |
case ERROR(msg) => |
|
599 |
cat_error(msg, |
|
600 |
"The error(s) above occurred for build_bistory " + rev_options + afp_options) |
|
601 |
} |
|
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
602 |
|
65929
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
603 |
for (line <- split_lines(ssh.read(output_file))) |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
604 |
yield { |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
605 |
val log = Path.explode(line) |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
606 |
val bytes = ssh.read_bytes(log) |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
607 |
ssh.rm(log) |
69366 | 608 |
(log.file_name, bytes) |
65929
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
609 |
} |
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
610 |
}) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
611 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
612 |
} |