| author | blanchet |
| Sun, 21 May 2017 21:37:31 +0200 | |
| changeset 65885 | 77d922eff5ac |
| parent 65881 | b3d6fb291f58 |
| child 65889 | 29c9e3742069 |
| 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( |
|
105 |
hg: Mercurial.Repository, |
|
| 64909 | 106 |
progress: Progress = No_Progress, |
| 64025 | 107 |
rev: String = default_rev, |
108 |
isabelle_identifier: String = default_isabelle_identifier, |
|
109 |
components_base: String = "", |
|
| 64026 | 110 |
fresh: Boolean = false, |
| 64025 | 111 |
nonfree: Boolean = false, |
| 64052 | 112 |
multicore_base: Boolean = false, |
| 64301 | 113 |
multicore_list: List[(Int, Int)] = List(default_multicore), |
| 64030 | 114 |
arch_64: Boolean = false, |
115 |
heap: Int = default_heap, |
|
| 64036 | 116 |
max_heap: Option[Int] = None, |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
117 |
init_settings: List[String] = Nil, |
| 64030 | 118 |
more_settings: List[String] = Nil, |
| 64026 | 119 |
verbose: Boolean = false, |
| 64297 | 120 |
build_tags: List[String] = Nil, |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
121 |
build_args: List[String] = Nil): List[(Process_Result, Path)] = |
| 64025 | 122 |
{
|
| 64031 | 123 |
/* sanity checks */ |
124 |
||
| 64213 | 125 |
if (File.eq(Path.explode("~~"), hg.root))
|
| 64046 | 126 |
error("Repository coincides with ISABELLE_HOME=" + Path.explode("~~").expand)
|
127 |
||
| 64301 | 128 |
for ((threads, _) <- multicore_list if threads < 1) |
129 |
error("Bad threads value < 1: " + threads)
|
|
130 |
for ((_, processes) <- multicore_list if processes < 1) |
|
131 |
error("Bad processes value < 1: " + processes)
|
|
| 64036 | 132 |
|
| 64030 | 133 |
if (heap < 100) error("Bad heap value < 100: " + heap)
|
134 |
||
| 64036 | 135 |
if (max_heap.isDefined && max_heap.get < heap) |
136 |
error("Bad max_heap value < heap: " + max_heap.get)
|
|
137 |
||
| 64031 | 138 |
System.getenv("ISABELLE_SETTINGS_PRESENT") match {
|
139 |
case null | "" => |
|
140 |
case _ => error("Cannot run build_history within existing Isabelle settings environment")
|
|
141 |
} |
|
142 |
||
143 |
||
| 64049 | 144 |
/* init repository */ |
| 64031 | 145 |
|
| 64025 | 146 |
hg.update(rev = rev, clean = true) |
| 64049 | 147 |
progress.echo_if(verbose, hg.log(rev, options = "-l1")) |
| 64025 | 148 |
|
|
64232
367d83d6030e
clarified hg.id operation, with explicit tip as default;
wenzelm
parents:
64231
diff
changeset
|
149 |
val isabelle_version = hg.id(rev) |
| 64049 | 150 |
val other_isabelle = new Other_Isabelle(progress, hg.root, isabelle_identifier) |
| 64025 | 151 |
|
| 64051 | 152 |
|
| 64052 | 153 |
/* main */ |
| 64043 | 154 |
|
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
155 |
val build_host = Isabelle_System.hostname() |
| 64117 | 156 |
val build_history_date = Date.now() |
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
157 |
val build_group_id = build_host + ":" + build_history_date.time.ms |
| 64117 | 158 |
|
| 64051 | 159 |
var first_build = true |
| 64301 | 160 |
for ((threads, processes) <- multicore_list) yield |
| 64052 | 161 |
{
|
162 |
/* init settings */ |
|
163 |
||
|
65845
b8ff63149256
proper init_settings, before inspecting ML_HOME etc;
wenzelm
parents:
65844
diff
changeset
|
164 |
other_isabelle.init_settings(components_base, nonfree, init_settings) |
| 64051 | 165 |
other_isabelle.resolve_components(verbose) |
| 64117 | 166 |
val ml_platform = |
|
65845
b8ff63149256
proper init_settings, before inspecting ML_HOME etc;
wenzelm
parents:
65844
diff
changeset
|
167 |
augment_settings(other_isabelle, threads, arch_64, heap, max_heap, more_settings) |
| 64043 | 168 |
|
| 64052 | 169 |
val isabelle_output = Path.explode(other_isabelle("getenv -b ISABELLE_OUTPUT").check.out)
|
170 |
val isabelle_output_log = isabelle_output + Path.explode("log")
|
|
171 |
val isabelle_base_log = isabelle_output + Path.explode("../base_log")
|
|
172 |
||
| 64051 | 173 |
if (first_build) {
|
174 |
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
|
175 |
|
|
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
|
176 |
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
|
177 |
Isabelle_System.rm_tree(other_isabelle.isabelle_home + Path.explode("lib/classes"))
|
| 64051 | 178 |
other_isabelle.bash( |
179 |
"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
|
180 |
"bin/isabelle jedit -b", redirect = true, echo = verbose).check |
| 64052 | 181 |
|
| 64213 | 182 |
Isabelle_System.rm_tree(isabelle_base_log) |
| 64051 | 183 |
} |
| 64025 | 184 |
|
| 64213 | 185 |
Isabelle_System.rm_tree(isabelle_output) |
| 64052 | 186 |
Isabelle_System.mkdirs(isabelle_output) |
187 |
||
188 |
||
189 |
/* build */ |
|
190 |
||
191 |
if (multicore_base && !first_build && isabelle_base_log.is_dir) |
|
| 64189 | 192 |
Isabelle_System.copy_dir(isabelle_base_log, isabelle_output_log) |
| 64052 | 193 |
|
| 64117 | 194 |
val build_start = Date.now() |
| 64302 | 195 |
val build_args1 = List("-v", "-j" + processes) ::: build_args
|
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
196 |
val build_result = |
| 64304 | 197 |
other_isabelle("build " + Bash.strings(build_args1), redirect = true, echo = verbose)
|
| 64117 | 198 |
val build_end = Date.now() |
199 |
||
200 |
val log_path = |
|
| 64193 | 201 |
other_isabelle.isabelle_home_user + |
202 |
Build_Log.log_subdir(build_history_date) + |
|
| 65588 | 203 |
Build_Log.log_filename(Build_History.engine, build_history_date, |
| 64297 | 204 |
List(build_host, ml_platform, "M" + threads) ::: build_tags) |
| 64117 | 205 |
|
|
65881
b3d6fb291f58
keep main build.log to help diagnosing spurious lack of log_path.xz;
wenzelm
parents:
65846
diff
changeset
|
206 |
Isabelle_System.mkdirs(isabelle_output_log) |
|
b3d6fb291f58
keep main build.log to help diagnosing spurious lack of log_path.xz;
wenzelm
parents:
65846
diff
changeset
|
207 |
File.write(isabelle_output_log + Path.explode("build.log"), build_result.out)
|
|
b3d6fb291f58
keep main build.log to help diagnosing spurious lack of log_path.xz;
wenzelm
parents:
65846
diff
changeset
|
208 |
|
| 65646 | 209 |
val build_info: Build_Log.Build_Info = |
210 |
Build_Log.Log_File(log_path.base.implode, build_result.out_lines). |
|
211 |
parse_build_info(ml_statistics = true) |
|
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
212 |
|
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
213 |
|
|
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
214 |
/* output log */ |
| 64120 | 215 |
|
|
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
216 |
val store = Sessions.store() |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
217 |
|
| 64117 | 218 |
val meta_info = |
| 65624 | 219 |
Properties.lines_nonempty(Build_Log.Prop.build_tags.name, build_tags) ::: |
220 |
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
|
221 |
List( |
| 65591 | 222 |
Build_Log.Prop.build_group_id.name -> build_group_id, |
223 |
Build_Log.Prop.build_id.name -> (build_host + ":" + build_start.time.ms), |
|
224 |
Build_Log.Prop.build_engine.name -> Build_History.engine, |
|
225 |
Build_Log.Prop.build_host.name -> build_host, |
|
226 |
Build_Log.Prop.build_start.name -> Build_Log.print_date(build_start), |
|
227 |
Build_Log.Prop.build_end.name -> Build_Log.print_date(build_end), |
|
228 |
Build_Log.Prop.isabelle_version.name -> isabelle_version) |
|
| 64117 | 229 |
|
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
230 |
val ml_statistics = |
| 64120 | 231 |
build_info.finished_sessions.flatMap(session_name => |
232 |
{
|
|
|
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
233 |
val database = isabelle_output + store.database(session_name) |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
234 |
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
|
235 |
|
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
236 |
val properties = |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
237 |
if (database.is_file) {
|
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
238 |
using(SQLite.open_database(database))(db => |
|
65320
52861eebf58d
access table via session_name: db may in principle contain multiple entries;
wenzelm
parents:
65318
diff
changeset
|
239 |
store.read_build_log(db, session_name, ml_statistics = true)).ml_statistics |
|
65293
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
240 |
} |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
241 |
else if (log_gz.is_file) {
|
|
65318
342efc382558
eliminated somewhat redundant inlined name (despite a7aa17a1f721);
wenzelm
parents:
65296
diff
changeset
|
242 |
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
|
243 |
} |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
244 |
else Nil |
|
a53a5ae88205
prefer database, but also accept log.gz from historic versions;
wenzelm
parents:
64909
diff
changeset
|
245 |
properties.map(props => (Build_Log.SESSION_NAME -> session_name) :: props) |
| 64120 | 246 |
}) |
247 |
||
248 |
val heap_sizes = |
|
249 |
build_info.finished_sessions.flatMap(session_name => |
|
250 |
{
|
|
251 |
val heap = isabelle_output + Path.explode(session_name) |
|
252 |
if (heap.is_file) |
|
253 |
Some("Heap " + session_name + " (" + Value.Long(heap.file.length) + " bytes)")
|
|
254 |
else None |
|
255 |
}) |
|
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
256 |
|
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
257 |
Isabelle_System.mkdirs(log_path.dir) |
| 64253 | 258 |
File.write_xz(log_path.ext("xz"),
|
| 64173 | 259 |
terminate_lines( |
|
64296
544481988e65
explicit identification of builds and correlated build groups;
wenzelm
parents:
64263
diff
changeset
|
260 |
Build_Log.Log_File.print_props(META_INFO_MARKER, meta_info) :: build_result.out_lines ::: |
| 64120 | 261 |
ml_statistics.map(Build_Log.Log_File.print_props(Build_Log.ML_STATISTICS_MARKER, _)) ::: |
| 64253 | 262 |
heap_sizes), XZ.options(6)) |
| 64117 | 263 |
|
|
64119
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
264 |
|
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
265 |
/* next build */ |
|
8094eaa38d4b
inline session ML statistics into main build log;
wenzelm
parents:
64118
diff
changeset
|
266 |
|
| 64052 | 267 |
if (multicore_base && first_build && isabelle_output_log.is_dir) |
| 64189 | 268 |
Isabelle_System.copy_dir(isabelle_output_log, isabelle_base_log) |
| 64052 | 269 |
|
| 64260 | 270 |
Isabelle_System.rm_tree(isabelle_output) |
271 |
||
| 64052 | 272 |
first_build = false |
273 |
||
|
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
274 |
(build_result, log_path.ext("xz"))
|
| 64051 | 275 |
} |
| 64025 | 276 |
} |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
277 |
|
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
278 |
|
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
279 |
/* command line entry point */ |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
280 |
|
| 64301 | 281 |
private object Multicore |
282 |
{
|
|
283 |
private val Pat1 = """^(\d+)$""".r |
|
284 |
private val Pat2 = """^(\d+)x(\d+)$""".r |
|
285 |
||
286 |
def parse(s: String): (Int, Int) = |
|
287 |
s match {
|
|
288 |
case Pat1(Value.Int(x)) => (x, 1) |
|
289 |
case Pat2(Value.Int(x), Value.Int(y)) => (x, y) |
|
290 |
case _ => error("Bad multicore configuration: " + quote(s))
|
|
291 |
} |
|
292 |
} |
|
293 |
||
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
294 |
def main(args: Array[String]) |
|
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 |
Command_Line.tool0 {
|
| 64052 | 297 |
var multicore_base = false |
| 64025 | 298 |
var components_base = "" |
| 64030 | 299 |
var heap: Option[Int] = None |
| 64036 | 300 |
var max_heap: Option[Int] = None |
| 64301 | 301 |
var multicore_list = List(default_multicore) |
| 64025 | 302 |
var isabelle_identifier = default_isabelle_identifier |
| 64030 | 303 |
var more_settings: List[String] = Nil |
| 64026 | 304 |
var fresh = false |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
305 |
var init_settings: List[String] = Nil |
| 64030 | 306 |
var arch_64 = false |
| 64025 | 307 |
var nonfree = false |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
308 |
var output_file = "" |
| 64025 | 309 |
var rev = default_rev |
| 64297 | 310 |
var build_tags = List.empty[String] |
| 64025 | 311 |
var verbose = false |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
312 |
|
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
313 |
val getopts = Getopts("""
|
| 64026 | 314 |
Usage: isabelle build_history [OPTIONS] REPOSITORY [ARGS ...] |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
315 |
|
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
316 |
Options are: |
| 64052 | 317 |
-B first multicore build serves as base for scheduling information |
| 64025 | 318 |
-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
|
319 |
-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
|
320 |
default_heap * 2 + """ for x86_64) |
| 64301 | 321 |
-M MULTICORE multicore configurations (see below) |
| 64025 | 322 |
-N NAME alternative ISABELLE_IDENTIFIER (default: """ + default_isabelle_identifier + """) |
| 64036 | 323 |
-U SIZE maximal ML heap in MB (default: unbounded) |
| 64030 | 324 |
-e TEXT additional text for generated etc/settings |
| 64026 | 325 |
-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
|
326 |
-i TEXT initial text for generated etc/settings |
| 64030 | 327 |
-m ARCH processor architecture (32=x86, 64=x86_64, default: x86) |
| 64025 | 328 |
-n include nonfree components |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
329 |
-o FILE output file for log names (default: stdout) |
| 64026 | 330 |
-r REV update to revision (default: """ + default_rev + """) |
| 64297 | 331 |
-t TAG free-form build tag (multiple occurrences possible) |
| 64025 | 332 |
-v verbose |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
333 |
|
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
334 |
Build Isabelle sessions from the history of another REPOSITORY clone, |
| 64026 | 335 |
passing ARGS directly to its isabelle build tool. |
| 64301 | 336 |
|
337 |
Each MULTICORE configuration consists of one or two numbers (default 1): |
|
338 |
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
|
339 |
""", |
| 64052 | 340 |
"B" -> (_ => multicore_base = true), |
| 64025 | 341 |
"C:" -> (arg => components_base = arg), |
| 64030 | 342 |
"H:" -> (arg => heap = Some(Value.Int.parse(arg))), |
| 64301 | 343 |
"M:" -> (arg => multicore_list = space_explode(',', arg).map(Multicore.parse(_))),
|
| 64025 | 344 |
"N:" -> (arg => isabelle_identifier = arg), |
| 64036 | 345 |
"U:" -> (arg => max_heap = Some(Value.Int.parse(arg))), |
| 64030 | 346 |
"e:" -> (arg => more_settings = more_settings ::: List(arg)), |
| 64026 | 347 |
"f" -> (_ => fresh = true), |
|
65843
d547173212d2
proper init_settings for init_component (before generated ML_OPTIONS etc.);
wenzelm
parents:
65646
diff
changeset
|
348 |
"i:" -> (arg => init_settings = init_settings ::: List(arg)), |
| 64030 | 349 |
"m:" -> |
350 |
{
|
|
351 |
case "32" | "x86" => arch_64 = false |
|
352 |
case "64" | "x86_64" => arch_64 = true |
|
353 |
case bad => error("Bad processor architecture: " + quote(bad))
|
|
354 |
}, |
|
| 64025 | 355 |
"n" -> (_ => nonfree = true), |
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
356 |
"o:" -> (arg => output_file = arg), |
| 64025 | 357 |
"r:" -> (arg => rev = arg), |
| 64297 | 358 |
"t:" -> (arg => build_tags = build_tags ::: List(arg)), |
| 64025 | 359 |
"v" -> (_ => verbose = true)) |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
360 |
|
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
361 |
val more_args = getopts(args) |
| 64026 | 362 |
val (root, build_args) = |
363 |
more_args match {
|
|
364 |
case root :: build_args => (root, build_args) |
|
365 |
case _ => getopts.usage() |
|
366 |
} |
|
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
367 |
|
| 64162 | 368 |
val hg = Mercurial.repository(Path.explode(root)) |
369 |
val progress = new Console_Progress(stderr = true) |
|
| 64346 | 370 |
|
| 64162 | 371 |
val results = |
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
372 |
build_history(hg, progress = progress, rev = rev, isabelle_identifier = isabelle_identifier, |
| 64162 | 373 |
components_base = components_base, fresh = fresh, nonfree = nonfree, |
| 64301 | 374 |
multicore_base = multicore_base, multicore_list = multicore_list, arch_64 = arch_64, |
| 64162 | 375 |
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
|
376 |
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
|
377 |
verbose = verbose, build_tags = build_tags, build_args = build_args) |
| 64162 | 378 |
|
|
65844
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
379 |
if (output_file == "") {
|
|
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
380 |
for ((_, log_path) <- results) |
|
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
381 |
Output.writeln(log_path.implode, stdout = true) |
|
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
382 |
} |
|
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
383 |
else {
|
|
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
384 |
File.write(Path.explode(output_file), |
|
76e60a142ca1
support for explicit output file: potentially more robust than stdout;
wenzelm
parents:
65843
diff
changeset
|
385 |
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
|
386 |
} |
|
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
|
387 |
|
|
64194
b5ada7dcceaa
integrity test of build_history vs. build_history_base;
wenzelm
parents:
64193
diff
changeset
|
388 |
val rc = (0 /: results) { case (rc, (res, _)) => rc max res.rc }
|
| 64162 | 389 |
if (rc != 0) sys.exit(rc) |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
390 |
} |
|
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
391 |
} |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
392 |
|
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
393 |
|
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
394 |
|
| 64225 | 395 |
/** remote build_history -- via command-line **/ |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
396 |
|
| 64225 | 397 |
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
|
398 |
ssh: SSH.Session, |
| 64227 | 399 |
isabelle_repos_self: Path, |
400 |
isabelle_repos_other: Path, |
|
401 |
isabelle_repos_source: String = "http://isabelle.in.tum.de/repos/isabelle", |
|
402 |
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
|
403 |
push_isabelle_home: Boolean = false, |
| 64909 | 404 |
progress: Progress = No_Progress, |
| 64227 | 405 |
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
|
406 |
args: String = ""): (List[(String, Bytes)], Process_Result) = |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
407 |
{
|
| 64305 | 408 |
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
|
409 |
|
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
410 |
|
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
411 |
/* prepare repository clones */ |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
412 |
|
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
413 |
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
|
414 |
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
|
415 |
|
| 64353 | 416 |
val rev = |
417 |
if (self_update) {
|
|
418 |
val rev = |
|
419 |
if (push_isabelle_home) {
|
|
420 |
val isabelle_home_hg = Mercurial.repository(Path.explode("~~"))
|
|
421 |
val rev = isabelle_home_hg.id() |
|
422 |
isabelle_home_hg.push(isabelle_hg.root_url, rev = rev, force = true) |
|
423 |
rev |
|
424 |
} |
|
425 |
else {
|
|
426 |
isabelle_hg.pull() |
|
427 |
isabelle_hg.id() |
|
428 |
} |
|
|
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
|
429 |
isabelle_hg.update(rev = rev, clean = true) |
| 64459 | 430 |
ssh.execute( |
431 |
ssh.bash_path(isabelle_repos_self + Path.explode("bin/isabelle"))
|
|
432 |
+ " components -a").check |
|
| 64353 | 433 |
ssh.execute(ssh.bash_path(isabelle_admin + Path.explode("build")) + " jars_fresh").check
|
434 |
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
|
435 |
} |
| 64353 | 436 |
else "tip" |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
437 |
|
|
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
|
438 |
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
|
439 |
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
|
440 |
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
|
441 |
other_hg.pull(isabelle_hg.root.implode) |
| 64353 | 442 |
other_hg.update(rev = rev, clean = true) |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
443 |
|
|
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
444 |
|
|
64256
c3197aeae90b
simplified SSH.Session: sftp channel is always open and its operations provided by the main interface;
wenzelm
parents:
64253
diff
changeset
|
445 |
/* Admin/build_history */ |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
446 |
|
|
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
447 |
ssh.with_tmp_dir(tmp_dir => |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
448 |
{
|
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
449 |
val output_file = tmp_dir + Path.explode("output")
|
| 64346 | 450 |
|
|
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
451 |
val process_result = |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
452 |
ssh.execute( |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
453 |
ssh.bash_path(isabelle_admin + Path.explode("build_history")) +
|
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
454 |
" -o " + ssh.bash_path(output_file) + " " + options + " " + |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
455 |
ssh.bash_path(isabelle_repos_other) + " " + args, |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
456 |
progress_stdout = progress.echo(_), |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
457 |
progress_stderr = progress.echo(_), |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
458 |
strict = false) |
|
64468
ed8940d6295c
back to more elementary result (see 5f49765a25ec): avoid concurrent use of ssh channel;
wenzelm
parents:
64466
diff
changeset
|
459 |
|
|
65846
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
460 |
val result = |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
461 |
for (line <- split_lines(ssh.read(output_file))) |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
462 |
yield {
|
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
463 |
val log = Path.explode(line) |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
464 |
val bytes = ssh.read_bytes(log) |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
465 |
ssh.rm(log) |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
466 |
(log.base.implode, bytes) |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
467 |
} |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
468 |
|
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
469 |
(result, process_result) |
|
aa6e58dc54d0
prefer explicit output file: potentially more robust than stdout;
wenzelm
parents:
65845
diff
changeset
|
470 |
}) |
|
64223
9d5b9f41df77
remove invocation of build_history: results are reported via stdout;
wenzelm
parents:
64213
diff
changeset
|
471 |
} |
|
64021
1e23caac8757
basic setup for Admin/build_history -- outside of Isabelle environment;
wenzelm
parents:
diff
changeset
|
472 |
} |