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