author | wenzelm |
Tue, 17 Oct 2017 13:56:58 +0200 | |
changeset 66878 | 91da58bb560d |
parent 66877 | 4f0ccfe1bcb6 |
child 66913 | 7cdd4d59e95c |
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 |
import java.io.{File => JFile} |
64117 | 11 |
import java.time.format.DateTimeFormatter |
64118 | 12 |
import java.util.Locale |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
13 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
14 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
15 |
object Build_History |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
16 |
{ |
64117 | 17 |
/* log files */ |
18 |
||
65588 | 19 |
val engine = "build_history" |
65596 | 20 |
val log_prefix = engine + "_" |
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
21 |
val META_INFO_MARKER = "\fmeta_info = " |
64117 | 22 |
|
23 |
||
64188 | 24 |
/* augment settings */ |
64050 | 25 |
|
64188 | 26 |
def augment_settings( |
27 |
other_isabelle: Other_Isabelle, |
|
28 |
threads: Int, |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
29 |
arch_64: Boolean, |
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
30 |
heap: Int, |
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
31 |
max_heap: Option[Int], |
64188 | 32 |
more_settings: List[String]): String = |
33 |
{ |
|
34 |
val (ml_platform, ml_settings) = |
|
35 |
{ |
|
36 |
val windows_32 = "x86-windows" |
|
37 |
val windows_64 = "x86_64-windows" |
|
38 |
val platform_32 = other_isabelle("getenv -b ISABELLE_PLATFORM32").check.out |
|
39 |
val platform_64 = other_isabelle("getenv -b ISABELLE_PLATFORM64").check.out |
|
40 |
val platform_family = other_isabelle("getenv -b ISABELLE_PLATFORM_FAMILY").check.out |
|
64049 | 41 |
|
64188 | 42 |
val polyml_home = |
43 |
try { Path.explode(other_isabelle("getenv -b ML_HOME").check.out).dir } |
|
44 |
catch { case ERROR(msg) => error("Bad ML_HOME: " + msg) } |
|
64049 | 45 |
|
64188 | 46 |
def ml_home(platform: String): Path = polyml_home + Path.explode(platform) |
64049 | 47 |
|
64188 | 48 |
def err(platform: String): Nothing = |
49 |
error("Platform " + platform + " unavailable on this machine") |
|
64050 | 50 |
|
64188 | 51 |
def check_dir(platform: String): Boolean = |
52 |
platform != "" && ml_home(platform).is_dir |
|
64050 | 53 |
|
64188 | 54 |
val ml_platform = |
55 |
if (Platform.is_windows && arch_64) { |
|
56 |
if (check_dir(windows_64)) windows_64 else err(windows_64) |
|
57 |
} |
|
58 |
else if (Platform.is_windows && !arch_64) { |
|
59 |
if (check_dir(windows_32)) windows_32 |
|
60 |
else platform_32 // x86-cygwin |
|
61 |
} |
|
62 |
else { |
|
63 |
val (platform, platform_name) = |
|
64 |
if (arch_64) (platform_64, "x86_64-" + platform_family) |
|
65 |
else (platform_32, "x86-" + platform_family) |
|
66 |
if (check_dir(platform)) platform else err(platform_name) |
|
67 |
} |
|
64050 | 68 |
|
64188 | 69 |
val ml_options = |
70 |
"--minheap " + heap + (if (max_heap.isDefined) " --maxheap " + max_heap.get else "") + |
|
71 |
" --gcthreads " + threads + |
|
72 |
(if (ml_platform.endsWith("-windows")) " --codepage utf8" else "") |
|
64050 | 73 |
|
64188 | 74 |
(ml_platform, |
75 |
List( |
|
76 |
"ML_HOME=" + File.bash_path(ml_home(ml_platform)), |
|
77 |
"ML_PLATFORM=" + quote(ml_platform), |
|
78 |
"ML_OPTIONS=" + quote(ml_options))) |
|
64050 | 79 |
} |
80 |
||
64188 | 81 |
val thread_settings = |
82 |
List( |
|
83 |
"ISABELLE_JAVA_SYSTEM_OPTIONS=\"$ISABELLE_JAVA_SYSTEM_OPTIONS -Disabelle.threads=" + threads + "\"", |
|
84 |
"ISABELLE_BUILD_OPTIONS=\"threads=" + threads + "\"") |
|
64050 | 85 |
|
64188 | 86 |
val settings = |
87 |
List(ml_settings, thread_settings) ::: |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
88 |
(if (more_settings.isEmpty) Nil else List(more_settings)) |
64050 | 89 |
|
64188 | 90 |
File.append(other_isabelle.etc_settings, "\n" + cat_lines(settings.map(terminate_lines(_)))) |
64050 | 91 |
|
64188 | 92 |
ml_platform |
64049 | 93 |
} |
94 |
||
95 |
||
96 |
||
64050 | 97 |
/** build_history **/ |
64025 | 98 |
|
99 |
private val default_rev = "tip" |
|
64301 | 100 |
private val default_multicore = (1, 1) |
64335 | 101 |
private val default_heap = 1500 |
64025 | 102 |
private val default_isabelle_identifier = "build_history" |
103 |
||
104 |
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
|
105 |
options: Options, |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
106 |
root: Path, |
64909 | 107 |
progress: Progress = No_Progress, |
64025 | 108 |
rev: String = default_rev, |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
109 |
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
|
110 |
afp_partition: Int = 0, |
64025 | 111 |
isabelle_identifier: String = default_isabelle_identifier, |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
112 |
ml_statistics_step: Int = 1, |
64025 | 113 |
components_base: String = "", |
64026 | 114 |
fresh: Boolean = false, |
64025 | 115 |
nonfree: Boolean = false, |
64052 | 116 |
multicore_base: Boolean = false, |
64301 | 117 |
multicore_list: List[(Int, Int)] = List(default_multicore), |
64030 | 118 |
arch_64: Boolean = false, |
119 |
heap: Int = default_heap, |
|
64036 | 120 |
max_heap: Option[Int] = None, |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
121 |
init_settings: List[String] = Nil, |
64030 | 122 |
more_settings: List[String] = Nil, |
64026 | 123 |
verbose: Boolean = false, |
64297 | 124 |
build_tags: List[String] = Nil, |
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
125 |
build_args: List[String] = Nil): List[(Process_Result, Path)] = |
64025 | 126 |
{ |
64031 | 127 |
/* sanity checks */ |
128 |
||
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
129 |
if (File.eq(Path.explode("~~"), root)) |
64046 | 130 |
error("Repository coincides with ISABELLE_HOME=" + Path.explode("~~").expand) |
131 |
||
64301 | 132 |
for ((threads, _) <- multicore_list if threads < 1) |
133 |
error("Bad threads value < 1: " + threads) |
|
134 |
for ((_, processes) <- multicore_list if processes < 1) |
|
135 |
error("Bad processes value < 1: " + processes) |
|
64036 | 136 |
|
64030 | 137 |
if (heap < 100) error("Bad heap value < 100: " + heap) |
138 |
||
64036 | 139 |
if (max_heap.isDefined && max_heap.get < heap) |
140 |
error("Bad max_heap value < heap: " + max_heap.get) |
|
141 |
||
64031 | 142 |
System.getenv("ISABELLE_SETTINGS_PRESENT") match { |
143 |
case null | "" => |
|
144 |
case _ => error("Cannot run build_history within existing Isabelle settings environment") |
|
145 |
} |
|
146 |
||
147 |
||
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
148 |
/* checkout Isabelle + AFP repository */ |
64031 | 149 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
150 |
def checkout(dir: Path, version: String): String = |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
151 |
{ |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
152 |
val hg = Mercurial.repository(dir) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
153 |
hg.update(rev = version, clean = true) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
154 |
progress.echo_if(verbose, hg.log(version, options = "-l1")) |
66866 | 155 |
hg.id(rev = version) |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
156 |
} |
64025 | 157 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
158 |
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
|
159 |
|
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
160 |
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
|
161 |
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
|
162 |
|
66862 | 163 |
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
|
164 |
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
|
165 |
else { |
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
166 |
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
|
167 |
(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
|
168 |
} |
64025 | 169 |
|
64051 | 170 |
|
64052 | 171 |
/* main */ |
64043 | 172 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
173 |
val other_isabelle = new Other_Isabelle(progress, root, isabelle_identifier) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
174 |
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
175 |
val build_host = 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 |
||
65845
b8ff63149256
proper init_settings, before inspecting ML_HOME etc;
wenzelm
parents:
65844
diff
changeset
|
184 |
other_isabelle.init_settings(components_base, nonfree, init_settings) |
64051 | 185 |
other_isabelle.resolve_components(verbose) |
64117 | 186 |
val ml_platform = |
65845
b8ff63149256
proper init_settings, before inspecting ML_HOME etc;
wenzelm
parents:
65844
diff
changeset
|
187 |
augment_settings(other_isabelle, threads, arch_64, heap, max_heap, more_settings) |
64043 | 188 |
|
64052 | 189 |
val isabelle_output = Path.explode(other_isabelle("getenv -b ISABELLE_OUTPUT").check.out) |
190 |
val isabelle_output_log = isabelle_output + Path.explode("log") |
|
191 |
val isabelle_base_log = isabelle_output + Path.explode("../base_log") |
|
192 |
||
64051 | 193 |
if (first_build) { |
194 |
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
|
195 |
|
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
|
196 |
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
|
197 |
Isabelle_System.rm_tree(other_isabelle.isabelle_home + Path.explode("lib/classes")) |
64051 | 198 |
other_isabelle.bash( |
199 |
"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
|
200 |
"bin/isabelle jedit -b", redirect = true, echo = verbose).check |
64052 | 201 |
|
64213 | 202 |
Isabelle_System.rm_tree(isabelle_base_log) |
64051 | 203 |
} |
64025 | 204 |
|
64213 | 205 |
Isabelle_System.rm_tree(isabelle_output) |
64052 | 206 |
Isabelle_System.mkdirs(isabelle_output) |
207 |
||
65909 | 208 |
val log_path = |
209 |
other_isabelle.isabelle_home_user + |
|
210 |
Build_Log.log_subdir(build_history_date) + |
|
211 |
Build_Log.log_filename(Build_History.engine, build_history_date, |
|
212 |
List(build_host, ml_platform, "M" + threads) ::: build_tags) |
|
213 |
||
214 |
Isabelle_System.mkdirs(log_path.dir) |
|
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
215 |
|
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
216 |
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
|
217 |
val build_out_progress = new File_Progress(build_out) |
65909 | 218 |
build_out.file.delete |
219 |
||
64052 | 220 |
|
221 |
/* build */ |
|
222 |
||
223 |
if (multicore_base && !first_build && isabelle_base_log.is_dir) |
|
64189 | 224 |
Isabelle_System.copy_dir(isabelle_base_log, isabelle_output_log) |
64052 | 225 |
|
64117 | 226 |
val build_start = Date.now() |
66862 | 227 |
val build_args1 = List("-v", "-j" + processes) ::: afp_build_args ::: build_args |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
228 |
val build_result = |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
229 |
(new Other_Isabelle(build_out_progress, root, isabelle_identifier))( |
66862 | 230 |
"build " + Bash.strings(build_args1 ::: afp_sessions), redirect = true, echo = true, |
231 |
strict = false) |
|
64117 | 232 |
val build_end = Date.now() |
233 |
||
65646 | 234 |
val build_info: Build_Log.Build_Info = |
65999 | 235 |
Build_Log.Log_File(log_path.base_name, build_result.out_lines). |
65646 | 236 |
parse_build_info(ml_statistics = true) |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
237 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
238 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
239 |
/* output log */ |
64120 | 240 |
|
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
241 |
val store = Sessions.store() |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
242 |
|
64117 | 243 |
val meta_info = |
65624 | 244 |
Properties.lines_nonempty(Build_Log.Prop.build_tags.name, build_tags) ::: |
245 |
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
|
246 |
List( |
65591 | 247 |
Build_Log.Prop.build_group_id.name -> build_group_id, |
248 |
Build_Log.Prop.build_id.name -> (build_host + ":" + build_start.time.ms), |
|
249 |
Build_Log.Prop.build_engine.name -> Build_History.engine, |
|
250 |
Build_Log.Prop.build_host.name -> build_host, |
|
251 |
Build_Log.Prop.build_start.name -> Build_Log.print_date(build_start), |
|
252 |
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
|
253 |
Build_Log.Prop.isabelle_version.name -> isabelle_version) ::: |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
254 |
afp_version.map(Build_Log.Prop.afp_version.name -> _).toList |
64117 | 255 |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
256 |
build_out_progress.echo("Reading theory timings ...") |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
257 |
val theory_timings = |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
258 |
build_info.finished_sessions.flatMap(session_name => |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
259 |
{ |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
260 |
val database = isabelle_output + store.database(session_name) |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
261 |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
262 |
val properties = |
66875 | 263 |
if (database.is_file) { |
264 |
using(SQLite.open_database(database))(db => |
|
265 |
try { store.read_theory_timings(db, session_name) } |
|
266 |
catch { case ERROR(_) => Nil }) |
|
267 |
} |
|
268 |
else Nil |
|
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
269 |
|
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
270 |
properties.map(ps => (Build_Log.SESSION_NAME -> session_name) :: ps) |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
271 |
}) |
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
272 |
|
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
273 |
build_out_progress.echo("Reading ML statistics ...") |
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
274 |
val ml_statistics = |
64120 | 275 |
build_info.finished_sessions.flatMap(session_name => |
276 |
{ |
|
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
277 |
val database = isabelle_output + store.database(session_name) |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
278 |
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
|
279 |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
280 |
val properties = |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
281 |
if (database.is_file) { |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
282 |
using(SQLite.open_database(database))(db => |
65935 | 283 |
store.read_ml_statistics(db, session_name)) |
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
284 |
} |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
285 |
else if (log_gz.is_file) { |
65318
342efc382558
eliminated somewhat redundant inlined name (despite a7aa17a1f721);
wenzelm
parents:
65296
diff
changeset
|
286 |
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
|
287 |
} |
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
288 |
else Nil |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
289 |
|
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
290 |
val trimmed_properties = |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
291 |
if (ml_statistics_step <= 0) Nil |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
292 |
else if (ml_statistics_step == 1) properties |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
293 |
else { |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
294 |
(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
|
295 |
yield ps).toList |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
296 |
} |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
297 |
|
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
298 |
trimmed_properties.map(ps => (Build_Log.SESSION_NAME -> session_name) :: ps) |
64120 | 299 |
}) |
300 |
||
65937 | 301 |
build_out_progress.echo("Reading error messages ...") |
302 |
val session_errors = |
|
303 |
build_info.failed_sessions.flatMap(session_name => |
|
304 |
{ |
|
305 |
val database = isabelle_output + store.database(session_name) |
|
306 |
val errors = |
|
307 |
if (database.is_file) { |
|
308 |
try { |
|
309 |
using(SQLite.open_database(database))(db => store.read_errors(db, session_name)) |
|
310 |
} // column "errors" could be missing |
|
311 |
catch { case _: java.sql.SQLException => Nil } |
|
312 |
} |
|
313 |
else Nil |
|
314 |
errors.map(msg => List(Build_Log.SESSION_NAME -> session_name, Markup.CONTENT -> msg)) |
|
315 |
}) |
|
316 |
||
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
317 |
build_out_progress.echo("Reading heap sizes ...") |
64120 | 318 |
val heap_sizes = |
319 |
build_info.finished_sessions.flatMap(session_name => |
|
320 |
{ |
|
321 |
val heap = isabelle_output + Path.explode(session_name) |
|
322 |
if (heap.is_file) |
|
323 |
Some("Heap " + session_name + " (" + Value.Long(heap.file.length) + " bytes)") |
|
324 |
else None |
|
325 |
}) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
326 |
|
65927
23a1e2fa5c8a
more progress information, for the sake of sporadic dropouts;
wenzelm
parents:
65917
diff
changeset
|
327 |
build_out_progress.echo("Writing log file " + log_path.ext("xz") + " ...") |
64253 | 328 |
File.write_xz(log_path.ext("xz"), |
64173 | 329 |
terminate_lines( |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
330 |
Build_Log.Log_File.print_props(META_INFO_MARKER, meta_info) :: build_result.out_lines ::: |
66874
0b8da0fc9563
store theory timings in session in build_log database;
wenzelm
parents:
66871
diff
changeset
|
331 |
theory_timings.map(Build_Log.Log_File.print_props(Build_Log.THEORY_TIMING_MARKER, _)) ::: |
64120 | 332 |
ml_statistics.map(Build_Log.Log_File.print_props(Build_Log.ML_STATISTICS_MARKER, _)) ::: |
65937 | 333 |
session_errors.map(Build_Log.Log_File.print_props(Build_Log.ERROR_MESSAGE_MARKER, _)) ::: |
64253 | 334 |
heap_sizes), XZ.options(6)) |
64117 | 335 |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
336 |
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
337 |
/* next build */ |
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
338 |
|
64052 | 339 |
if (multicore_base && first_build && isabelle_output_log.is_dir) |
64189 | 340 |
Isabelle_System.copy_dir(isabelle_output_log, isabelle_base_log) |
64052 | 341 |
|
64260 | 342 |
Isabelle_System.rm_tree(isabelle_output) |
343 |
||
64052 | 344 |
first_build = false |
345 |
||
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
346 |
(build_result, log_path.ext("xz")) |
64051 | 347 |
} |
64025 | 348 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
349 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
350 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
351 |
/* command line entry point */ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
352 |
|
64301 | 353 |
private object Multicore |
354 |
{ |
|
355 |
private val Pat1 = """^(\d+)$""".r |
|
356 |
private val Pat2 = """^(\d+)x(\d+)$""".r |
|
357 |
||
358 |
def parse(s: String): (Int, Int) = |
|
359 |
s match { |
|
360 |
case Pat1(Value.Int(x)) => (x, 1) |
|
361 |
case Pat2(Value.Int(x), Value.Int(y)) => (x, y) |
|
362 |
case _ => error("Bad multicore configuration: " + quote(s)) |
|
363 |
} |
|
364 |
} |
|
365 |
||
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
366 |
def main(args: Array[String]) |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
367 |
{ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
368 |
Command_Line.tool0 { |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
369 |
var afp_rev: Option[String] = None |
64052 | 370 |
var multicore_base = false |
64025 | 371 |
var components_base = "" |
64030 | 372 |
var heap: Option[Int] = None |
64036 | 373 |
var max_heap: Option[Int] = None |
64301 | 374 |
var multicore_list = List(default_multicore) |
64025 | 375 |
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
|
376 |
var afp_partition = 0 |
64030 | 377 |
var more_settings: List[String] = Nil |
64026 | 378 |
var fresh = false |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
379 |
var init_settings: List[String] = Nil |
64030 | 380 |
var arch_64 = false |
64025 | 381 |
var nonfree = false |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
382 |
var output_file = "" |
64025 | 383 |
var rev = default_rev |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
384 |
var ml_statistics_step = 1 |
64297 | 385 |
var build_tags = List.empty[String] |
64025 | 386 |
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
|
387 |
var exit_code = false |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
388 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
389 |
val getopts = Getopts(""" |
64026 | 390 |
Usage: isabelle build_history [OPTIONS] REPOSITORY [ARGS ...] |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
391 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
392 |
Options are: |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
393 |
-A REV include $ISABELLE_HOME/AFP repository at given revision |
64052 | 394 |
-B first multicore build serves as base for scheduling information |
64025 | 395 |
-C DIR base directory for Isabelle components (default: $ISABELLE_HOME_USER/../contrib) |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
396 |
-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
|
397 |
default_heap * 2 + """ for x86_64) |
64301 | 398 |
-M MULTICORE multicore configurations (see below) |
64025 | 399 |
-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
|
400 |
-P NUMBER AFP partition number (0, 1, 2, default: 0=unrestricted) |
64036 | 401 |
-U SIZE maximal ML heap in MB (default: unbounded) |
64030 | 402 |
-e TEXT additional text for generated etc/settings |
64026 | 403 |
-f fresh build of Isabelle/Scala components (recommended) |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
404 |
-i TEXT initial text for generated etc/settings |
64030 | 405 |
-m ARCH processor architecture (32=x86, 64=x86_64, default: x86) |
64025 | 406 |
-n include nonfree components |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
407 |
-o FILE output file for log names (default: stdout) |
64026 | 408 |
-r REV update to revision (default: """ + default_rev + """) |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
409 |
-s NUMBER step size for ML statistics (0=none, 1=all, n=step, default: 1) |
64297 | 410 |
-t TAG free-form build tag (multiple occurrences possible) |
64025 | 411 |
-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
|
412 |
-x return overall exit code from build processes |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
413 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
414 |
Build Isabelle sessions from the history of another REPOSITORY clone, |
64026 | 415 |
passing ARGS directly to its isabelle build tool. |
64301 | 416 |
|
417 |
Each MULTICORE configuration consists of one or two numbers (default 1): |
|
418 |
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
|
419 |
""", |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
420 |
"A:" -> (arg => afp_rev = Some(arg)), |
64052 | 421 |
"B" -> (_ => multicore_base = true), |
64025 | 422 |
"C:" -> (arg => components_base = arg), |
64030 | 423 |
"H:" -> (arg => heap = Some(Value.Int.parse(arg))), |
64301 | 424 |
"M:" -> (arg => multicore_list = space_explode(',', arg).map(Multicore.parse(_))), |
64025 | 425 |
"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
|
426 |
"P:" -> (arg => afp_partition = Value.Int.parse(arg)), |
64036 | 427 |
"U:" -> (arg => max_heap = Some(Value.Int.parse(arg))), |
64030 | 428 |
"e:" -> (arg => more_settings = more_settings ::: List(arg)), |
64026 | 429 |
"f" -> (_ => fresh = true), |
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
430 |
"i:" -> (arg => init_settings = init_settings ::: List(arg)), |
64030 | 431 |
"m:" -> |
432 |
{ |
|
433 |
case "32" | "x86" => arch_64 = false |
|
434 |
case "64" | "x86_64" => arch_64 = true |
|
435 |
case bad => error("Bad processor architecture: " + quote(bad)) |
|
436 |
}, |
|
64025 | 437 |
"n" -> (_ => nonfree = true), |
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
438 |
"o:" -> (arg => output_file = arg), |
64025 | 439 |
"r:" -> (arg => rev = arg), |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
440 |
"s:" -> (arg => ml_statistics_step = Value.Int.parse(arg)), |
64297 | 441 |
"t:" -> (arg => build_tags = build_tags ::: List(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
|
442 |
"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
|
443 |
"x" -> (_ => exit_code = true)) |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
444 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
445 |
val more_args = getopts(args) |
64026 | 446 |
val (root, build_args) = |
447 |
more_args match { |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
448 |
case root :: build_args => (Path.explode(root), build_args) |
64026 | 449 |
case _ => getopts.usage() |
450 |
} |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
451 |
|
64162 | 452 |
val progress = new Console_Progress(stderr = true) |
64346 | 453 |
|
64162 | 454 |
val results = |
66861
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
455 |
build_history(Options.init(), root, progress = progress, rev = rev, afp_rev = afp_rev, |
f6676691ef8a
partition AFP sessions according to structure, which happens to cut it roughly into equal parts;
wenzelm
parents:
66860
diff
changeset
|
456 |
afp_partition = afp_partition, isabelle_identifier = isabelle_identifier, |
66867
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
457 |
ml_statistics_step = ml_statistics_step, components_base = components_base, fresh = fresh, |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
458 |
nonfree = nonfree, multicore_base = multicore_base, multicore_list = multicore_list, |
b00d8e1f8ddd
added ml_statistics_step to trim stored properties;
wenzelm
parents:
66866
diff
changeset
|
459 |
arch_64 = arch_64, 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
|
460 |
max_heap = max_heap, init_settings = init_settings, more_settings = more_settings, |
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
461 |
verbose = verbose, build_tags = build_tags, build_args = build_args) |
64162 | 462 |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
463 |
if (output_file == "") { |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
464 |
for ((_, log_path) <- results) |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
465 |
Output.writeln(log_path.implode, stdout = true) |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
466 |
} |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
467 |
else { |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
468 |
File.write(Path.explode(output_file), |
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
469 |
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
|
470 |
} |
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
|
471 |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
472 |
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
|
473 |
if (rc != 0 && exit_code) sys.exit(rc) |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
474 |
} |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
475 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
476 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
477 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
478 |
|
64225 | 479 |
/** remote build_history -- via command-line **/ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
480 |
|
64225 | 481 |
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
|
482 |
ssh: SSH.Session, |
64227 | 483 |
isabelle_repos_self: Path, |
484 |
isabelle_repos_other: Path, |
|
485 |
isabelle_repos_source: String = "http://isabelle.in.tum.de/repos/isabelle", |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
486 |
afp_repos_source: String = AFP.repos_source, |
65928
38eb5d633b0b
avoid conflict with generated settings of other_isabelle;
wenzelm
parents:
65927
diff
changeset
|
487 |
isabelle_identifier: String = "remote_build_history", |
64227 | 488 |
self_update: Boolean = false, |
64348
4c253e84ae62
clarified push/pull chain: current ISABELLE_HOME may server as source for changes that are not published on isabelle_repos_source yet (e.g. isabelle-release branch);
wenzelm
parents:
64346
diff
changeset
|
489 |
push_isabelle_home: Boolean = false, |
64909 | 490 |
progress: Progress = No_Progress, |
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
491 |
rev: String = "", |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
492 |
afp_rev: Option[String] = None, |
64227 | 493 |
options: String = "", |
65929
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
494 |
args: String = ""): List[(String, Bytes)] = |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
495 |
{ |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
496 |
/* Isabelle self repository */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
497 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
498 |
val isabelle_hg = |
66570 | 499 |
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
|
500 |
|
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
501 |
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
|
502 |
ssh.execute( |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
503 |
Isabelle_System.export_isabelle_identifier(isabelle_identifier) + |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
504 |
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
|
505 |
progress_stdout = progress.echo_if(echo, _), |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
506 |
progress_stderr = progress.echo_if(echo, _), |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
507 |
strict = strict).check |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
508 |
|
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
509 |
if (self_update) { |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
510 |
val self_rev = |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
511 |
if (push_isabelle_home) { |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
512 |
val isabelle_home_hg = Mercurial.repository(Path.explode("~~")) |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
513 |
val self_rev = isabelle_home_hg.id() |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
514 |
isabelle_home_hg.push(isabelle_hg.root_url, rev = self_rev, force = true) |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
515 |
self_rev |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
516 |
} |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
517 |
else { |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
518 |
isabelle_hg.pull() |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
519 |
isabelle_hg.id() |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
520 |
} |
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
521 |
isabelle_hg.update(rev = self_rev, clean = true) |
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
522 |
execute("bin/isabelle", "components -I") |
66878 | 523 |
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
|
524 |
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
|
525 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
526 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
527 |
|
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
528 |
/* Isabelle other + AFP repository */ |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
529 |
|
66570 | 530 |
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
|
531 |
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
|
532 |
} |
64348
4c253e84ae62
clarified push/pull chain: current ISABELLE_HOME may server as source for changes that are not published on isabelle_repos_source yet (e.g. isabelle-release branch);
wenzelm
parents:
64346
diff
changeset
|
533 |
val other_hg = |
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
534 |
Mercurial.clone_repository( |
66570 | 535 |
ssh.bash_path(isabelle_repos_self), isabelle_repos_other, rev = rev, ssh = ssh) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
536 |
|
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
537 |
val afp_options = |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
538 |
if (afp_rev.isEmpty) "" |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
539 |
else { |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
540 |
val afp_repos = isabelle_repos_other + Path.explode("AFP") |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
541 |
val afp_hg = Mercurial.setup_repository(afp_repos_source, afp_repos, ssh = ssh) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
542 |
" -A " + Bash.string(afp_rev.get) |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
543 |
} |
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
544 |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
545 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
546 |
/* Admin/build_history */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
547 |
|
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
548 |
ssh.with_tmp_dir(tmp_dir => |
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
549 |
{ |
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
550 |
val output_file = tmp_dir + Path.explode("output") |
64346 | 551 |
|
66877
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
552 |
execute("Admin/build_history", |
4f0ccfe1bcb6
uniform execute, with proper isabelle_identifier (notably for "isabelle components -I");
wenzelm
parents:
66876
diff
changeset
|
553 |
"-o " + ssh.bash_path(output_file) + |
66106
b5333fc056da
always start with fresh clone (with explicitly given rev): more robust on Windows;
wenzelm
parents:
65999
diff
changeset
|
554 |
(if (rev == "") "" else " -r " + Bash.string(rev)) + " " + |
66860
54ae2cc05325
support for AFP in build_history and remote_build_history;
wenzelm
parents:
66570
diff
changeset
|
555 |
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
|
556 |
echo = true, strict = false) |
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
557 |
|
65929
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
558 |
for (line <- split_lines(ssh.read(output_file))) |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
559 |
yield { |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
560 |
val log = Path.explode(line) |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
561 |
val bytes = ssh.read_bytes(log) |
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
562 |
ssh.rm(log) |
65999 | 563 |
(log.base_name, bytes) |
65929
de3adcf6a276
prefer strict result (in contrast to 0f3b0a929c02);
wenzelm
parents:
65928
diff
changeset
|
564 |
} |
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
565 |
}) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
566 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
567 |
} |