src/Pure/System/build.scala
author wenzelm
Tue Jul 17 22:34:29 2012 +0200 (2012-07-17)
changeset 48280 7d86239986c2
parent 48276 4bd480886813
child 48334 8dff9933e72a
permissions -rw-r--r--
basic support for session ROOT files, with examples for FOL and ZF;
     1 /*  Title:      Pure/System/build.scala
     2     Author:     Makarius
     3 
     4 Build and manage Isabelle sessions.
     5 */
     6 
     7 package isabelle
     8 
     9 
    10 object Build
    11 {
    12   /* command line entry point */
    13 
    14   private object Bool
    15   {
    16     def unapply(s: String): Option[Boolean] =
    17       s match {
    18         case "true" => Some(true)
    19         case "false" => Some(false)
    20         case _ => None
    21       }
    22   }
    23 
    24   def main(args: Array[String])
    25   {
    26     def bad_args()
    27     {
    28       java.lang.System.err.println("Bad arguments: " + args.toString)
    29       sys.exit(2)
    30     }
    31 
    32     args.toList match {
    33       case Bool(all_sessions) :: Bool(build_images) :: Bool(list_only) :: rest =>
    34         rest.indexWhere(_ == "\n") match {
    35           case -1 => bad_args()
    36           case i =>
    37             val (options, rest1) = rest.splitAt(i)
    38             val sessions = rest1.tail
    39             val rc = build(all_sessions, build_images, list_only, options, sessions)
    40             sys.exit(rc)
    41         }
    42       case _ => bad_args()
    43     }
    44   }
    45 
    46 
    47   /* build */
    48 
    49   def build(all_sessions: Boolean, build_images: Boolean, list_only: Boolean,
    50     options: List[String], sessions: List[String]): Int =
    51   {
    52     val rc = 1
    53 
    54     println("options = " + options.toString)
    55     println("sessions = " + sessions.toString)
    56 
    57     rc
    58   }
    59 
    60 
    61   /* session information */
    62 
    63   case class Session_Info(
    64     val dir: Path,
    65     val text: String)
    66 
    67   val ROOT_NAME = "ROOT"
    68 
    69   def find_sessions(): List[Session_Info] =
    70   {
    71     for {
    72       dir <- Isabelle_System.components()
    73       root = Isabelle_System.platform_file(dir + Path.basic(ROOT_NAME))
    74       if root.isFile
    75     }
    76     yield Session_Info(dir, Standard_System.read_file(root))
    77   }
    78 }
    79