restrict to required sessions;
authorwenzelm
Fri Jul 20 12:27:25 2012 +0200 (2012-07-20)
changeset 48363cf081b7042d2
parent 48362 c3192ccb0ff4
child 48364 9091b659d7b6
restrict to required sessions;
src/Pure/System/build.scala
     1.1 --- a/src/Pure/System/build.scala	Fri Jul 20 12:00:08 2012 +0200
     1.2 +++ b/src/Pure/System/build.scala	Fri Jul 20 12:27:25 2012 +0200
     1.3 @@ -75,6 +75,14 @@
     1.4          new Queue(keys1, graph1)
     1.5        }
     1.6  
     1.7 +      def required(names: List[String]): Queue =
     1.8 +      {
     1.9 +        val req = graph.all_preds(names.map(keys(_))).map(_.name).toSet
    1.10 +        val keys1 = keys -- keys.keySet.filter(name => !req(name))
    1.11 +        val graph1 = graph.restrict(key => keys1.isDefinedAt(key.name))
    1.12 +        new Queue(keys1, graph1)
    1.13 +      }
    1.14 +
    1.15        def topological_order: List[(Key, Info)] =
    1.16          graph.topological_order.map(key => (key, graph.get_node(key)))
    1.17      }
    1.18 @@ -235,11 +243,18 @@
    1.19    def build(all_sessions: Boolean, build_images: Boolean, list_only: Boolean,
    1.20      more_dirs: List[Path], options: List[String], sessions: List[String]): Int =
    1.21    {
    1.22 -    println("more_dirs = " + more_dirs.toString)
    1.23 -    println("options = " + options.toString)
    1.24 -    println("sessions = " + sessions.toString)
    1.25 +    val full_queue = find_sessions(more_dirs)
    1.26  
    1.27 -    for ((key, info) <- find_sessions(more_dirs).topological_order)
    1.28 +    sessions.filter(name => !full_queue.defined(name)) match {
    1.29 +      case Nil =>
    1.30 +      case bad => error("Undefined session(s): " + commas_quote(bad))
    1.31 +    }
    1.32 +
    1.33 +    val required_queue =
    1.34 +      if (all_sessions) full_queue
    1.35 +      else full_queue.required(sessions)
    1.36 +
    1.37 +    for ((key, info) <- required_queue.topological_order)
    1.38        println(key.name + " in " + info.dir)
    1.39  
    1.40      0