diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-02-18 01:09:36 +0000 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-02-18 01:09:36 +0000 |
commit | 3c135b40c2d2aac017ac12edc6924e3c369296fd (patch) | |
tree | 4d8812320f75339d398679da0221fb31e77e523c /stage2 | |
parent | 632f3d0340f66977fd59bb8d0a601a430dd3d0f5 (diff) | |
download | cbt-3c135b40c2d2aac017ac12edc6924e3c369296fd.tar.gz cbt-3c135b40c2d2aac017ac12edc6924e3c369296fd.tar.bz2 cbt-3c135b40c2d2aac017ac12edc6924e3c369296fd.zip |
allow DirectoryDependencies on BuildBuilds
this fixes a bug where finalBuild would over eagerly go down all the way
down to the outermost build instead of stopping at the one requested.
Now it checks the new argument and stops there.
This is necessary to allow having one build depend on another build in
order to embed it in a type-safe way and have access to it’s tasks.
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/BasicBuild.scala | 5 | ||||
-rw-r--r-- | stage2/BuildBuild.scala | 9 | ||||
-rw-r--r-- | stage2/Stage2.scala | 6 |
3 files changed, 16 insertions, 4 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index 4ca39a7..c1a8c4e 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -253,7 +253,12 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge */ // ========== cbt internals ========== + @deprecated("use finalbuild(File)","") def finalBuild: BuildInterface = this + override def finalBuild( current: File ): BuildInterface = { + //assert( current.getCanonicalFile == projectDirectory.getCanonicalFile, s"$current == $projectDirectory" ) + this + } override def show = this.getClass.getSimpleName ++ "(" ++ projectDirectory.string ++ ")" // a method that can be called only to trigger any side-effects diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala index 2eebcbc..9ac631f 100644 --- a/stage2/BuildBuild.scala +++ b/stage2/BuildBuild.scala @@ -1,5 +1,6 @@ package cbt import java.nio.file._ +import java.io.File trait BuildBuild extends BuildBuildWithoutEssentials{ override def dependencies = @@ -97,5 +98,11 @@ trait BuildBuildWithoutEssentials extends BaseBuild{ } } override def triggerLoopFiles = super.triggerLoopFiles ++ managedBuild.triggerLoopFiles - override def finalBuild: BuildInterface = if( projectDirectory == context.cwd ) this else managedBuild.finalBuild + @deprecated("use finalbuild(File)","") + override def finalBuild: BuildInterface = finalBuild( context.cwd ) + override def finalBuild( current: File ): BuildInterface = { + val p = projectDirectory.getCanonicalFile + val c = current.getCanonicalFile + if( c == p ) this else managedBuild.finalBuild( current ) + } } diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala index 93f0a77..7ac7a2a 100644 --- a/stage2/Stage2.scala +++ b/stage2/Stage2.scala @@ -4,7 +4,7 @@ import java.util._ object Stage2 extends Stage2Base{ def getBuild(context: Context) = { - new Lib( context.logger ).loadRoot( context ).finalBuild + new Lib( context.logger ).loadRoot( context ).finalBuild( context.cwd ) } def run( args: Stage2Args ): ExitCode = { @@ -39,7 +39,7 @@ object Stage2 extends Stage2Base{ null ) val first = lib.loadRoot( context ) - val build = first.finalBuild + val build = first.finalBuild( context.cwd ) val res = if (loop) { @@ -57,7 +57,7 @@ object Stage2 extends Stage2Base{ scala.util.control.Breaks.break case file if triggerFiles.exists(file.toString startsWith _.toString) => - val build = lib.loadRoot(context).finalBuild + val build = lib.loadRoot(context).finalBuild( context.cwd ) logger.loop(s"Re-running $task for " ++ build.show) lib.callReflective(build, task) } |