define build_options from command line;
authorwenzelm
Fri, 20 Jul 2012 16:47:43 +0200
changeset 48368 dc538eef2cf2
parent 48367 680d297ec71b
child 48369 10b534e64209
define build_options from command line;
src/Pure/System/build.scala
src/Pure/System/options.scala
--- a/src/Pure/System/build.scala	Fri Jul 20 16:47:17 2012 +0200
+++ b/src/Pure/System/build.scala	Fri Jul 20 16:47:43 2012 +0200
@@ -257,6 +257,8 @@
   {
     val full_queue = find_sessions(more_dirs)
 
+    val build_options = (Options.init() /: options)(_.define_simple(_))
+
     sessions.filter(name => !full_queue.defined(name)) match {
       case Nil =>
       case bad => error("Undefined session(s): " + commas_quote(bad))
--- a/src/Pure/System/options.scala	Fri Jul 20 16:47:17 2012 +0200
+++ b/src/Pure/System/options.scala	Fri Jul 20 16:47:43 2012 +0200
@@ -89,7 +89,7 @@
   private def check_name(name: String): Options.Opt =
     options.get(name) match {
       case Some(opt) => opt
-      case None => error("Undeclared option " + quote(name))
+      case None => error("Unknown option " + quote(name))
     }
 
   private def check_type(name: String, typ: Options.Type): Options.Opt =
@@ -117,8 +117,6 @@
   }
 
 
-
-
   /* external declare and define */
 
   def declare(name: String, typ_name: String, description: String = ""): Options =
@@ -151,6 +149,17 @@
     result
   }
 
+  def define_simple(str: String): Options =
+  {
+    str.indexOf('=') match {
+      case -1 =>
+        val opt = check_name(str)
+        if (opt.typ == Options.Bool) define(str, "true")
+        else error("Missing value for option " + quote(str) + " : " + opt.typ.print)
+      case i => define(str.substring(0, i), str.substring(i + 1))
+    }
+  }
+
 
   /* internal lookup and update */