src/Pure/Admin/build_log.scala
author wenzelm
Fri, 28 Apr 2017 14:12:57 +0200
changeset 65605 a6447eb6bc38
parent 65603 d6fe8a277576
child 65607 c937984c70e9
permissions -rw-r--r--
separate small meta_info vs. big build_info;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64160
1eea419fab65 clarified files;
wenzelm
parents: 64155
diff changeset
     1
/*  Title:      Pure/Admin/build_log.scala
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     3
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
     4
Build log parsing for current and historic formats.
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     5
*/
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     6
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     7
package isabelle
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     8
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
     9
64100
9b1573213ebe tuned error;
wenzelm
parents: 64099
diff changeset
    10
import java.io.{File => JFile}
9b1573213ebe tuned error;
wenzelm
parents: 64099
diff changeset
    11
import java.time.ZoneId
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
    12
import java.time.format.{DateTimeFormatter, DateTimeParseException}
64096
5edeb60a7ec5 more flexible date formats;
wenzelm
parents: 64095
diff changeset
    13
import java.util.Locale
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
    14
import java.sql.PreparedStatement
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
    15
65600
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
    16
import scala.collection.immutable.SortedMap
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    17
import scala.collection.mutable
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    18
import scala.util.matching.Regex
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    19
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
    20
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
    21
object Build_Log
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
    22
{
64298
wenzelm
parents: 64297
diff changeset
    23
  /** content **/
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
    24
64298
wenzelm
parents: 64297
diff changeset
    25
  /* properties */
64150
b10f2ddd7679 clarified modules;
wenzelm
parents: 64120
diff changeset
    26
64298
wenzelm
parents: 64297
diff changeset
    27
  object Prop
wenzelm
parents: 64297
diff changeset
    28
  {
64303
605351c7ef97 another attempt to squeeze a list into a property list entry;
wenzelm
parents: 64300
diff changeset
    29
    val separator = '\u000b'
605351c7ef97 another attempt to squeeze a list into a property list entry;
wenzelm
parents: 64300
diff changeset
    30
64300
3073688abbe9 clarified multiple props: result needs to fit on a single line within the log file;
wenzelm
parents: 64299
diff changeset
    31
    def multiple(name: String, args: List[String]): Properties.T =
3073688abbe9 clarified multiple props: result needs to fit on a single line within the log file;
wenzelm
parents: 64299
diff changeset
    32
      if (args.isEmpty) Nil
64303
605351c7ef97 another attempt to squeeze a list into a property list entry;
wenzelm
parents: 64300
diff changeset
    33
      else List(name -> args.mkString(separator.toString))
64299
4f11063c6e55 clarified properties;
wenzelm
parents: 64298
diff changeset
    34
65601
e76d8f3e5478 more standard multi-line storage in database: Prop.separator is only required for single-line meta_info within log file;
wenzelm
parents: 65600
diff changeset
    35
    def multiple_lines(s: String): String =
e76d8f3e5478 more standard multi-line storage in database: Prop.separator is only required for single-line meta_info within log file;
wenzelm
parents: 65600
diff changeset
    36
      cat_lines(Library.space_explode(separator, s))
e76d8f3e5478 more standard multi-line storage in database: Prop.separator is only required for single-line meta_info within log file;
wenzelm
parents: 65600
diff changeset
    37
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    38
    val build_tags = SQL.Column.string("build_tags")  // multiple
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    39
    val build_args = SQL.Column.string("build_args")  // multiple
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    40
    val build_group_id = SQL.Column.string("build_group_id")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    41
    val build_id = SQL.Column.string("build_id")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    42
    val build_engine = SQL.Column.string("build_engine")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    43
    val build_host = SQL.Column.string("build_host")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    44
    val build_start = SQL.Column.date("build_start")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    45
    val build_end = SQL.Column.date("build_end")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    46
    val isabelle_version = SQL.Column.string("isabelle_version")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    47
    val afp_version = SQL.Column.string("afp_version")
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    48
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    49
    val columns: List[SQL.Column] =
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    50
      List(build_tags, build_args, build_group_id, build_id, build_engine,
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
    51
        build_host, build_start, build_end, isabelle_version, afp_version)
64298
wenzelm
parents: 64297
diff changeset
    52
  }
64150
b10f2ddd7679 clarified modules;
wenzelm
parents: 64120
diff changeset
    53
b10f2ddd7679 clarified modules;
wenzelm
parents: 64120
diff changeset
    54
64298
wenzelm
parents: 64297
diff changeset
    55
  /* settings */
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    56
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    57
  object Settings
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    58
  {
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    59
    val build_settings = List("ISABELLE_BUILD_OPTIONS")
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    60
    val ml_settings = List("ML_PLATFORM", "ML_HOME", "ML_SYSTEM", "ML_OPTIONS")
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    61
    val all_settings = build_settings ::: ml_settings
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    62
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    63
    type Entry = (String, String)
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    64
    type T = List[Entry]
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    65
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    66
    object Entry
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    67
    {
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    68
      def unapply(s: String): Option[Entry] =
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    69
        s.indexOf('=') match {
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    70
          case -1 => None
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    71
          case i =>
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    72
            val a = s.substring(0, i)
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    73
            val b = Library.perhaps_unquote(s.substring(i + 1))
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    74
            Some((a, b))
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    75
        }
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    76
      def apply(a: String, b: String): String = a + "=" + quote(b)
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    77
      def getenv(a: String): String = apply(a, Isabelle_System.getenv(a))
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    78
    }
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    79
64081
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    80
    def show(): String =
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    81
      cat_lines(
38bb09ed965b more uniform treatment of settings;
wenzelm
parents: 64080
diff changeset
    82
        build_settings.map(Entry.getenv(_)) ::: List("") ::: ml_settings.map(Entry.getenv(_)))
64080
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    83
  }
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    84
2e5c0bd708af clarified modules;
wenzelm
parents: 64079
diff changeset
    85
64298
wenzelm
parents: 64297
diff changeset
    86
  /* file names */
wenzelm
parents: 64297
diff changeset
    87
wenzelm
parents: 64297
diff changeset
    88
  def log_date(date: Date): String =
wenzelm
parents: 64297
diff changeset
    89
    String.format(Locale.ROOT, "%s.%05d",
wenzelm
parents: 64297
diff changeset
    90
      DateTimeFormatter.ofPattern("yyyy-MM-dd").format(date.rep),
wenzelm
parents: 64297
diff changeset
    91
      new java.lang.Long((date.time - date.midnight.time).ms / 1000))
wenzelm
parents: 64297
diff changeset
    92
wenzelm
parents: 64297
diff changeset
    93
  def log_subdir(date: Date): Path =
wenzelm
parents: 64297
diff changeset
    94
    Path.explode("log") + Path.explode(date.rep.getYear.toString)
wenzelm
parents: 64297
diff changeset
    95
wenzelm
parents: 64297
diff changeset
    96
  def log_filename(engine: String, date: Date, more: List[String] = Nil): Path =
wenzelm
parents: 64297
diff changeset
    97
    Path.explode((engine :: log_date(date) :: more).mkString("", "_", ".log"))
wenzelm
parents: 64297
diff changeset
    98
wenzelm
parents: 64297
diff changeset
    99
wenzelm
parents: 64297
diff changeset
   100
  /* log file collections */
wenzelm
parents: 64297
diff changeset
   101
65588
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   102
  def is_log(file: JFile,
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   103
    prefixes: Iterable[String] =
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   104
      List(Build_History.log_prefix, Isatest.log_prefix, AFP_Test.log_prefix),
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   105
    suffixes: Iterable[String] =
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   106
      List(".log", ".log.gz", ".log.xz")): Boolean =
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   107
  {
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   108
    val name = file.getName
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   109
    prefixes.iterator.exists(name.startsWith(_)) &&
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   110
    suffixes.iterator.exists(name.endsWith(_))
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   111
  }
64298
wenzelm
parents: 64297
diff changeset
   112
65588
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   113
  def log_files(dirs: Iterable[Path]): List[JFile] =
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   114
    dirs.iterator.flatMap(dir => File.find_files(dir.file, is_log(_))).toList
64298
wenzelm
parents: 64297
diff changeset
   115
wenzelm
parents: 64297
diff changeset
   116
64100
9b1573213ebe tuned error;
wenzelm
parents: 64099
diff changeset
   117
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   118
  /** log file **/
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   119
64155
646c4d6a6a02 tuned signature;
wenzelm
parents: 64150
diff changeset
   120
  def print_date(date: Date): String = Log_File.Date_Format(date)
646c4d6a6a02 tuned signature;
wenzelm
parents: 64150
diff changeset
   121
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   122
  object Log_File
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   123
  {
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   124
    def apply(name: String, lines: List[String]): Log_File =
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   125
      new Log_File(name, lines)
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   126
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   127
    def apply(name: String, text: String): Log_File =
64063
2c5039363ea3 tuned signature;
wenzelm
parents: 64062
diff changeset
   128
      Log_File(name, Library.trim_split_lines(text))
64090
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   129
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   130
    def apply(file: JFile): Log_File =
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   131
    {
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   132
      val name = file.getName
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   133
      val (base_name, text) =
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   134
        Library.try_unsuffix(".gz", name) match {
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   135
          case Some(base_name) => (base_name, File.read_gzip(file))
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   136
          case None =>
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   137
            Library.try_unsuffix(".xz", name) match {
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   138
              case Some(base_name) => (base_name, File.read_xz(file))
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   139
              case None => (name, File.read(file))
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   140
            }
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   141
          }
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   142
      apply(base_name, text)
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   143
    }
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   144
5a68280112b3 more operations;
wenzelm
parents: 64089
diff changeset
   145
    def apply(path: Path): Log_File = apply(path.file)
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   146
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   147
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   148
    /* date format */
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   149
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   150
    val Date_Format =
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   151
    {
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   152
      val fmts =
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   153
        Date.Formatter.variants(
64116
6cfd429a4296 prefer explicit timezone offset for printing;
wenzelm
parents: 64111
diff changeset
   154
          List("EEE MMM d HH:mm:ss O yyyy", "EEE MMM d HH:mm:ss VV yyyy"),
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   155
          List(Locale.ENGLISH, Locale.GERMAN)) :::
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   156
        List(
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   157
          DateTimeFormatter.RFC_1123_DATE_TIME,
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   158
          Date.Formatter.pattern("EEE MMM d HH:mm:ss yyyy").withZone(ZoneId.of("Europe/Berlin")))
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   159
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   160
      def tune_timezone(s: String): String =
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   161
        s match {
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   162
          case "CET" | "MET" => "GMT+1"
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   163
          case "CEST" | "MEST" => "GMT+2"
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   164
          case "EST" => "Europe/Berlin"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   165
          case _ => s
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   166
        }
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   167
      def tune_weekday(s: String): String =
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   168
        s match {
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   169
          case "Die" => "Di"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   170
          case "Mit" => "Mi"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   171
          case "Don" => "Do"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   172
          case "Fre" => "Fr"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   173
          case "Sam" => "Sa"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   174
          case "Son" => "So"
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   175
          case _ => s
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   176
        }
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   177
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   178
      def tune(s: String): String =
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   179
        Word.implode(
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   180
          Word.explode(s) match {
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   181
            case a :: "M\uFFFDr" :: bs => tune_weekday(a) :: "Mär" :: bs.map(tune_timezone(_))
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   182
            case a :: bs => tune_weekday(a) :: bs.map(tune_timezone(_))
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   183
            case Nil => Nil
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   184
          }
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   185
        )
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   186
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   187
      Date.Format.make(fmts, tune)
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   188
    }
64117
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   189
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   190
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   191
    /* inlined content */
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   192
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   193
    def print_props(marker: String, props: Properties.T): String =
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   194
      marker + YXML.string_of_body(XML.Encode.properties(props))
64102
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   195
  }
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   196
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   197
  class Log_File private(val name: String, val lines: List[String])
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   198
  {
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   199
    log_file =>
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   200
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   201
    override def toString: String = name
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   202
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   203
    def text: String = cat_lines(lines)
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   204
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   205
    def err(msg: String): Nothing =
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   206
      error("Error in log file " + quote(name) + ": " + msg)
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   207
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   208
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   209
    /* date format */
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   210
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   211
    object Strict_Date
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   212
    {
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   213
      def unapply(s: String): Some[Date] =
64102
1ec2adddf16b prefer static Date_Format;
wenzelm
parents: 64101
diff changeset
   214
        try { Some(Log_File.Date_Format.parse(s)) }
64101
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   215
        catch { case exn: DateTimeParseException => log_file.err(exn.getMessage) }
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   216
    }
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   217
976289c733e6 more formal directory content;
wenzelm
parents: 64100
diff changeset
   218
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   219
    /* inlined content */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   220
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   221
    def find[A](f: String => Option[A]): Option[A] =
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   222
      lines.iterator.map(f).find(_.isDefined).map(_.get)
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   223
64196
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   224
    def find_line(marker: String): Option[String] =
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   225
      find(Library.try_unprefix(marker, _))
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   226
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   227
    def find_match(regex: Regex): Option[String] =
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   228
      lines.iterator.map(regex.unapplySeq(_)).find(res => res.isDefined && res.get.length == 1).
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   229
        map(res => res.get.head)
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   230
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   231
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   232
    /* settings */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   233
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   234
    def get_setting(a: String): Option[Settings.Entry] =
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   235
      lines.find(_.startsWith(a + "=")) match {
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   236
        case Some(line) => Settings.Entry.unapply(line)
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   237
        case None => None
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   238
      }
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   239
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   240
    def get_settings(as: List[String]): Settings.T =
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   241
      for { a <- as; entry <- get_setting(a) } yield entry
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   242
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   243
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   244
    /* properties (YXML) */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   245
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   246
    val xml_cache = new XML.Cache()
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   247
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   248
    def parse_props(text: String): Properties.T =
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   249
      xml_cache.props(XML.Decode.properties(YXML.parse_body(text)))
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   250
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   251
    def filter_props(marker: String): List[Properties.T] =
64196
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   252
      for {
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   253
        line <- lines
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   254
        s <- Library.try_unprefix(marker, line)
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   255
        if YXML.detect(s)
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   256
      } yield parse_props(s)
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   257
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   258
    def find_props(marker: String): Option[Properties.T] =
64196
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   259
      find_line(marker) match {
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   260
        case Some(text) if YXML.detect(text) => Some(parse_props(text))
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   261
        case _ => None
6688b9cd443b more robust wrt. old versions that use clear-text properties (e.g. Timing in build_history_base);
wenzelm
parents: 64193
diff changeset
   262
      }
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   263
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   264
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   265
    /* parse various formats */
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   266
64105
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   267
    def parse_meta_info(): Meta_Info = Build_Log.parse_meta_info(log_file)
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   268
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   269
    def parse_build_info(): Build_Info = Build_Log.parse_build_info(log_file)
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   270
64082
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   271
    def parse_session_info(
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   272
        command_timings: Boolean = false,
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   273
        ml_statistics: Boolean = false,
d57c7295f601 clarified signature;
wenzelm
parents: 64081
diff changeset
   274
        task_statistics: Boolean = false): Session_Info =
65318
342efc382558 eliminated somewhat redundant inlined name (despite a7aa17a1f721);
wenzelm
parents: 65290
diff changeset
   275
      Build_Log.parse_session_info(log_file, command_timings, ml_statistics, task_statistics)
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   276
  }
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   277
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   278
64098
099518e8af2c misc tuning and clarification;
wenzelm
parents: 64096
diff changeset
   279
65276
fa1a5efee2ec tuned comments;
wenzelm
parents: 65052
diff changeset
   280
  /** digested meta info: produced by Admin/build_history in log.xz file **/
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   281
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   282
  object Meta_Info
64099
wenzelm
parents: 64098
diff changeset
   283
  {
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   284
    val empty: Meta_Info = Meta_Info(Nil, Nil)
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   285
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   286
    val log_filename = SQL.Column.string("log_filename", primary_key = true)
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   287
    val settings = SQL.Column.bytes("settings")
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   288
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   289
    val table =
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   290
      SQL.Table("isabelle_build_log_meta_info", log_filename :: Prop.columns ::: List(settings))
64099
wenzelm
parents: 64098
diff changeset
   291
  }
64098
099518e8af2c misc tuning and clarification;
wenzelm
parents: 64096
diff changeset
   292
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   293
  sealed case class Meta_Info(props: Properties.T, settings: List[(String, String)])
64103
60d163f38056 accept spurious empty logs;
wenzelm
parents: 64102
diff changeset
   294
  {
60d163f38056 accept spurious empty logs;
wenzelm
parents: 64102
diff changeset
   295
    def is_empty: Boolean = props.isEmpty && settings.isEmpty
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   296
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   297
    def get(c: SQL.Column): Option[String] = Properties.get(props, c.name)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   298
    def get_date(c: SQL.Column): Option[Date] = get(c).map(Log_File.Date_Format.parse(_))
64103
60d163f38056 accept spurious empty logs;
wenzelm
parents: 64102
diff changeset
   299
  }
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   300
64095
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   301
  object Isatest
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   302
  {
65588
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   303
    val log_prefix = "isatest-makeall-"
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   304
    val engine = "isatest"
64109
wenzelm
parents: 64108
diff changeset
   305
    val Start = new Regex("""^------------------- starting test --- (.+) --- (.+)$""")
wenzelm
parents: 64108
diff changeset
   306
    val End = new Regex("""^------------------- test (?:successful|FAILED) --- (.+) --- .*$""")
64095
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   307
    val Isabelle_Version = new Regex("""^Isabelle version: (\S+)$""")
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   308
    val No_AFP_Version = new Regex("""$.""")
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   309
  }
1a6d37c31df9 support for isatest format;
wenzelm
parents: 64094
diff changeset
   310
64109
wenzelm
parents: 64108
diff changeset
   311
  object AFP_Test
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   312
  {
65588
b0d8d97198b3 clarified signature;
wenzelm
parents: 65318
diff changeset
   313
    val log_prefix = "afp-test-devel-"
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   314
    val engine = "afp-test"
64109
wenzelm
parents: 64108
diff changeset
   315
    val Start = new Regex("""^Start test(?: for .+)? at ([^,]+), (.*)$""")
wenzelm
parents: 64108
diff changeset
   316
    val Start_Old = new Regex("""^Start test(?: for .+)? at ([^,]+)$""")
wenzelm
parents: 64108
diff changeset
   317
    val End = new Regex("""^End test on (.+), .+, elapsed time:.*$""")
64087
a77c57235bae more uniform regexps;
wenzelm
parents: 64086
diff changeset
   318
    val Isabelle_Version = new Regex("""^Isabelle version: .* -- hg id (\S+)$""")
a77c57235bae more uniform regexps;
wenzelm
parents: 64086
diff changeset
   319
    val AFP_Version = new Regex("""^AFP version: .* -- hg id (\S+)$""")
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   320
    val Bad_Init = new Regex("""^cp:.*: Disc quota exceeded$""")
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   321
  }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   322
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   323
  object Jenkins
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   324
  {
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   325
    val engine = "jenkins"
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   326
    val Start = new Regex("""^Started .*$""")
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   327
    val Start_Date = new Regex("""^Build started at (.+)$""")
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   328
    val No_End = new Regex("""$.""")
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   329
    val Isabelle_Version = new Regex("""^Isabelle id (\S+)$""")
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   330
    val AFP_Version = new Regex("""^AFP id (\S+)$""")
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   331
    val CONFIGURATION = "=== CONFIGURATION ==="
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   332
    val BUILD = "=== BUILD ==="
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   333
    val FINISHED = "Finished: "
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   334
  }
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   335
64105
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   336
  private def parse_meta_info(log_file: Log_File): Meta_Info =
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   337
  {
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   338
    def parse(engine: String, host: String, start: Date,
64109
wenzelm
parents: 64108
diff changeset
   339
      End: Regex, Isabelle_Version: Regex, AFP_Version: Regex): Meta_Info =
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   340
    {
64296
544481988e65 explicit identification of builds and correlated build groups;
wenzelm
parents: 64196
diff changeset
   341
      val build_id =
544481988e65 explicit identification of builds and correlated build groups;
wenzelm
parents: 64196
diff changeset
   342
      {
544481988e65 explicit identification of builds and correlated build groups;
wenzelm
parents: 64196
diff changeset
   343
        val prefix = if (host != "") host else if (engine != "") engine else ""
544481988e65 explicit identification of builds and correlated build groups;
wenzelm
parents: 64196
diff changeset
   344
        (if (prefix == "") "build" else prefix) + ":" + start.time.ms
544481988e65 explicit identification of builds and correlated build groups;
wenzelm
parents: 64196
diff changeset
   345
      }
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   346
      val build_engine = if (engine == "") Nil else List(Prop.build_engine.name -> engine)
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   347
      val build_host = if (host == "") Nil else List(Prop.build_host.name -> host)
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   348
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   349
      val start_date = List(Prop.build_start.name -> print_date(start))
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   350
      val end_date =
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   351
        log_file.lines.last match {
64109
wenzelm
parents: 64108
diff changeset
   352
          case End(log_file.Strict_Date(end_date)) =>
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   353
            List(Prop.build_end.name -> print_date(end_date))
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   354
          case _ => Nil
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   355
        }
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   356
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   357
      val isabelle_version =
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   358
        log_file.find_match(Isabelle_Version).map(Prop.isabelle_version.name -> _)
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   359
      val afp_version =
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   360
        log_file.find_match(AFP_Version).map(Prop.afp_version.name -> _)
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   361
65591
5953c7fbc2b8 more SQL operations;
wenzelm
parents: 65590
diff changeset
   362
      Meta_Info((Prop.build_id.name -> build_id) :: build_engine ::: build_host :::
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   363
          start_date ::: end_date ::: isabelle_version.toList ::: afp_version.toList,
64091
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   364
        log_file.get_settings(Settings.all_settings))
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   365
    }
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   366
f8dfba90e73f more liberal parsing for old AFP logs;
wenzelm
parents: 64090
diff changeset
   367
    log_file.lines match {
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   368
      case line :: _ if line.startsWith(Build_History.META_INFO_MARKER) =>
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   369
        Meta_Info(log_file.find_props(Build_History.META_INFO_MARKER).get,
64117
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   370
          log_file.get_settings(Settings.all_settings))
c2b41b073d8a build_history log files with formal meta info;
wenzelm
parents: 64116
diff changeset
   371
64109
wenzelm
parents: 64108
diff changeset
   372
      case Isatest.Start(log_file.Strict_Date(start), host) :: _ =>
wenzelm
parents: 64108
diff changeset
   373
        parse(Isatest.engine, host, start, Isatest.End,
64108
623abb8fecdf clarified meta info;
wenzelm
parents: 64107
diff changeset
   374
          Isatest.Isabelle_Version, Isatest.No_AFP_Version)
64099
wenzelm
parents: 64098
diff changeset
   375
64109
wenzelm
parents: 64108
diff changeset
   376
      case AFP_Test.Start(log_file.Strict_Date(start), host) :: _ =>
wenzelm
parents: 64108
diff changeset
   377
        parse(AFP_Test.engine, host, start, AFP_Test.End,
wenzelm
parents: 64108
diff changeset
   378
          AFP_Test.Isabelle_Version, AFP_Test.AFP_Version)
64099
wenzelm
parents: 64098
diff changeset
   379
64109
wenzelm
parents: 64108
diff changeset
   380
      case AFP_Test.Start_Old(log_file.Strict_Date(start)) :: _ =>
wenzelm
parents: 64108
diff changeset
   381
        parse(AFP_Test.engine, "", start, AFP_Test.End,
wenzelm
parents: 64108
diff changeset
   382
          AFP_Test.Isabelle_Version, AFP_Test.AFP_Version)
64099
wenzelm
parents: 64098
diff changeset
   383
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   384
      case Jenkins.Start() :: _
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   385
      if log_file.lines.contains(Jenkins.CONFIGURATION) ||
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   386
         log_file.lines.last.startsWith(Jenkins.FINISHED) =>
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   387
        log_file.lines.dropWhile(_ != Jenkins.BUILD) match {
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   388
          case Jenkins.BUILD :: _ :: Jenkins.Start_Date(log_file.Strict_Date(start)) :: _ =>
64111
b2290b9d0175 prefer local timezone;
wenzelm
parents: 64110
diff changeset
   389
            parse(Jenkins.engine, "", start.to(ZoneId.of("Europe/Berlin")), Jenkins.No_End,
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   390
              Jenkins.Isabelle_Version, Jenkins.AFP_Version)
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   391
          case _ => Meta_Info.empty
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   392
        }
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   393
64341
45b6faeee56d avoid deprecated Scala;
wenzelm
parents: 64303
diff changeset
   394
      case line :: _ if line.startsWith("\u0000") => Meta_Info.empty
64109
wenzelm
parents: 64108
diff changeset
   395
      case List(Isatest.End(_)) => Meta_Info.empty
wenzelm
parents: 64108
diff changeset
   396
      case _ :: AFP_Test.Bad_Init() :: _ => Meta_Info.empty
64105
d93bd6d253c6 tuned signature;
wenzelm
parents: 64104
diff changeset
   397
      case Nil => Meta_Info.empty
64104
b70fa05d6746 more permissive: accept all historic isatest and afp-test logs;
wenzelm
parents: 64103
diff changeset
   398
64110
c0b96b34c7b9 support for Isabelle/Jenkins log file format;
wenzelm
parents: 64109
diff changeset
   399
      case _ => log_file.err("cannot detect log file format")
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   400
    }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   401
  }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   402
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   403
64098
099518e8af2c misc tuning and clarification;
wenzelm
parents: 64096
diff changeset
   404
65276
fa1a5efee2ec tuned comments;
wenzelm
parents: 65052
diff changeset
   405
  /** build info: toplevel output of isabelle build or Admin/build_history **/
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   406
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   407
  val ML_STATISTICS_MARKER = "\fML_statistics = "
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   408
  val SESSION_NAME = "session_name"
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   409
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   410
  object Session_Status extends Enumeration
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   411
  {
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   412
    val EXISTING = Value("existing")
64061
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   413
    val FINISHED = Value("finished")
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   414
    val FAILED = Value("failed")
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   415
    val CANCELLED = Value("cancelled")
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   416
  }
1bbea2b55d22 some support for header and data fields, notably from afp-test;
wenzelm
parents: 64054
diff changeset
   417
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   418
  object Session_Entry
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   419
  {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   420
    val encode: XML.Encode.T[Session_Entry] = (entry: Session_Entry) =>
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   421
    {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   422
      import XML.Encode._
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   423
      pair(string, pair(list(string), pair(option(int), pair(Timing.encode, pair(Timing.encode,
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   424
        pair(list(properties), pair(option(long), string)))))))(
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   425
        entry.chapter, (entry.groups, (entry.threads, (entry.timing, (entry.ml_timing,
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   426
        (entry.ml_statistics, (entry.heap_size, entry.status.toString)))))))
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   427
    }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   428
    val decode: XML.Decode.T[Session_Entry] = (body: XML.Body) =>
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   429
    {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   430
      import XML.Decode._
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   431
      val (chapter, (groups, (threads, (timing, (ml_timing, (ml_statistics, (heap_size, status))))))) =
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   432
        pair(string, pair(list(string), pair(option(int), pair(Timing.decode, pair(Timing.decode,
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   433
          pair(list(properties), pair(option(long), string)))))))(body)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   434
      Session_Entry(chapter, groups, threads, timing, ml_timing, ml_statistics, heap_size,
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   435
        Session_Status.withName(status))
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   436
    }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   437
  }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   438
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   439
  sealed case class Session_Entry(
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   440
    chapter: String,
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   441
    groups: List[String],
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   442
    threads: Option[Int],
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   443
    timing: Timing,
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   444
    ml_timing: Timing,
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   445
    ml_statistics: List[Properties.T],
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   446
    heap_size: Option[Long],
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   447
    status: Session_Status.Value)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   448
  {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   449
    def finished: Boolean = status == Session_Status.FINISHED
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   450
  }
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   451
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   452
  object Build_Info
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   453
  {
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   454
    val build_info = SQL.Column.bytes("build_info")
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   455
    val table = SQL.Table("isabelle_build_log_build_info", List(Meta_Info.log_filename, build_info))
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   456
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   457
    def encode: XML.Encode.T[Build_Info] = (info: Build_Info) =>
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   458
    {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   459
      import XML.Encode._
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   460
      list(pair(string, Session_Entry.encode))(info.sessions.toList)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   461
    }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   462
    def decode: XML.Decode.T[Build_Info] = (body: XML.Body) =>
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   463
    {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   464
      import XML.Decode._
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   465
      Build_Info(list(pair(string, Session_Entry.decode))(body).toMap)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   466
    }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   467
  }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   468
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   469
  sealed case class Build_Info(sessions: Map[String, Session_Entry])
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   470
  {
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   471
    def session(name: String): Session_Entry = sessions(name)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   472
    def get_session(name: String): Option[Session_Entry] = sessions.get(name)
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   473
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   474
    def get_default[A](name: String, f: Session_Entry => A, x: A): A =
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   475
      get_session(name) match {
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   476
        case Some(entry) => f(entry)
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   477
        case None => x
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   478
      }
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   479
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   480
    def finished_sessions: List[String] = sessions.keySet.iterator.filter(finished(_)).toList
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   481
    def finished(name: String): Boolean = get_default(name, _.finished, false)
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   482
    def timing(name: String): Timing = get_default(name, _.timing, Timing.zero)
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   483
    def ml_timing(name: String): Timing = get_default(name, _.ml_timing, Timing.zero)
65052
7f825cc6debf more operations;
wenzelm
parents: 64341
diff changeset
   484
    def ml_statistics(name: String): ML_Statistics =
7f825cc6debf more operations;
wenzelm
parents: 64341
diff changeset
   485
      get_default(name, entry => ML_Statistics(name, entry.ml_statistics), ML_Statistics.empty)
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   486
  }
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   487
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   488
  private def parse_build_info(log_file: Log_File): Build_Info =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   489
  {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   490
    object Chapter_Name
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   491
    {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   492
      def unapply(s: String): Some[(String, String)] =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   493
        space_explode('/', s) match {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   494
          case List(chapter, name) => Some((chapter, name))
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   495
          case _ => Some(("", s))
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   496
        }
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   497
    }
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   498
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   499
    val Session_No_Groups = new Regex("""^Session (\S+)$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   500
    val Session_Groups = new Regex("""^Session (\S+) \((.*)\)$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   501
    val Session_Finished1 =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   502
      new Regex("""^Finished (\S+) \((\d+):(\d+):(\d+) elapsed time, (\d+):(\d+):(\d+) cpu time.*$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   503
    val Session_Finished2 =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   504
      new Regex("""^Finished (\S+) \((\d+):(\d+):(\d+) elapsed time.*$""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   505
    val Session_Timing =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   506
      new Regex("""^Timing (\S+) \((\d) threads, (\d+\.\d+)s elapsed time, (\d+\.\d+)s cpu time, (\d+\.\d+)s GC time.*$""")
64086
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   507
    val Session_Started = new Regex("""^(?:Running|Building) (\S+) \.\.\.$""")
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   508
    val Session_Failed = new Regex("""^(\S+) FAILED""")
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   509
    val Session_Cancelled = new Regex("""^(\S+) CANCELLED""")
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   510
    val Heap = new Regex("""^Heap (\S+) \((\d+) bytes\)$""")
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   511
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   512
    var chapter = Map.empty[String, String]
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   513
    var groups = Map.empty[String, List[String]]
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   514
    var threads = Map.empty[String, Int]
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   515
    var timing = Map.empty[String, Timing]
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   516
    var ml_timing = Map.empty[String, Timing]
64086
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   517
    var started = Set.empty[String]
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   518
    var failed = Set.empty[String]
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   519
    var cancelled = Set.empty[String]
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   520
    var ml_statistics = Map.empty[String, List[Properties.T]]
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   521
    var heap_sizes = Map.empty[String, Long]
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   522
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   523
    def all_sessions: Set[String] =
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   524
      chapter.keySet ++ groups.keySet ++ threads.keySet ++ timing.keySet ++ ml_timing.keySet ++
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   525
      failed ++ cancelled ++ started ++ ml_statistics.keySet ++ heap_sizes.keySet
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   526
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   527
64062
a7352cbde7d7 misc tuning and clarification;
wenzelm
parents: 64061
diff changeset
   528
    for (line <- log_file.lines) {
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   529
      line match {
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   530
        case Session_No_Groups(Chapter_Name(chapt, name)) =>
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   531
          chapter += (name -> chapt)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   532
          groups += (name -> Nil)
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   533
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   534
        case Session_Groups(Chapter_Name(chapt, name), grps) =>
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   535
          chapter += (name -> chapt)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   536
          groups += (name -> Word.explode(grps))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   537
64086
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   538
        case Session_Started(name) =>
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   539
          started += name
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   540
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   541
        case Session_Finished1(name,
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   542
            Value.Int(e1), Value.Int(e2), Value.Int(e3),
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   543
            Value.Int(c1), Value.Int(c2), Value.Int(c3)) =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   544
          val elapsed = Time.hms(e1, e2, e3)
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   545
          val cpu = Time.hms(c1, c2, c3)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   546
          timing += (name -> Timing(elapsed, cpu, Time.zero))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   547
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   548
        case Session_Finished2(name,
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   549
            Value.Int(e1), Value.Int(e2), Value.Int(e3)) =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   550
          val elapsed = Time.hms(e1, e2, e3)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   551
          timing += (name -> Timing(elapsed, Time.zero, Time.zero))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   552
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   553
        case Session_Timing(name,
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   554
            Value.Int(t), Value.Double(e), Value.Double(c), Value.Double(g)) =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   555
          val elapsed = Time.seconds(e)
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   556
          val cpu = Time.seconds(c)
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   557
          val gc = Time.seconds(g)
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   558
          ml_timing += (name -> Timing(elapsed, cpu, gc))
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   559
          threads += (name -> t)
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   560
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   561
        case Heap(name, Value.Long(size)) =>
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   562
          heap_sizes += (name -> size)
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   563
65590
3e7bf5e34e0b more robust (see also 6688b9cd443b);
wenzelm
parents: 65588
diff changeset
   564
        case _ if line.startsWith(ML_STATISTICS_MARKER) && YXML.detect(line) =>
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   565
          val (name, props) =
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   566
            Library.try_unprefix(ML_STATISTICS_MARKER, line).map(log_file.parse_props(_)) match {
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   567
              case Some((SESSION_NAME, session_name) :: props) => (session_name, props)
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   568
              case _ => log_file.err("malformed ML_statistics " + quote(line))
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   569
            }
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   570
          ml_statistics += (name -> (props :: ml_statistics.getOrElse(name, Nil)))
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   571
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   572
        case _ =>
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   573
      }
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   574
    }
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   575
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   576
    val sessions =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   577
      Map(
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   578
        (for (name <- all_sessions.toList) yield {
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   579
          val status =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   580
            if (failed(name)) Session_Status.FAILED
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   581
            else if (cancelled(name)) Session_Status.CANCELLED
64086
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   582
            else if (timing.isDefinedAt(name) || ml_timing.isDefinedAt(name))
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   583
              Session_Status.FINISHED
ac7ae5067783 clarified status: started sessions may bomb without explicit FAILED or CANCELLED (cf. in afp-test-devel-2016-01-03.log);
wenzelm
parents: 64085
diff changeset
   584
            else if (started(name)) Session_Status.FAILED
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   585
            else Session_Status.EXISTING
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   586
          val entry =
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   587
            Session_Entry(
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   588
              chapter.getOrElse(name, ""),
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   589
              groups.getOrElse(name, Nil),
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   590
              threads.get(name),
64089
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   591
              timing.getOrElse(name, Timing.zero),
10d719dbb3ee more permissive timing data;
wenzelm
parents: 64088
diff changeset
   592
              ml_timing.getOrElse(name, Timing.zero),
64119
8094eaa38d4b inline session ML statistics into main build log;
wenzelm
parents: 64117
diff changeset
   593
              ml_statistics.getOrElse(name, Nil).reverse,
64120
6c5039016321 record heap sizes;
wenzelm
parents: 64119
diff changeset
   594
              heap_sizes.get(name),
64085
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   595
              status)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   596
          (name -> entry)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   597
        }):_*)
1c451e5c145f clarified parse_build_info: isabelle build output;
wenzelm
parents: 64083
diff changeset
   598
    Build_Info(sessions)
64054
1fc9ab31720d clarified modules;
wenzelm
parents: 64053
diff changeset
   599
  }
64099
wenzelm
parents: 64098
diff changeset
   600
wenzelm
parents: 64098
diff changeset
   601
wenzelm
parents: 64098
diff changeset
   602
65276
fa1a5efee2ec tuned comments;
wenzelm
parents: 65052
diff changeset
   603
  /** session info: produced by isabelle build as session log.gz file **/
64099
wenzelm
parents: 64098
diff changeset
   604
wenzelm
parents: 64098
diff changeset
   605
  sealed case class Session_Info(
wenzelm
parents: 64098
diff changeset
   606
    session_timing: Properties.T,
wenzelm
parents: 64098
diff changeset
   607
    command_timings: List[Properties.T],
wenzelm
parents: 64098
diff changeset
   608
    ml_statistics: List[Properties.T],
wenzelm
parents: 64098
diff changeset
   609
    task_statistics: List[Properties.T])
wenzelm
parents: 64098
diff changeset
   610
wenzelm
parents: 64098
diff changeset
   611
  private def parse_session_info(
wenzelm
parents: 64098
diff changeset
   612
    log_file: Log_File,
wenzelm
parents: 64098
diff changeset
   613
    command_timings: Boolean,
wenzelm
parents: 64098
diff changeset
   614
    ml_statistics: Boolean,
wenzelm
parents: 64098
diff changeset
   615
    task_statistics: Boolean): Session_Info =
wenzelm
parents: 64098
diff changeset
   616
  {
65290
wenzelm
parents: 65276
diff changeset
   617
    Session_Info(
wenzelm
parents: 65276
diff changeset
   618
      session_timing = log_file.find_props("\fTiming = ") getOrElse Nil,
wenzelm
parents: 65276
diff changeset
   619
      command_timings = if (command_timings) log_file.filter_props("\fcommand_timing = ") else Nil,
wenzelm
parents: 65276
diff changeset
   620
      ml_statistics = if (ml_statistics) log_file.filter_props(ML_STATISTICS_MARKER) else Nil,
wenzelm
parents: 65276
diff changeset
   621
      task_statistics = if (task_statistics) log_file.filter_props("\ftask_statistics = ") else Nil)
64099
wenzelm
parents: 64098
diff changeset
   622
  }
65595
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   623
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   624
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   625
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   626
  /** persistent store **/
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   627
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   628
  def store(options: Options): Store = new Store(options)
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   629
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   630
  class Store private[Build_Log](options: Options) extends Properties.Store
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   631
  {
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   632
    def open_database(
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   633
      user: String = options.string("build_log_database_user"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   634
      password: String = options.string("build_log_database_password"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   635
      database: String = options.string("build_log_database_name"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   636
      host: String = options.string("build_log_database_host"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   637
      port: Int = options.int("build_log_database_port"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   638
      ssh_host: String = options.string("build_log_ssh_host"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   639
      ssh_user: String = options.string("build_log_ssh_user"),
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   640
      ssh_port: Int = options.int("build_log_ssh_port")): PostgreSQL.Database =
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   641
    {
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   642
      PostgreSQL.open_database(
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   643
        user = user, password = password, database = database, host = host, port = port,
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   644
        ssh =
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   645
          if (ssh_host == "") None
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   646
          else Some(SSH.init_context(options).open_session(ssh_host, ssh_user, port)))
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   647
    }
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   648
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   649
    def compress_build_info(build_info: Build_Info, options: XZ.Options = XZ.options()): Bytes =
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   650
      Bytes(YXML.string_of_body(Build_Info.encode(build_info))).compress(options)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   651
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   652
    def uncompress_build_info(bytes: Bytes): Build_Info =
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   653
      Build_Info.decode(xml_cache.body(YXML.parse_body(bytes.uncompress().text)))
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   654
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   655
    def filter_files(db: SQL.Database, table: SQL.Table, files: List[JFile]): List[JFile] =
65600
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   656
    {
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   657
      val key = Meta_Info.log_filename
65600
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   658
      val known_files =
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   659
        using(db.select_statement(table, List(key)))(stmt =>
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   660
          SQL.iterator(stmt.executeQuery)(rs => db.string(rs, key)).toSet)
65600
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   661
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   662
      val unique_files =
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   663
        (Map.empty[String, JFile] /: files.iterator)({ case (m, file) =>
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   664
          val name = file.getName
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   665
          if (known_files(name)) m else m + (name -> file)
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   666
        })
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   667
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   668
      unique_files.iterator.map(_._2).toList
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   669
    }
138ffa41dc54 clarified filter_files: sorted and unique;
wenzelm
parents: 65599
diff changeset
   670
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   671
    def write_meta_info(db: SQL.Database, files: List[JFile])
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   672
    {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   673
      db.transaction {
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   674
        db.create_table(Meta_Info.table)
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   675
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   676
        using(db.insert_statement(Meta_Info.table))(stmt =>
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   677
        {
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   678
          for (file <- filter_files(db, Meta_Info.table, files)) {
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   679
            val meta_info = Log_File(file).parse_meta_info()
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   680
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   681
            db.set_string(stmt, 1, file.getName)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   682
            for ((c, i) <- Prop.columns.zipWithIndex) {
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   683
              if (c.T == SQL.Type.Date)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   684
                db.set_date(stmt, i + 2, meta_info.get_date(c).orNull)
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   685
              else
65601
e76d8f3e5478 more standard multi-line storage in database: Prop.separator is only required for single-line meta_info within log file;
wenzelm
parents: 65600
diff changeset
   686
                db.set_string(stmt, i + 2, meta_info.get(c).map(Prop.multiple_lines(_)).orNull)
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   687
            }
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   688
            db.set_bytes(stmt, Meta_Info.table.columns.length, encode_properties(meta_info.settings))
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   689
65605
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   690
            stmt.execute()
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   691
          }
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   692
        })
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   693
      }
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   694
    }
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   695
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   696
    def write_build_info(db: SQL.Database, files: List[JFile])
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   697
    {
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   698
      db.transaction {
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   699
        db.create_table(Build_Info.table)
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   700
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   701
        using(db.insert_statement(Build_Info.table))(stmt =>
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   702
        {
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   703
          for (file <- filter_files(db, Build_Info.table, files)) {
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   704
            val build_info = Log_File(file).parse_build_info()
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   705
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   706
            db.set_string(stmt, 1, file.getName)
a6447eb6bc38 separate small meta_info vs. big build_info;
wenzelm
parents: 65603
diff changeset
   707
            db.set_bytes(stmt, 2, compress_build_info(build_info))
65599
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   708
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   709
            stmt.execute()
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   710
          }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   711
        })
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   712
      }
08dfa79866ec database storage of Meta_Info and Build_Info;
wenzelm
parents: 65595
diff changeset
   713
    }
65595
ffd8283b7be0 support for database connection;
wenzelm
parents: 65591
diff changeset
   714
  }
64045
c6160d0b0337 clarified modules;
wenzelm
parents:
diff changeset
   715
}