author | wenzelm |
Sun, 06 Nov 2016 22:51:40 +0100 | |
changeset 64468 | ed8940d6295c |
parent 64466 | 2bf4fdcebd49 |
child 64472 | c2191352e908 |
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 |
||
19 |
val BUILD_HISTORY = "build_history" |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
20 |
val META_INFO_MARKER = "\fmeta_info = " |
64117 | 21 |
|
22 |
||
64188 | 23 |
/* augment settings */ |
64050 | 24 |
|
64188 | 25 |
def augment_settings( |
26 |
other_isabelle: Other_Isabelle, |
|
27 |
threads: Int, |
|
28 |
arch_64: Boolean = false, |
|
29 |
heap: Int = default_heap, |
|
30 |
max_heap: Option[Int] = None, |
|
31 |
more_settings: List[String]): String = |
|
32 |
{ |
|
33 |
val (ml_platform, ml_settings) = |
|
34 |
{ |
|
35 |
val windows_32 = "x86-windows" |
|
36 |
val windows_64 = "x86_64-windows" |
|
37 |
val platform_32 = other_isabelle("getenv -b ISABELLE_PLATFORM32").check.out |
|
38 |
val platform_64 = other_isabelle("getenv -b ISABELLE_PLATFORM64").check.out |
|
39 |
val platform_family = other_isabelle("getenv -b ISABELLE_PLATFORM_FAMILY").check.out |
|
64049 | 40 |
|
64188 | 41 |
val polyml_home = |
42 |
try { Path.explode(other_isabelle("getenv -b ML_HOME").check.out).dir } |
|
43 |
catch { case ERROR(msg) => error("Bad ML_HOME: " + msg) } |
|
64049 | 44 |
|
64188 | 45 |
def ml_home(platform: String): Path = polyml_home + Path.explode(platform) |
64049 | 46 |
|
64188 | 47 |
def err(platform: String): Nothing = |
48 |
error("Platform " + platform + " unavailable on this machine") |
|
64050 | 49 |
|
64188 | 50 |
def check_dir(platform: String): Boolean = |
51 |
platform != "" && ml_home(platform).is_dir |
|
64050 | 52 |
|
64188 | 53 |
val ml_platform = |
54 |
if (Platform.is_windows && arch_64) { |
|
55 |
if (check_dir(windows_64)) windows_64 else err(windows_64) |
|
56 |
} |
|
57 |
else if (Platform.is_windows && !arch_64) { |
|
58 |
if (check_dir(windows_32)) windows_32 |
|
59 |
else platform_32 // x86-cygwin |
|
60 |
} |
|
61 |
else { |
|
62 |
val (platform, platform_name) = |
|
63 |
if (arch_64) (platform_64, "x86_64-" + platform_family) |
|
64 |
else (platform_32, "x86-" + platform_family) |
|
65 |
if (check_dir(platform)) platform else err(platform_name) |
|
66 |
} |
|
64050 | 67 |
|
64188 | 68 |
val ml_options = |
69 |
"--minheap " + heap + (if (max_heap.isDefined) " --maxheap " + max_heap.get else "") + |
|
70 |
" --gcthreads " + threads + |
|
71 |
(if (ml_platform.endsWith("-windows")) " --codepage utf8" else "") |
|
64050 | 72 |
|
64188 | 73 |
(ml_platform, |
74 |
List( |
|
75 |
"ML_HOME=" + File.bash_path(ml_home(ml_platform)), |
|
76 |
"ML_PLATFORM=" + quote(ml_platform), |
|
77 |
"ML_OPTIONS=" + quote(ml_options))) |
|
64050 | 78 |
} |
79 |
||
64188 | 80 |
val thread_settings = |
81 |
List( |
|
82 |
"ISABELLE_JAVA_SYSTEM_OPTIONS=\"$ISABELLE_JAVA_SYSTEM_OPTIONS -Disabelle.threads=" + threads + "\"", |
|
83 |
"ISABELLE_BUILD_OPTIONS=\"threads=" + threads + "\"") |
|
64050 | 84 |
|
64188 | 85 |
val settings = |
86 |
List(ml_settings, thread_settings) ::: |
|
87 |
(if (more_settings.isEmpty) Nil else List(more_settings)) |
|
64050 | 88 |
|
64188 | 89 |
File.append(other_isabelle.etc_settings, "\n" + cat_lines(settings.map(terminate_lines(_)))) |
64050 | 90 |
|
64188 | 91 |
ml_platform |
64049 | 92 |
} |
93 |
||
94 |
||
95 |
||
64050 | 96 |
/** build_history **/ |
64025 | 97 |
|
98 |
private val default_rev = "tip" |
|
64301 | 99 |
private val default_multicore = (1, 1) |
64335 | 100 |
private val default_heap = 1500 |
64025 | 101 |
private val default_isabelle_identifier = "build_history" |
102 |
||
103 |
def build_history( |
|
104 |
hg: Mercurial.Repository, |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
105 |
progress: Progress = Ignore_Progress, |
64025 | 106 |
rev: String = default_rev, |
107 |
isabelle_identifier: String = default_isabelle_identifier, |
|
108 |
components_base: String = "", |
|
64026 | 109 |
fresh: Boolean = false, |
64025 | 110 |
nonfree: Boolean = false, |
64052 | 111 |
multicore_base: Boolean = false, |
64301 | 112 |
multicore_list: List[(Int, Int)] = List(default_multicore), |
64030 | 113 |
arch_64: Boolean = false, |
114 |
heap: Int = default_heap, |
|
64036 | 115 |
max_heap: Option[Int] = None, |
64030 | 116 |
more_settings: List[String] = Nil, |
64026 | 117 |
verbose: Boolean = false, |
64297 | 118 |
build_tags: List[String] = Nil, |
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
119 |
build_args: List[String] = Nil): List[(Process_Result, Path)] = |
64025 | 120 |
{ |
64031 | 121 |
/* sanity checks */ |
122 |
||
64213 | 123 |
if (File.eq(Path.explode("~~"), hg.root)) |
64046 | 124 |
error("Repository coincides with ISABELLE_HOME=" + Path.explode("~~").expand) |
125 |
||
64301 | 126 |
for ((threads, _) <- multicore_list if threads < 1) |
127 |
error("Bad threads value < 1: " + threads) |
|
128 |
for ((_, processes) <- multicore_list if processes < 1) |
|
129 |
error("Bad processes value < 1: " + processes) |
|
64036 | 130 |
|
64030 | 131 |
if (heap < 100) error("Bad heap value < 100: " + heap) |
132 |
||
64036 | 133 |
if (max_heap.isDefined && max_heap.get < heap) |
134 |
error("Bad max_heap value < heap: " + max_heap.get) |
|
135 |
||
64031 | 136 |
System.getenv("ISABELLE_SETTINGS_PRESENT") match { |
137 |
case null | "" => |
|
138 |
case _ => error("Cannot run build_history within existing Isabelle settings environment") |
|
139 |
} |
|
140 |
||
141 |
||
64049 | 142 |
/* init repository */ |
64031 | 143 |
|
64025 | 144 |
hg.update(rev = rev, clean = true) |
64049 | 145 |
progress.echo_if(verbose, hg.log(rev, options = "-l1")) |
64025 | 146 |
|
64232
367d83d6030e
clarified hg.id operation, with explicit tip as default;
wenzelm
parents:
64231
diff
changeset
|
147 |
val isabelle_version = hg.id(rev) |
64049 | 148 |
val other_isabelle = new Other_Isabelle(progress, hg.root, isabelle_identifier) |
64025 | 149 |
|
64051 | 150 |
|
64052 | 151 |
/* main */ |
64043 | 152 |
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
153 |
val build_host = Isabelle_System.hostname() |
64117 | 154 |
val build_history_date = Date.now() |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
155 |
val build_group_id = build_host + ":" + build_history_date.time.ms |
64117 | 156 |
|
64051 | 157 |
var first_build = true |
64301 | 158 |
for ((threads, processes) <- multicore_list) yield |
64052 | 159 |
{ |
160 |
/* init settings */ |
|
161 |
||
64188 | 162 |
other_isabelle.init_settings(components_base, nonfree) |
64051 | 163 |
other_isabelle.resolve_components(verbose) |
64117 | 164 |
val ml_platform = |
64188 | 165 |
augment_settings(other_isabelle, threads, arch_64, heap, max_heap, more_settings) |
64043 | 166 |
|
64052 | 167 |
val isabelle_output = Path.explode(other_isabelle("getenv -b ISABELLE_OUTPUT").check.out) |
168 |
val isabelle_output_log = isabelle_output + Path.explode("log") |
|
169 |
val isabelle_base_log = isabelle_output + Path.explode("../base_log") |
|
170 |
||
64051 | 171 |
if (first_build) { |
172 |
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
|
173 |
|
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
|
174 |
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
|
175 |
Isabelle_System.rm_tree(other_isabelle.isabelle_home + Path.explode("lib/classes")) |
64051 | 176 |
other_isabelle.bash( |
177 |
"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
|
178 |
"bin/isabelle jedit -b", redirect = true, echo = verbose).check |
64052 | 179 |
|
64213 | 180 |
Isabelle_System.rm_tree(isabelle_base_log) |
64051 | 181 |
} |
64025 | 182 |
|
64213 | 183 |
Isabelle_System.rm_tree(isabelle_output) |
64052 | 184 |
Isabelle_System.mkdirs(isabelle_output) |
185 |
||
186 |
||
187 |
/* build */ |
|
188 |
||
189 |
if (multicore_base && !first_build && isabelle_base_log.is_dir) |
|
64189 | 190 |
Isabelle_System.copy_dir(isabelle_base_log, isabelle_output_log) |
64052 | 191 |
|
64117 | 192 |
val build_start = Date.now() |
64302 | 193 |
val build_args1 = List("-v", "-j" + processes) ::: build_args |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
194 |
val build_result = |
64304 | 195 |
other_isabelle("build " + Bash.strings(build_args1), redirect = true, echo = verbose) |
64117 | 196 |
val build_end = Date.now() |
197 |
||
198 |
val log_path = |
|
64193 | 199 |
other_isabelle.isabelle_home_user + |
200 |
Build_Log.log_subdir(build_history_date) + |
|
64297 | 201 |
Build_Log.log_filename(BUILD_HISTORY, build_history_date, |
202 |
List(build_host, ml_platform, "M" + threads) ::: build_tags) |
|
64117 | 203 |
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
204 |
val build_info = |
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
205 |
Build_Log.Log_File(log_path.base.implode, build_result.out_lines).parse_build_info() |
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
206 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
207 |
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
208 |
/* output log */ |
64120 | 209 |
|
64117 | 210 |
val meta_info = |
64300
3073688abbe9
clarified multiple props: result needs to fit on a single line within the log file;
wenzelm
parents:
64299
diff
changeset
|
211 |
Build_Log.Prop.multiple(Build_Log.Prop.build_tags, build_tags) ::: |
64302 | 212 |
Build_Log.Prop.multiple(Build_Log.Prop.build_args, build_args1) ::: |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
213 |
List( |
64298 | 214 |
Build_Log.Prop.build_group_id -> build_group_id, |
215 |
Build_Log.Prop.build_id -> (build_host + ":" + build_start.time.ms), |
|
216 |
Build_Log.Prop.build_engine -> BUILD_HISTORY, |
|
217 |
Build_Log.Prop.build_host -> build_host, |
|
218 |
Build_Log.Prop.build_start -> Build_Log.print_date(build_start), |
|
219 |
Build_Log.Prop.build_end -> Build_Log.print_date(build_end), |
|
220 |
Build_Log.Prop.isabelle_version -> isabelle_version) |
|
64117 | 221 |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
222 |
val ml_statistics = |
64120 | 223 |
build_info.finished_sessions.flatMap(session_name => |
224 |
{ |
|
225 |
val session_log = isabelle_output_log + Path.explode(session_name).ext("gz") |
|
226 |
if (session_log.is_file) { |
|
227 |
Build_Log.Log_File(session_log).parse_session_info(ml_statistics = true). |
|
228 |
ml_statistics.map(props => (Build_Log.SESSION_NAME -> session_name) :: props) |
|
229 |
} |
|
230 |
else Nil |
|
231 |
}) |
|
232 |
||
233 |
val heap_sizes = |
|
234 |
build_info.finished_sessions.flatMap(session_name => |
|
235 |
{ |
|
236 |
val heap = isabelle_output + Path.explode(session_name) |
|
237 |
if (heap.is_file) |
|
238 |
Some("Heap " + session_name + " (" + Value.Long(heap.file.length) + " bytes)") |
|
239 |
else None |
|
240 |
}) |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
241 |
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
242 |
Isabelle_System.mkdirs(log_path.dir) |
64253 | 243 |
File.write_xz(log_path.ext("xz"), |
64173 | 244 |
terminate_lines( |
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
245 |
Build_Log.Log_File.print_props(META_INFO_MARKER, meta_info) :: build_result.out_lines ::: |
64120 | 246 |
ml_statistics.map(Build_Log.Log_File.print_props(Build_Log.ML_STATISTICS_MARKER, _)) ::: |
64253 | 247 |
heap_sizes), XZ.options(6)) |
64117 | 248 |
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
249 |
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
250 |
/* next build */ |
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
251 |
|
64052 | 252 |
if (multicore_base && first_build && isabelle_output_log.is_dir) |
64189 | 253 |
Isabelle_System.copy_dir(isabelle_output_log, isabelle_base_log) |
64052 | 254 |
|
64260 | 255 |
Isabelle_System.rm_tree(isabelle_output) |
256 |
||
64052 | 257 |
first_build = false |
258 |
||
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
259 |
(build_result, log_path.ext("xz")) |
64051 | 260 |
} |
64025 | 261 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
262 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
263 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
264 |
/* command line entry point */ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
265 |
|
64301 | 266 |
private object Multicore |
267 |
{ |
|
268 |
private val Pat1 = """^(\d+)$""".r |
|
269 |
private val Pat2 = """^(\d+)x(\d+)$""".r |
|
270 |
||
271 |
def parse(s: String): (Int, Int) = |
|
272 |
s match { |
|
273 |
case Pat1(Value.Int(x)) => (x, 1) |
|
274 |
case Pat2(Value.Int(x), Value.Int(y)) => (x, y) |
|
275 |
case _ => error("Bad multicore configuration: " + quote(s)) |
|
276 |
} |
|
277 |
} |
|
278 |
||
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
279 |
def main(args: Array[String]) |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
280 |
{ |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
281 |
Command_Line.tool0 { |
64052 | 282 |
var multicore_base = false |
64025 | 283 |
var components_base = "" |
64030 | 284 |
var heap: Option[Int] = None |
64036 | 285 |
var max_heap: Option[Int] = None |
64301 | 286 |
var multicore_list = List(default_multicore) |
64025 | 287 |
var isabelle_identifier = default_isabelle_identifier |
64030 | 288 |
var more_settings: List[String] = Nil |
64026 | 289 |
var fresh = false |
64030 | 290 |
var arch_64 = false |
64025 | 291 |
var nonfree = false |
292 |
var rev = default_rev |
|
64297 | 293 |
var build_tags = List.empty[String] |
64025 | 294 |
var verbose = false |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
295 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
296 |
val getopts = Getopts(""" |
64026 | 297 |
Usage: isabelle build_history [OPTIONS] REPOSITORY [ARGS ...] |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
298 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
299 |
Options are: |
64052 | 300 |
-B first multicore build serves as base for scheduling information |
64025 | 301 |
-C DIR base directory for Isabelle components (default: $ISABELLE_HOME_USER/../contrib) |
64036 | 302 |
-H SIZE minimal ML heap in MB (default: """ + default_heap + """ for x86, """ + default_heap * 2 + """ for x86_64) |
64301 | 303 |
-M MULTICORE multicore configurations (see below) |
64025 | 304 |
-N NAME alternative ISABELLE_IDENTIFIER (default: """ + default_isabelle_identifier + """) |
64036 | 305 |
-U SIZE maximal ML heap in MB (default: unbounded) |
64030 | 306 |
-e TEXT additional text for generated etc/settings |
64026 | 307 |
-f fresh build of Isabelle/Scala components (recommended) |
64030 | 308 |
-m ARCH processor architecture (32=x86, 64=x86_64, default: x86) |
64025 | 309 |
-n include nonfree components |
64026 | 310 |
-r REV update to revision (default: """ + default_rev + """) |
64297 | 311 |
-t TAG free-form build tag (multiple occurrences possible) |
64025 | 312 |
-v verbose |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
313 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
314 |
Build Isabelle sessions from the history of another REPOSITORY clone, |
64026 | 315 |
passing ARGS directly to its isabelle build tool. |
64301 | 316 |
|
317 |
Each MULTICORE configuration consists of one or two numbers (default 1): |
|
318 |
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
|
319 |
""", |
64052 | 320 |
"B" -> (_ => multicore_base = true), |
64025 | 321 |
"C:" -> (arg => components_base = arg), |
64030 | 322 |
"H:" -> (arg => heap = Some(Value.Int.parse(arg))), |
64301 | 323 |
"M:" -> (arg => multicore_list = space_explode(',', arg).map(Multicore.parse(_))), |
64025 | 324 |
"N:" -> (arg => isabelle_identifier = arg), |
64036 | 325 |
"U:" -> (arg => max_heap = Some(Value.Int.parse(arg))), |
64030 | 326 |
"e:" -> (arg => more_settings = more_settings ::: List(arg)), |
64026 | 327 |
"f" -> (_ => fresh = true), |
64030 | 328 |
"m:" -> |
329 |
{ |
|
330 |
case "32" | "x86" => arch_64 = false |
|
331 |
case "64" | "x86_64" => arch_64 = true |
|
332 |
case bad => error("Bad processor architecture: " + quote(bad)) |
|
333 |
}, |
|
64025 | 334 |
"n" -> (_ => nonfree = true), |
335 |
"r:" -> (arg => rev = arg), |
|
64297 | 336 |
"t:" -> (arg => build_tags = build_tags ::: List(arg)), |
64025 | 337 |
"v" -> (_ => verbose = true)) |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
338 |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
339 |
val more_args = getopts(args) |
64026 | 340 |
val (root, build_args) = |
341 |
more_args match { |
|
342 |
case root :: build_args => (root, build_args) |
|
343 |
case _ => getopts.usage() |
|
344 |
} |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
345 |
|
64162 | 346 |
val hg = Mercurial.repository(Path.explode(root)) |
347 |
val progress = new Console_Progress(stderr = true) |
|
64346 | 348 |
|
64162 | 349 |
val results = |
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
350 |
build_history(hg, progress = progress, rev = rev, isabelle_identifier = isabelle_identifier, |
64162 | 351 |
components_base = components_base, fresh = fresh, nonfree = nonfree, |
64301 | 352 |
multicore_base = multicore_base, multicore_list = multicore_list, arch_64 = arch_64, |
64162 | 353 |
heap = heap.getOrElse(if (arch_64) default_heap * 2 else default_heap), |
354 |
max_heap = max_heap, more_settings = more_settings, verbose = verbose, |
|
64297 | 355 |
build_tags = build_tags, build_args = build_args) |
64162 | 356 |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
357 |
val rc = (0 /: results) { case (rc, (res, _)) => rc max res.rc } |
64162 | 358 |
if (rc != 0) sys.exit(rc) |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
359 |
} |
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
360 |
} |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
361 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
362 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
363 |
|
64225 | 364 |
/** remote build_history -- via command-line **/ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
365 |
|
64225 | 366 |
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
|
367 |
ssh: SSH.Session, |
64227 | 368 |
isabelle_repos_self: Path, |
369 |
isabelle_repos_other: Path, |
|
370 |
isabelle_repos_source: String = "http://isabelle.in.tum.de/repos/isabelle", |
|
371 |
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
|
372 |
push_isabelle_home: Boolean = false, |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
373 |
progress: Progress = Ignore_Progress, |
64227 | 374 |
options: String = "", |
64419
0f3b0a929c02
more permissive remote_build_history: failure happens routinely and should not lead error, without saving logs;
wenzelm
parents:
64376
diff
changeset
|
375 |
args: String = ""): (List[(String, Bytes)], Process_Result) = |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
376 |
{ |
64305 | 377 |
val isabelle_admin = isabelle_repos_self + Path.explode("Admin") |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
378 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
379 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
380 |
/* prepare repository clones */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
381 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
382 |
val isabelle_hg = |
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
383 |
Mercurial.setup_repository(isabelle_repos_source, isabelle_repos_self, ssh = Some(ssh)) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
384 |
|
64353 | 385 |
val rev = |
386 |
if (self_update) { |
|
387 |
val rev = |
|
388 |
if (push_isabelle_home) { |
|
389 |
val isabelle_home_hg = Mercurial.repository(Path.explode("~~")) |
|
390 |
val rev = isabelle_home_hg.id() |
|
391 |
isabelle_home_hg.push(isabelle_hg.root_url, rev = rev, force = true) |
|
392 |
rev |
|
393 |
} |
|
394 |
else { |
|
395 |
isabelle_hg.pull() |
|
396 |
isabelle_hg.id() |
|
397 |
} |
|
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
|
398 |
isabelle_hg.update(rev = rev, clean = true) |
64459 | 399 |
ssh.execute( |
400 |
ssh.bash_path(isabelle_repos_self + Path.explode("bin/isabelle")) |
|
401 |
+ " components -a").check |
|
64353 | 402 |
ssh.execute(ssh.bash_path(isabelle_admin + Path.explode("build")) + " jars_fresh").check |
403 |
rev |
|
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
|
404 |
} |
64353 | 405 |
else "tip" |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
406 |
|
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
|
407 |
val other_hg = |
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
|
408 |
Mercurial.setup_repository( |
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
|
409 |
ssh.bash_path(isabelle_repos_self), isabelle_repos_other, ssh = Some(ssh)) |
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
|
410 |
other_hg.pull(isabelle_hg.root.implode) |
64353 | 411 |
other_hg.update(rev = rev, clean = true) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
412 |
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
413 |
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
414 |
/* Admin/build_history */ |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
415 |
|
64419
0f3b0a929c02
more permissive remote_build_history: failure happens routinely and should not lead error, without saving logs;
wenzelm
parents:
64376
diff
changeset
|
416 |
val process_result = |
0f3b0a929c02
more permissive remote_build_history: failure happens routinely and should not lead error, without saving logs;
wenzelm
parents:
64376
diff
changeset
|
417 |
ssh.execute( |
0f3b0a929c02
more permissive remote_build_history: failure happens routinely and should not lead error, without saving logs;
wenzelm
parents:
64376
diff
changeset
|
418 |
ssh.bash_path(isabelle_admin + Path.explode("build_history")) + " " + options + " " + |
0f3b0a929c02
more permissive remote_build_history: failure happens routinely and should not lead error, without saving logs;
wenzelm
parents:
64376
diff
changeset
|
419 |
ssh.bash_path(isabelle_repos_other) + " " + args, |
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
420 |
progress_stdout = progress.echo(_), |
64453
075c077a6e29
ignore interrupts from underlying process, e.g. due to out-of-memory situation in ML_Process (see also build.scala);
wenzelm
parents:
64419
diff
changeset
|
421 |
progress_stderr = progress.echo(_), |
075c077a6e29
ignore interrupts from underlying process, e.g. due to out-of-memory situation in ML_Process (see also build.scala);
wenzelm
parents:
64419
diff
changeset
|
422 |
strict = false) |
64346 | 423 |
|
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
424 |
val result = |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
425 |
for (line <- process_result.out_lines) |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
426 |
yield { |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
427 |
val log = Path.explode(line) |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
428 |
val bytes = ssh.read_bytes(log) |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
429 |
ssh.rm(log) |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
430 |
(log.base.implode, bytes) |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
431 |
} |
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
432 |
|
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
433 |
(result, process_result) |
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
434 |
} |
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
435 |
} |