Add helper methods to IC for reading analysis cache files

This commit is contained in:
Peter Vlugter 2012-05-07 11:49:53 +12:00 committed by Mark Harrah
parent 80500b5ca5
commit fdf9be166f
1 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package sbt.compiler
import sbt.CompileSetup
import sbt.inc.Analysis
import xsbti.{Logger, Maybe}
import xsbti.compile._
@ -29,4 +30,17 @@ object IC extends IncrementalCompiler[Analysis, AnalyzingCompiler]
val raw = new RawCompiler(instance, sbt.ClasspathOptions.auto, log)
AnalyzingCompiler.compileSources(sourceJar :: Nil, targetJar, interfaceJar :: Nil, label, raw, log)
}
def readCache(file: File): Option[(Analysis, CompileSetup)] =
try { Some(readCacheUncaught(file)) } catch { case _: Exception => None }
def readAnalysis(file: File): Analysis =
try { readCacheUncaught(file)._1 } catch { case _: Exception => Analysis.Empty }
def readCacheUncaught(file: File): (Analysis, CompileSetup) =
{
import sbinary.DefaultProtocol.{immutableMapFormat, immutableSetFormat, StringFormat, tuple2Format}
import sbt.inc.AnalysisFormats._
sbt.IO.gzipFileIn(file)( in => sbinary.Operations.read[(Analysis, CompileSetup)](in) )
}
}