src/Pure/Tools/build_history.scala
author wenzelm
Tue Oct 11 22:24:14 2016 +0200 (2016-10-11)
changeset 64155 646c4d6a6a02
parent 64151 be9b3cffe058
permissions -rw-r--r--
tuned signature;
wenzelm@64021
     1
/*  Title:      Pure/Tools/build_history.scala
wenzelm@64021
     2
    Author:     Makarius
wenzelm@64021
     3
wenzelm@64021
     4
Build other history versions.
wenzelm@64021
     5
*/
wenzelm@64021
     6
wenzelm@64021
     7
package isabelle
wenzelm@64021
     8
wenzelm@64021
     9
wenzelm@64021
    10
import java.io.{File => JFile}
wenzelm@64117
    11
import java.time.format.DateTimeFormatter
wenzelm@64118
    12
import java.util.Locale
wenzelm@64021
    13
wenzelm@64021
    14
wenzelm@64021
    15
object Build_History
wenzelm@64021
    16
{
wenzelm@64117
    17
  /* log files */
wenzelm@64117
    18
wenzelm@64117
    19
  val BUILD_HISTORY = "build_history"
wenzelm@64119
    20
  val META_INFO_MARKER = "\fmeta_info = "
wenzelm@64117
    21
wenzelm@64117
    22
wenzelm@64117
    23
wenzelm@64050
    24
  /** other Isabelle environment **/
wenzelm@64049
    25
wenzelm@64049
    26
  private class Other_Isabelle(progress: Progress, isabelle_home: Path, isabelle_identifier: String)
wenzelm@64049
    27
  {
wenzelm@64049
    28
    other_isabelle =>
wenzelm@64049
    29
wenzelm@64050
    30
wenzelm@64050
    31
    /* static system */
wenzelm@64050
    32
wenzelm@64049
    33
    def bash(script: String, redirect: Boolean = false, echo: Boolean = false): Process_Result =
wenzelm@64049
    34
      Isabelle_System.bash(
wenzelm@64049
    35
        "export ISABELLE_IDENTIFIER=" + File.bash_string(isabelle_identifier) + "\n" + script,
wenzelm@64049
    36
        env = null, cwd = isabelle_home.file, redirect = redirect,
wenzelm@64049
    37
        progress_stdout = progress.echo_if(echo, _),
wenzelm@64049
    38
        progress_stderr = progress.echo_if(echo, _))
wenzelm@64049
    39
wenzelm@64052
    40
    def copy_dir(dir1: Path, dir2: Path): Unit =
wenzelm@64052
    41
      bash("cp -a " + File.bash_path(dir1) + " " + File.bash_path(dir2)).check
wenzelm@64052
    42
wenzelm@64049
    43
    def apply(cmdline: String, redirect: Boolean = false, echo: Boolean = false): Process_Result =
wenzelm@64049
    44
      bash("bin/isabelle " + cmdline, redirect, echo)
wenzelm@64049
    45
wenzelm@64049
    46
    def resolve_components(echo: Boolean): Unit =
wenzelm@64049
    47
      other_isabelle("components -a", redirect = true, echo = echo).check
wenzelm@64049
    48
wenzelm@64050
    49
    val isabelle_home_user: Path =
wenzelm@64049
    50
      Path.explode(other_isabelle("getenv -b ISABELLE_HOME_USER").check.out)
wenzelm@64050
    51
wenzelm@64050
    52
    val etc_settings: Path = isabelle_home_user + Path.explode("etc/settings")
wenzelm@64117
    53
    val log_dir: Path = isabelle_home_user + Path.explode("log")
wenzelm@64050
    54
wenzelm@64050
    55
wenzelm@64050
    56
    /* reset settings */
wenzelm@64050
    57
wenzelm@64050
    58
    def reset_settings(components_base: String, nonfree: Boolean)
wenzelm@64050
    59
    {
wenzelm@64050
    60
      if (etc_settings.is_file && !File.read(etc_settings).startsWith("# generated by Isabelle"))
wenzelm@64050
    61
        error("Cannot proceed with existing user settings file: " + etc_settings)
wenzelm@64050
    62
wenzelm@64050
    63
      Isabelle_System.mkdirs(etc_settings.dir)
wenzelm@64050
    64
      File.write(etc_settings,
wenzelm@64151
    65
        "# generated by Isabelle " + Date.now() + "\n" +
wenzelm@64050
    66
        "#-*- shell-script -*- :mode=shellscript:\n")
wenzelm@64050
    67
wenzelm@64050
    68
      val component_settings =
wenzelm@64050
    69
      {
wenzelm@64050
    70
        val components_base_path =
wenzelm@64050
    71
          if (components_base == "") isabelle_home_user.dir + Path.explode("contrib")
wenzelm@64050
    72
          else Path.explode(components_base).expand
wenzelm@64050
    73
wenzelm@64050
    74
        val catalogs =
wenzelm@64050
    75
          if (nonfree) List("main", "optional", "nonfree") else List("main", "optional")
wenzelm@64050
    76
wenzelm@64050
    77
        catalogs.map(catalog =>
wenzelm@64050
    78
          "init_components " + File.bash_path(components_base_path) +
wenzelm@64050
    79
            " \"$ISABELLE_HOME/Admin/components/" + catalog + "\"")
wenzelm@64050
    80
      }
wenzelm@64050
    81
      File.append(etc_settings, "\n" + Library.terminate_lines(component_settings))
wenzelm@64050
    82
    }
wenzelm@64050
    83
wenzelm@64050
    84
wenzelm@64050
    85
    /* augment settings */
wenzelm@64050
    86
wenzelm@64050
    87
    def augment_settings(
wenzelm@64050
    88
      threads: Int,
wenzelm@64050
    89
      arch_64: Boolean = false,
wenzelm@64050
    90
      heap: Int = default_heap,
wenzelm@64050
    91
      max_heap: Option[Int] = None,
wenzelm@64117
    92
      more_settings: List[String]): String =
wenzelm@64050
    93
    {
wenzelm@64117
    94
      val (ml_platform, ml_settings) =
wenzelm@64050
    95
      {
wenzelm@64050
    96
        val windows_32 = "x86-windows"
wenzelm@64050
    97
        val windows_64 = "x86_64-windows"
wenzelm@64050
    98
        val platform_32 = other_isabelle("getenv -b ISABELLE_PLATFORM32").check.out
wenzelm@64050
    99
        val platform_64 = other_isabelle("getenv -b ISABELLE_PLATFORM64").check.out
wenzelm@64050
   100
        val platform_family = other_isabelle("getenv -b ISABELLE_PLATFORM_FAMILY").check.out
wenzelm@64050
   101
wenzelm@64050
   102
        val polyml_home =
wenzelm@64050
   103
          try { Path.explode(other_isabelle("getenv -b ML_HOME").check.out).dir }
wenzelm@64050
   104
          catch { case ERROR(msg) => error("Bad ML_HOME: " + msg) }
wenzelm@64050
   105
wenzelm@64050
   106
        def ml_home(platform: String): Path = polyml_home + Path.explode(platform)
wenzelm@64050
   107
wenzelm@64050
   108
        def err(platform: String): Nothing =
wenzelm@64050
   109
          error("Platform " + platform + " unavailable on this machine")
wenzelm@64050
   110
wenzelm@64050
   111
        def check_dir(platform: String): Boolean =
wenzelm@64050
   112
          platform != "" && ml_home(platform).is_dir
wenzelm@64050
   113
wenzelm@64050
   114
        val ml_platform =
wenzelm@64050
   115
          if (Platform.is_windows && arch_64) {
wenzelm@64050
   116
            if (check_dir(windows_64)) windows_64 else err(windows_64)
wenzelm@64050
   117
          }
wenzelm@64050
   118
          else if (Platform.is_windows && !arch_64) {
wenzelm@64050
   119
            if (check_dir(windows_32)) windows_32
wenzelm@64050
   120
            else platform_32  // x86-cygwin
wenzelm@64050
   121
          }
wenzelm@64050
   122
          else {
wenzelm@64050
   123
            val (platform, platform_name) =
wenzelm@64050
   124
              if (arch_64) (platform_64, "x86_64-" + platform_family)
wenzelm@64050
   125
              else (platform_32, "x86-" + platform_family)
wenzelm@64050
   126
            if (check_dir(platform)) platform else err(platform_name)
wenzelm@64050
   127
          }
wenzelm@64050
   128
wenzelm@64050
   129
        val ml_options =
wenzelm@64050
   130
          "--minheap " + heap + (if (max_heap.isDefined) " --maxheap " + max_heap.get else "") +
wenzelm@64050
   131
          " --gcthreads " + threads +
wenzelm@64050
   132
          (if (ml_platform.endsWith("-windows")) " --codepage utf8" else "")
wenzelm@64050
   133
wenzelm@64117
   134
        (ml_platform,
wenzelm@64117
   135
          List(
wenzelm@64117
   136
            "ML_HOME=" + File.bash_path(ml_home(ml_platform)),
wenzelm@64117
   137
            "ML_PLATFORM=" + quote(ml_platform),
wenzelm@64117
   138
            "ML_OPTIONS=" + quote(ml_options)))
wenzelm@64050
   139
      }
wenzelm@64050
   140
wenzelm@64050
   141
      val thread_settings =
wenzelm@64050
   142
        List(
wenzelm@64050
   143
          "ISABELLE_JAVA_SYSTEM_OPTIONS=\"$ISABELLE_JAVA_SYSTEM_OPTIONS -Disabelle.threads=" + threads + "\"",
wenzelm@64050
   144
          "ISABELLE_BUILD_OPTIONS=\"threads=" + threads + "\"")
wenzelm@64050
   145
wenzelm@64050
   146
      val settings =
wenzelm@64050
   147
        List(ml_settings, thread_settings) :::
wenzelm@64050
   148
          (if (more_settings.isEmpty) Nil else List(more_settings))
wenzelm@64050
   149
wenzelm@64050
   150
      File.append(etc_settings, "\n" + cat_lines(settings.map(Library.terminate_lines(_))))
wenzelm@64117
   151
wenzelm@64117
   152
      ml_platform
wenzelm@64050
   153
    }
wenzelm@64049
   154
  }
wenzelm@64049
   155
wenzelm@64049
   156
wenzelm@64049
   157
wenzelm@64050
   158
  /** build_history **/
wenzelm@64025
   159
wenzelm@64025
   160
  private val default_rev = "tip"
wenzelm@64030
   161
  private val default_threads = 1
wenzelm@64034
   162
  private val default_heap = 1000
wenzelm@64025
   163
  private val default_isabelle_identifier = "build_history"
wenzelm@64025
   164
wenzelm@64025
   165
  def build_history(
wenzelm@64038
   166
    progress: Progress,
wenzelm@64025
   167
    hg: Mercurial.Repository,
wenzelm@64025
   168
    rev: String = default_rev,
wenzelm@64025
   169
    isabelle_identifier: String = default_isabelle_identifier,
wenzelm@64025
   170
    components_base: String = "",
wenzelm@64026
   171
    fresh: Boolean = false,
wenzelm@64025
   172
    nonfree: Boolean = false,
wenzelm@64052
   173
    multicore_base: Boolean = false,
wenzelm@64051
   174
    threads_list: List[Int] = List(default_threads),
wenzelm@64030
   175
    arch_64: Boolean = false,
wenzelm@64030
   176
    heap: Int = default_heap,
wenzelm@64036
   177
    max_heap: Option[Int] = None,
wenzelm@64030
   178
    more_settings: List[String] = Nil,
wenzelm@64026
   179
    verbose: Boolean = false,
wenzelm@64051
   180
    build_args: List[String] = Nil): List[Process_Result] =
wenzelm@64025
   181
  {
wenzelm@64031
   182
    /* sanity checks */
wenzelm@64031
   183
wenzelm@64046
   184
    if (File.eq(Path.explode("~~").file, hg.root.file))
wenzelm@64046
   185
      error("Repository coincides with ISABELLE_HOME=" + Path.explode("~~").expand)
wenzelm@64046
   186
wenzelm@64051
   187
    for (threads <- threads_list if threads < 1) error("Bad threads value < 1: " + threads)
wenzelm@64036
   188
wenzelm@64030
   189
    if (heap < 100) error("Bad heap value < 100: " + heap)
wenzelm@64030
   190
wenzelm@64036
   191
    if (max_heap.isDefined && max_heap.get < heap)
wenzelm@64036
   192
      error("Bad max_heap value < heap: " + max_heap.get)
wenzelm@64036
   193
wenzelm@64031
   194
    System.getenv("ISABELLE_SETTINGS_PRESENT") match {
wenzelm@64031
   195
      case null | "" =>
wenzelm@64031
   196
      case _ => error("Cannot run build_history within existing Isabelle settings environment")
wenzelm@64031
   197
    }
wenzelm@64031
   198
wenzelm@64031
   199
wenzelm@64049
   200
    /* init repository */
wenzelm@64031
   201
wenzelm@64025
   202
    hg.update(rev = rev, clean = true)
wenzelm@64049
   203
    progress.echo_if(verbose, hg.log(rev, options = "-l1"))
wenzelm@64025
   204
wenzelm@64117
   205
    val isabelle_version = hg.identify(rev, options = "-i")
wenzelm@64049
   206
    val other_isabelle = new Other_Isabelle(progress, hg.root, isabelle_identifier)
wenzelm@64025
   207
wenzelm@64051
   208
wenzelm@64052
   209
    /* main */
wenzelm@64043
   210
wenzelm@64117
   211
    val build_history_date = Date.now()
wenzelm@64139
   212
    val build_host = Isabelle_System.hostname()
wenzelm@64117
   213
wenzelm@64051
   214
    var first_build = true
wenzelm@64052
   215
    for (threads <- threads_list) yield
wenzelm@64052
   216
    {
wenzelm@64052
   217
      /* init settings */
wenzelm@64052
   218
wenzelm@64051
   219
      other_isabelle.reset_settings(components_base, nonfree)
wenzelm@64051
   220
      other_isabelle.resolve_components(verbose)
wenzelm@64117
   221
      val ml_platform =
wenzelm@64117
   222
        other_isabelle.augment_settings(threads, arch_64, heap, max_heap, more_settings)
wenzelm@64043
   223
wenzelm@64052
   224
      val isabelle_output = Path.explode(other_isabelle("getenv -b ISABELLE_OUTPUT").check.out)
wenzelm@64052
   225
      val isabelle_output_log = isabelle_output + Path.explode("log")
wenzelm@64052
   226
      val isabelle_base_log = isabelle_output + Path.explode("../base_log")
wenzelm@64052
   227
wenzelm@64051
   228
      if (first_build) {
wenzelm@64051
   229
        other_isabelle.resolve_components(verbose)
wenzelm@64051
   230
        other_isabelle.bash(
wenzelm@64051
   231
          "env PATH=\"" + File.bash_path(Path.explode("~~/lib/dummy_stty").expand) + ":$PATH\" " +
wenzelm@64051
   232
            "bin/isabelle jedit -b" + (if (fresh) " -f" else ""),
wenzelm@64051
   233
          redirect = true, echo = verbose).check
wenzelm@64052
   234
wenzelm@64052
   235
        Isabelle_System.rm_tree(isabelle_base_log.file)
wenzelm@64051
   236
      }
wenzelm@64025
   237
wenzelm@64051
   238
      Isabelle_System.rm_tree(isabelle_output.file)
wenzelm@64052
   239
      Isabelle_System.mkdirs(isabelle_output)
wenzelm@64052
   240
wenzelm@64052
   241
wenzelm@64052
   242
      /* build */
wenzelm@64052
   243
wenzelm@64052
   244
      if (multicore_base && !first_build && isabelle_base_log.is_dir)
wenzelm@64052
   245
        other_isabelle.copy_dir(isabelle_base_log, isabelle_output_log)
wenzelm@64052
   246
wenzelm@64117
   247
      val build_start = Date.now()
wenzelm@64121
   248
      val res =
wenzelm@64121
   249
        other_isabelle("build -v " + File.bash_args(build_args), redirect = true, echo = verbose)
wenzelm@64117
   250
      val build_end = Date.now()
wenzelm@64117
   251
wenzelm@64119
   252
wenzelm@64119
   253
      /* output log */
wenzelm@64119
   254
wenzelm@64117
   255
      val log_path =
wenzelm@64150
   256
        other_isabelle.log_dir +
wenzelm@64150
   257
          Build_Log.log_path(BUILD_HISTORY, build_history_date, ml_platform, "M" + threads).ext("gz")
wenzelm@64117
   258
wenzelm@64120
   259
      val build_info = Build_Log.Log_File(log_path.base.implode, res.out_lines).parse_build_info()
wenzelm@64120
   260
wenzelm@64117
   261
      val meta_info =
wenzelm@64117
   262
        List(Build_Log.Field.build_engine -> BUILD_HISTORY,
wenzelm@64117
   263
          Build_Log.Field.build_host -> build_host,
wenzelm@64155
   264
          Build_Log.Field.build_start -> Build_Log.print_date(build_start),
wenzelm@64155
   265
          Build_Log.Field.build_end -> Build_Log.print_date(build_end),
wenzelm@64117
   266
          Build_Log.Field.isabelle_version -> isabelle_version)
wenzelm@64117
   267
wenzelm@64119
   268
      val ml_statistics =
wenzelm@64120
   269
        build_info.finished_sessions.flatMap(session_name =>
wenzelm@64120
   270
          {
wenzelm@64120
   271
            val session_log = isabelle_output_log + Path.explode(session_name).ext("gz")
wenzelm@64120
   272
            if (session_log.is_file) {
wenzelm@64120
   273
              Build_Log.Log_File(session_log).parse_session_info(ml_statistics = true).
wenzelm@64120
   274
                ml_statistics.map(props => (Build_Log.SESSION_NAME -> session_name) :: props)
wenzelm@64120
   275
            }
wenzelm@64120
   276
            else Nil
wenzelm@64120
   277
          })
wenzelm@64120
   278
wenzelm@64120
   279
      val heap_sizes =
wenzelm@64120
   280
        build_info.finished_sessions.flatMap(session_name =>
wenzelm@64120
   281
          {
wenzelm@64120
   282
            val heap = isabelle_output + Path.explode(session_name)
wenzelm@64120
   283
            if (heap.is_file)
wenzelm@64120
   284
              Some("Heap " + session_name + " (" + Value.Long(heap.file.length) + " bytes)")
wenzelm@64120
   285
            else None
wenzelm@64120
   286
          })
wenzelm@64119
   287
wenzelm@64119
   288
      Isabelle_System.mkdirs(log_path.dir)
wenzelm@64117
   289
      File.write_gzip(log_path,
wenzelm@64120
   290
        Library.terminate_lines(
wenzelm@64119
   291
          Build_Log.Log_File.print_props(META_INFO_MARKER, meta_info) :: res.out_lines :::
wenzelm@64120
   292
          ml_statistics.map(Build_Log.Log_File.print_props(Build_Log.ML_STATISTICS_MARKER, _)) :::
wenzelm@64120
   293
          heap_sizes))
wenzelm@64117
   294
wenzelm@64117
   295
      Output.writeln(log_path.implode, stdout = true)
wenzelm@64052
   296
wenzelm@64119
   297
wenzelm@64119
   298
      /* next build */
wenzelm@64119
   299
wenzelm@64052
   300
      if (multicore_base && first_build && isabelle_output_log.is_dir)
wenzelm@64052
   301
        other_isabelle.copy_dir(isabelle_output_log, isabelle_base_log)
wenzelm@64052
   302
wenzelm@64052
   303
      first_build = false
wenzelm@64052
   304
wenzelm@64052
   305
      res
wenzelm@64051
   306
    }
wenzelm@64025
   307
  }
wenzelm@64021
   308
wenzelm@64021
   309
wenzelm@64021
   310
  /* command line entry point */
wenzelm@64021
   311
wenzelm@64021
   312
  def main(args: Array[String])
wenzelm@64021
   313
  {
wenzelm@64021
   314
    Command_Line.tool0 {
wenzelm@64052
   315
      var multicore_base = false
wenzelm@64025
   316
      var components_base = ""
wenzelm@64030
   317
      var heap: Option[Int] = None
wenzelm@64036
   318
      var max_heap: Option[Int] = None
wenzelm@64051
   319
      var threads_list = List(default_threads)
wenzelm@64025
   320
      var isabelle_identifier = default_isabelle_identifier
wenzelm@64030
   321
      var more_settings: List[String] = Nil
wenzelm@64026
   322
      var fresh = false
wenzelm@64030
   323
      var arch_64 = false
wenzelm@64025
   324
      var nonfree = false
wenzelm@64025
   325
      var rev = default_rev
wenzelm@64025
   326
      var verbose = false
wenzelm@64021
   327
wenzelm@64021
   328
      val getopts = Getopts("""
wenzelm@64026
   329
Usage: isabelle build_history [OPTIONS] REPOSITORY [ARGS ...]
wenzelm@64021
   330
wenzelm@64021
   331
  Options are:
wenzelm@64052
   332
    -B           first multicore build serves as base for scheduling information
wenzelm@64025
   333
    -C DIR       base directory for Isabelle components (default: $ISABELLE_HOME_USER/../contrib)
wenzelm@64036
   334
    -H SIZE      minimal ML heap in MB (default: """ + default_heap + """ for x86, """ + default_heap * 2 + """ for x86_64)
wenzelm@64052
   335
    -M THREADS   multicore configurations (comma-separated list, default: """ + default_threads + """)
wenzelm@64025
   336
    -N NAME      alternative ISABELLE_IDENTIFIER (default: """ + default_isabelle_identifier + """)
wenzelm@64036
   337
    -U SIZE      maximal ML heap in MB (default: unbounded)
wenzelm@64030
   338
    -e TEXT      additional text for generated etc/settings
wenzelm@64026
   339
    -f           fresh build of Isabelle/Scala components (recommended)
wenzelm@64030
   340
    -m ARCH      processor architecture (32=x86, 64=x86_64, default: x86)
wenzelm@64025
   341
    -n           include nonfree components
wenzelm@64026
   342
    -r REV       update to revision (default: """ + default_rev + """)
wenzelm@64025
   343
    -v           verbose
wenzelm@64021
   344
wenzelm@64021
   345
  Build Isabelle sessions from the history of another REPOSITORY clone,
wenzelm@64026
   346
  passing ARGS directly to its isabelle build tool.
wenzelm@64021
   347
""",
wenzelm@64052
   348
        "B" -> (_ => multicore_base = true),
wenzelm@64025
   349
        "C:" -> (arg => components_base = arg),
wenzelm@64030
   350
        "H:" -> (arg => heap = Some(Value.Int.parse(arg))),
wenzelm@64051
   351
        "M:" -> (arg => threads_list = space_explode(',', arg).map(Value.Int.parse(_))),
wenzelm@64025
   352
        "N:" -> (arg => isabelle_identifier = arg),
wenzelm@64036
   353
        "U:" -> (arg => max_heap = Some(Value.Int.parse(arg))),
wenzelm@64030
   354
        "e:" -> (arg => more_settings = more_settings ::: List(arg)),
wenzelm@64026
   355
        "f" -> (_ => fresh = true),
wenzelm@64030
   356
        "m:" ->
wenzelm@64030
   357
          {
wenzelm@64030
   358
            case "32" | "x86" => arch_64 = false
wenzelm@64030
   359
            case "64" | "x86_64" => arch_64 = true
wenzelm@64030
   360
            case bad => error("Bad processor architecture: " + quote(bad))
wenzelm@64030
   361
          },
wenzelm@64025
   362
        "n" -> (_ => nonfree = true),
wenzelm@64025
   363
        "r:" -> (arg => rev = arg),
wenzelm@64025
   364
        "v" -> (_ => verbose = true))
wenzelm@64021
   365
wenzelm@64021
   366
      val more_args = getopts(args)
wenzelm@64026
   367
      val (root, build_args) =
wenzelm@64026
   368
        more_args match {
wenzelm@64026
   369
          case root :: build_args => (root, build_args)
wenzelm@64026
   370
          case _ => getopts.usage()
wenzelm@64026
   371
        }
wenzelm@64021
   372
wenzelm@64021
   373
      using(Mercurial.open_repository(Path.explode(root)))(hg =>
wenzelm@64021
   374
        {
wenzelm@64117
   375
          val progress = new Console_Progress(stderr = true)
wenzelm@64051
   376
          val results =
wenzelm@64038
   377
            build_history(progress, hg, rev = rev, isabelle_identifier = isabelle_identifier,
wenzelm@64026
   378
              components_base = components_base, fresh = fresh, nonfree = nonfree,
wenzelm@64052
   379
              multicore_base = multicore_base, threads_list = threads_list, arch_64 = arch_64,
wenzelm@64030
   380
              heap = heap.getOrElse(if (arch_64) default_heap * 2 else default_heap),
wenzelm@64036
   381
              max_heap = max_heap, more_settings = more_settings, verbose = verbose,
wenzelm@64036
   382
              build_args = build_args)
wenzelm@64051
   383
          val rc = (0 /: results) { case (rc, res) => rc max res.rc }
wenzelm@64051
   384
          if (rc != 0) sys.exit(rc)
wenzelm@64021
   385
        })
wenzelm@64021
   386
    }
wenzelm@64021
   387
  }
wenzelm@64021
   388
}