src/Pure/System/build.scala
author wenzelm
Wed, 18 Jul 2012 19:47:10 +0200
changeset 48340 6f4fc030882a
parent 48339 62570361e608
child 48341 752de4e10162
permissions -rw-r--r--
allow explicit specification of additional session directories;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/System/build.scala
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     3
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     4
Build and manage Isabelle sessions.
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     5
*/
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     6
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     7
package isabelle
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     8
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
     9
48335
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    10
import java.io.File
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    11
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    12
import scala.collection.mutable
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    13
import scala.annotation.tailrec
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    14
48335
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    15
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    16
object Build
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    17
{
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    18
  /* command line entry point */
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    19
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    20
  private object Bool
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    21
  {
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    22
    def unapply(s: String): Option[Boolean] =
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    23
      s match {
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    24
        case "true" => Some(true)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    25
        case "false" => Some(false)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    26
        case _ => None
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    27
      }
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    28
  }
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    29
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    30
  private object Chunks
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    31
  {
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    32
    private def chunks(list: List[String]): List[List[String]] =
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    33
      list.indexWhere(_ == "\n") match {
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    34
        case -1 => List(list)
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    35
        case i =>
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    36
          val (chunk, rest) = list.splitAt(i)
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    37
          chunk :: chunks(rest.tail)
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    38
      }
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    39
    def unapplySeq(list: List[String]): Option[List[List[String]]] = Some(chunks(list))
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    40
  }
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    41
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    42
  def main(args: Array[String])
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    43
  {
48335
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    44
    val rc =
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    45
      try {
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    46
        args.toList match {
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    47
          case Bool(all_sessions) :: Bool(build_images) :: Bool(list_only) ::
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    48
            Chunks(more_dirs, options, sessions) =>
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    49
              build(all_sessions, build_images, list_only,
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    50
                more_dirs.map(Path.explode), options, sessions)
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    51
          case _ => error("Bad arguments:\n" + cat_lines(args))
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    52
        }
48335
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    53
      }
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    54
      catch {
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    55
        case exn: Throwable => java.lang.System.err.println(Exn.message(exn)); 2
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    56
      }
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    57
    sys.exit(rc)
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    58
  }
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    59
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    60
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    61
  /* build */
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    62
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    63
  def build(all_sessions: Boolean, build_images: Boolean, list_only: Boolean,
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    64
    more_dirs: List[Path], options: List[String], sessions: List[String]): Int =
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    65
  {
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    66
    println("more_dirs = " + more_dirs.toString)
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    67
    println("options = " + options.toString)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    68
    println("sessions = " + sessions.toString)
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    69
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
    70
    find_sessions(more_dirs) foreach println
48335
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    71
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
    72
    0
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
    73
  }
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
    74
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
    75
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    76
  /** session information **/
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    77
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    78
  type Options = List[(String, Option[String])]
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    79
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
    80
  case class Session_Info(
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    81
    dir: Path,
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    82
    name: String,
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    83
    parent: String,
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    84
    description: String,
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    85
    options: Options,
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    86
    theories: List[(Options, String)],
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    87
    files: List[String])
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
    88
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    89
  private val pure_info =
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    90
    Session_Info(Path.current, "Pure", "", "", Nil, List((Nil, "Pure")), Nil)
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    91
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    92
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    93
  /* parsing */
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    94
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    95
  val ROOT_NAME = "ROOT"
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    96
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    97
  private case class Session_Entry(
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    98
    name: String,
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
    99
    reset: Boolean,
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   100
    path: Option[String],
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   101
    parent: String,
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   102
    description: String,
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   103
    options: Options,
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   104
    theories: List[(Options, List[String])],
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   105
    files: List[String])
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   106
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   107
  private object Parser extends Parse.Parser
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   108
  {
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   109
    val SESSION = "session"
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   110
    val IN = "in"
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   111
    val DESCRIPTION = "description"
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   112
    val OPTIONS = "options"
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   113
    val THEORIES = "theories"
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   114
    val FILES = "files"
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   115
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   116
    val syntax =
48336
3c55bfad22eb more tight treatment of reset_name;
wenzelm
parents: 48335
diff changeset
   117
      Outer_Syntax.empty + "!" + "(" + ")" + "+" + "," + "=" + "[" + "]" +
3c55bfad22eb more tight treatment of reset_name;
wenzelm
parents: 48335
diff changeset
   118
        SESSION + IN + DESCRIPTION + OPTIONS + THEORIES + FILES
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   119
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   120
    val session_entry: Parser[Session_Entry] =
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   121
    {
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   122
      val session_name = atom("session name", _.is_name)
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   123
      val theory_name = atom("theory name", _.is_name)
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   124
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   125
      val option =
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   126
        name ~ opt(keyword("=") ~! name ^^ { case _ ~ x => x }) ^^ { case x ~ y => (x, y) }
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   127
      val options = keyword("[") ~> repsep(option, keyword(",")) <~ keyword("]")
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   128
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   129
      val theories =
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   130
        keyword(THEORIES) ~! ((options | success(Nil)) ~ rep1(theory_name)) ^^
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   131
          { case _ ~ (x ~ y) => (x, y) }
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   132
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   133
      ((keyword(SESSION) ~! session_name) ^^ { case _ ~ x => x }) ~
48336
3c55bfad22eb more tight treatment of reset_name;
wenzelm
parents: 48335
diff changeset
   134
        (keyword("!") ^^^ true | success(false)) ~
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   135
        (opt(keyword(IN) ~! string ^^ { case _ ~ x => x })) ~
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   136
        (keyword("=") ~> session_name <~ keyword("+")) ~
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   137
        (keyword(DESCRIPTION) ~! text ^^ { case _ ~ x => x } | success("")) ~
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   138
        (keyword(OPTIONS) ~! options ^^ { case _ ~ x => x } | success(Nil)) ~
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   139
        rep1(theories) ~
48336
3c55bfad22eb more tight treatment of reset_name;
wenzelm
parents: 48335
diff changeset
   140
        (keyword(FILES) ~! rep1(path) ^^ { case _ ~ x => x } | success(Nil)) ^^
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   141
          { case a ~ b ~ c ~ d ~ e ~ f ~ g ~ h => Session_Entry(a, b, c, d, e, f, g, h) }
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   142
    }
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   143
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   144
    def parse_entries(root: File): List[Session_Entry] =
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   145
    {
48335
2f923e994056 more informative errors;
wenzelm
parents: 48334
diff changeset
   146
      val toks = syntax.scan(Standard_System.read_file(root))
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   147
      parse_all(rep(session_entry), Token.reader(toks, root.toString)) match {
48334
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   148
        case Success(result, _) => result
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   149
        case bad => error(bad.toString)
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   150
      }
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   151
    }
8dff9933e72a added parser for Session_Info;
wenzelm
parents: 48280
diff changeset
   152
  }
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   153
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   154
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   155
  /* find session */
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   156
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
   157
  def find_sessions(more_dirs: List[Path]): List[Session_Info] =
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   158
  {
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   159
    val infos = new mutable.ListBuffer[Session_Info]
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   160
    infos += pure_info
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   161
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   162
    for {
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
   163
      (dir, strict) <- Isabelle_System.components().map((_, false)) ++ more_dirs.map((_, true))
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   164
      root = Isabelle_System.platform_file(dir + Path.basic(ROOT_NAME))
48340
6f4fc030882a allow explicit specification of additional session directories;
wenzelm
parents: 48339
diff changeset
   165
      _ = (strict && !root.isFile && error("Bad session root file: " + quote(root.toString)))
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   166
      if root.isFile
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   167
      entry <- Parser.parse_entries(root)
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   168
    }
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   169
    {
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   170
      try {
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   171
        val parent =
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   172
          infos.find(_.name == entry.parent) getOrElse
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   173
           error("Unknown parent session: " + quote(entry.parent))
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   174
        val full_name =
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   175
          if (entry.reset) entry.name
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   176
          else parent.name + "-" + entry.name
48339
62570361e608 more errors;
wenzelm
parents: 48337
diff changeset
   177
62570361e608 more errors;
wenzelm
parents: 48337
diff changeset
   178
        if (entry.name == "") error("Bad session name")
62570361e608 more errors;
wenzelm
parents: 48337
diff changeset
   179
        if (infos.exists(_.name == full_name))
62570361e608 more errors;
wenzelm
parents: 48337
diff changeset
   180
          error("Duplicate session name: " + quote(full_name))
62570361e608 more errors;
wenzelm
parents: 48337
diff changeset
   181
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   182
        val path =
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   183
          entry.path match {
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   184
            case Some(p) => Path.explode(p)
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   185
            case None => Path.basic(entry.name)
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   186
          }
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   187
        val thys = entry.theories.map({ case (x, ys) => ys.map(y => (x, y)) }).flatten
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   188
        val info =
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   189
          Session_Info(dir + path, full_name, entry.parent, entry.description,
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   190
            entry.options, thys, entry.files)
48339
62570361e608 more errors;
wenzelm
parents: 48337
diff changeset
   191
48337
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   192
        infos += info
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   193
      }
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   194
      catch {
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   195
        case ERROR(msg) =>
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   196
          error(msg + "\nThe error(s) above occurred in session entry " +
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   197
            quote(entry.name) + " (file " + quote(root.toString) + ")")
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   198
      }
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   199
    }
9c7f8e5805b4 cumulate semantic Session_Info, based on syntactic Session_Entry;
wenzelm
parents: 48336
diff changeset
   200
    infos.toList
48280
7d86239986c2 basic support for session ROOT files, with examples for FOL and ZF;
wenzelm
parents: 48276
diff changeset
   201
  }
48276
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
   202
}
4bd480886813 basic setup for Isabelle build tool;
wenzelm
parents:
diff changeset
   203