aboutsummaryrefslogtreecommitdiff
path: root/stage2/plugins
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-02-09 21:20:11 -0500
committerChristopher Vogt <oss.nsp@cvogt.org>2017-02-09 22:43:00 -0500
commite8673866b79f7473391dcee26243eee80d5d3cb6 (patch)
tree16146affeebdb58cd302a1f8527220c906818c96 /stage2/plugins
parentbee13ba7a4458482ce00a5c6bae4cd64328c4e5e (diff)
downloadcbt-e8673866b79f7473391dcee26243eee80d5d3cb6.tar.gz
cbt-e8673866b79f7473391dcee26243eee80d5d3cb6.tar.bz2
cbt-e8673866b79f7473391dcee26243eee80d5d3cb6.zip
idempotent change propagation
using lastModified instead of a non-idempotent needsUpdate flag this fixes a bug where dependees would not be rebuilt if cbt exited or was killed after dependencies were already rebuilt.
Diffstat (limited to 'stage2/plugins')
-rw-r--r--stage2/plugins/Dotty.scala44
1 files changed, 23 insertions, 21 deletions
diff --git a/stage2/plugins/Dotty.scala b/stage2/plugins/Dotty.scala
index fe949a3..6fe5dd3 100644
--- a/stage2/plugins/Dotty.scala
+++ b/stage2/plugins/Dotty.scala
@@ -8,17 +8,15 @@ trait Dotty extends BaseBuild{
def dottyVersion: String = "0.1-20160926-ec28ea1-NIGHTLY"
def dottyOptions: Seq[String] = Seq()
override def scalaTarget: File = target ++ s"/dotty-$dottyVersion"
-
+
private lazy val dottyLib = new DottyLib(
- logger, context.cbtHasChanged, context.paths.mavenCache,
+ logger, context.cbtLastModified, context.paths.mavenCache,
context.classLoaderCache, dottyVersion = dottyVersion
)
- override def compile: Option[File] = taskCache[Dotty]("compile").memoize{
+ override def compile: Option[Long] = taskCache[Dotty]("compile").memoize{
dottyLib.compile(
- needsUpdate || context.parentBuild.map(_.needsUpdate).getOrElse(false),
- sourceFiles, compileTarget, compileStatusFile, compileClasspath,
- dottyOptions
+ sourceFiles, compileTarget, compileStatusFile, compileDependencies, dottyOptions
)
}
@@ -36,7 +34,7 @@ trait Dotty extends BaseBuild{
class DottyLib(
logger: Logger,
- cbtHasChanged: Boolean,
+ cbtLastModified: Long,
mavenCache: File,
classLoaderCache: ClassLoaderCache,
dottyVersion: String
@@ -44,7 +42,7 @@ class DottyLib(
val lib = new Lib(logger)
import lib._
- private def Resolver(urls: URL*) = MavenResolver(cbtHasChanged, mavenCache, urls: _*)
+ private def Resolver(urls: URL*) = MavenResolver(cbtLastModified, mavenCache, urls: _*)
private lazy val dottyDependency = Resolver(mavenCentral).bindOne(
MavenDependency("ch.epfl.lamp","dotty_2.11",dottyVersion)
)
@@ -94,22 +92,24 @@ class DottyLib(
}
def compile(
- needsRecompile: Boolean,
- files: Seq[File],
+ sourceFiles: Seq[File],
compileTarget: File,
statusFile: File,
- classpath: ClassPath,
+ dependencies: Seq[Dependency],
dottyOptions: Seq[String]
- ): Option[File] = {
-
+ ): Option[Long] = {
+ val d = Dependencies(dependencies)
+ val classpath = d.classpath
+ val cp = classpath.string
if(classpath.files.isEmpty)
- throw new Exception("Trying to compile with empty classpath. Source files: " ++ files.toString)
+ throw new Exception("Trying to compile with empty classpath. Source files: " ++ sourceFiles.toString)
- if( files.isEmpty ){
+ if( sourceFiles.isEmpty ){
None
}else{
- if( needsRecompile ){
- val start = System.currentTimeMillis
+ val start = System.currentTimeMillis
+ val lastCompiled = statusFile.lastModified
+ if( d.lastModified > lastCompiled || sourceFiles.exists(_.lastModified > lastCompiled) ){
val _class = "dotty.tools.dotc.Main"
val dualArgs =
@@ -118,7 +118,7 @@ class DottyLib(
)
val singleArgs = dottyOptions.map( "-S" ++ _ )
- val code =
+ val code =
try{
System.err.println("Compiling with Dotty to " ++ compileTarget.toString)
compileTarget.mkdirs
@@ -128,7 +128,7 @@ class DottyLib(
dualArgs ++ singleArgs ++ Seq(
"-bootclasspath", dottyDependency.classpath.string, // let's put cp last. It so long
"-classpath", classpath.string // let's put cp last. It so long
- ) ++ files.map(_.toString),
+ ) ++ sourceFiles.map(_.toString),
dottyDependency.classLoader(classLoaderCache)
)
}
@@ -150,7 +150,7 @@ ${dottyDependency.classpath.strings.mkString(":\\\n")} \\
-classpath \\
${classpath.strings.mkString(":\\\n")} \\
\\
-${files.sorted.mkString(" \\\n")}
+${sourceFiles.sorted.mkString(" \\\n")}
"""
)
ExitCode.Failure
@@ -164,8 +164,10 @@ ${files.sorted.mkString(" \\\n")}
} else {
System.exit(code.integer) // FIXME: let's find a better solution for error handling. Maybe a monad after all.
}
+ Some( start )
+ } else {
+ Some( lastCompiled )
}
- Some( compileTarget )
}
}
}