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