This commit is contained in:
Mark Harrah 2010-01-27 20:39:07 -05:00
parent 4a566eb581
commit 3e3519b3a7
3 changed files with 9 additions and 20 deletions

View File

@ -2,27 +2,14 @@ package xsbt.boot
import java.lang.ref.{Reference, SoftReference}
import java.util.HashMap
import java.lang.ref.{Reference, SoftReference}
final class Cache[K,V](create: K => V) extends NotNull
{
private[this] val delegate = new HashMap[K,Reference[V]]
def apply(k: K): V =
{
val existingRef = delegate.get(k)
if(existingRef == null)
newEntry(k)
else
{
val existing = existingRef.get
if(existing == null)
{
println("Cache value for '" + k + "' was garbage collected, recreating it...")
newEntry(k)
}
else
existing
}
}
def apply(k: K): V = getFromReference(k, delegate.get(k))
private[this] def getFromReference(k: K, existingRef: Reference[V]) = if(existingRef eq null) newEntry(k) else get(k, existingRef.get)
private[this] def get(k: K, existing: V) = if(existing == null) newEntry(k) else existing
private[this] def newEntry(k: K): V =
{
val v = create(k)

View File

@ -50,9 +50,9 @@ trait ProguardProject extends BasicScalaProject
keepClasses.map("-keep public class " + _ + " {\n public * ;\n}") ++
mapInJars(inJars) ++
Seq("-injars " + mkpath(rawJarPath.asFile),
mapOutJar(outJar)) ++
mapOutJar(outJar)) ++
mapLibraryJars(libraryJars) ++
mainClass.map(main => keepMain.stripMargin.format(main)).toList
mainClass.map(main => keepMain.stripMargin.format(main)).toList
lines.mkString("\n")
}

View File

@ -111,9 +111,11 @@ class AggressiveCompile(val cacheDirectory: File, val compilerTask: Task[Analyzi
val apiChanged = sources filter { src => !sameAPI(previousAPIMap, newAPIMap, src) }
log.info("Sources with API changes:\n\t" + apiChanged.mkString("\n\t"))
val finalAPIMap =
if(apiChanged.isEmpty || apiChanged.size == sourceChanges.checked.size) newAPIMap
// if either nothing changed or everything was recompiled, stop here
if(apiChanged.isEmpty || sources.size == sourceChanges.checked.size) newAPIMap
else
{
//val changedNames = TopLevel.nameChanges(newAPIMap.values, previousAPIMap.values)
InvalidateTransitive.clean(tracker, FileUtilities.delete, transitiveIfNeeded)
val sources = transitiveIfNeeded.invalid ** sourceChanges.checked
log.info("All sources invalidated by API changes:\n\t" + sources.mkString("\n\t"))