aboutsummaryrefslogtreecommitdiff
path: root/stage2/Lib.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-02-22 17:02:13 +0800
committerChristopher Vogt <oss.nsp@cvogt.org>2017-02-22 17:03:43 +0800
commit0972023722e8f6a59002d2d78defb7c5dec0240f (patch)
tree6afcb970230a9de6d07cfd6a424df555fbeee329 /stage2/Lib.scala
parent420b0bc9fdb542d0af49da96e37733ab3a3363ee (diff)
downloadcbt-0972023722e8f6a59002d2d78defb7c5dec0240f.tar.gz
cbt-0972023722e8f6a59002d2d78defb7c5dec0240f.tar.bz2
cbt-0972023722e8f6a59002d2d78defb7c5dec0240f.zip
treat subdirectores as subbuilds via cmd line
Diffstat (limited to 'stage2/Lib.scala')
-rw-r--r--stage2/Lib.scala25
1 files changed, 19 insertions, 6 deletions
diff --git a/stage2/Lib.scala b/stage2/Lib.scala
index d6047f9..700f18d 100644
--- a/stage2/Lib.scala
+++ b/stage2/Lib.scala
@@ -154,8 +154,8 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){
) ++ "\n"
}
- def callReflective[T <: AnyRef]( obj: T, code: Option[String] ): ExitCode = {
- callInternal( obj, code.toSeq.flatMap(_.split("\\.").map( NameTransformer.encode )), Nil ) match {
+ def callReflective[T <: AnyRef]( obj: T, code: Option[String], context: Context ): ExitCode = {
+ callInternal( obj, code.toSeq.flatMap(_.split("\\.").map( NameTransformer.encode )), Nil, context ) match {
case (obj, code, None) =>
val s = render(obj)
if(s.nonEmpty)
@@ -182,7 +182,7 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){
}
}
- private def callInternal[T <: AnyRef]( obj: T, members: Seq[String], previous: Seq[String] ): (Option[Object], Option[ExitCode], Option[String]) = {
+ private def callInternal[T <: AnyRef]( obj: T, members: Seq[String], previous: Seq[String], context: Context ): (Option[Object], Option[ExitCode], Option[String]) = {
members.headOption.map{ taskName =>
logger.lib("Calling task " ++ taskName.toString)
taskMethods(obj.getClass).get(taskName).map{ method =>
@@ -192,12 +192,25 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){
// FIXME: ExitCode needs to be part of the compatibility interfaces
(None, Some(ExitCode(Stage0Lib.get(code,"integer").asInstanceOf[Int])), None)
case Seq(bs @ _*) if bs.forall(_.isInstanceOf[BaseBuild]) =>
- bs.map( b => callInternal(b.asInstanceOf[BaseBuild], members.tail, previous :+ taskName) ).head
- case _ => callInternal(result, members.tail, previous :+ taskName)
+ bs.map( b => callInternal(b.asInstanceOf[BaseBuild], members.tail, previous :+ taskName, context) ).head
+ case _ => callInternal(result, members.tail, previous :+ taskName, context)
}
}.getOrElse( (None, None, None) )
}.getOrElse{
- ( Some(obj), None, Some("\nMethod not found: " ++ (previous :+ taskName).mkString(".") ++ "\n") )
+ val folder = NameTransformer.decode(taskName)
+ if( context != null && (context.workingDirectory / folder).exists ){
+ val newContext = context.copy( workingDirectory = context.workingDirectory / folder )
+ callInternal(
+ lib.loadRoot(
+ newContext
+ ).finalBuild,
+ members.tail,
+ previous,
+ newContext
+ )
+ } else {
+ ( Some(obj), None, Some("\nMethod not found: " ++ (previous :+ taskName).mkString(".") ++ "\n") )
+ }
}
}.getOrElse{
( Some(obj), None, None )