mirror of https://github.com/sbt/sbt.git
Tweak remaining binary compatibility issues with design.
This commit is contained in:
parent
40bf599f4a
commit
045ac1d984
|
|
@ -184,24 +184,13 @@ class AggressiveCompile(cacheFile: File) {
|
|||
private[this] def explicitBootClasspath(options: Seq[String]): Seq[File] =
|
||||
options.dropWhile(_ != CompilerArguments.BootClasspathOption).drop(1).take(1).headOption.toList.flatMap(IO.parseClasspath)
|
||||
|
||||
val store = AggressiveCompile.staticCache(cacheFile, AnalysisStore.sync(AnalysisStore.cached(FileBasedStore(cacheFile))))
|
||||
val store = MixedAnalyzingCompiler.staticCachedStore(cacheFile)
|
||||
|
||||
}
|
||||
@deprecated("0.13.8", "Use MixedAnalyzingCompiler instead.")
|
||||
object AggressiveCompile {
|
||||
import collection.mutable
|
||||
import java.lang.ref.{ Reference, SoftReference }
|
||||
private[this] val cache = new collection.mutable.HashMap[File, Reference[AnalysisStore]]
|
||||
private def staticCache(file: File, backing: => AnalysisStore): AnalysisStore =
|
||||
synchronized {
|
||||
cache get file flatMap { ref => Option(ref.get) } getOrElse {
|
||||
val b = backing
|
||||
cache.put(file, new SoftReference(b))
|
||||
b
|
||||
}
|
||||
}
|
||||
|
||||
def staticCachedStore(cacheFile: File) = staticCache(cacheFile, AnalysisStore.sync(AnalysisStore.cached(FileBasedStore(cacheFile))))
|
||||
@deprecated("0.13.8", "Use MixedAnalyzingCompiler.staticCachedStore instead.")
|
||||
def staticCachedStore(cacheFile: File) = MixedAnalyzingCompiler.staticCachedStore(cacheFile)
|
||||
|
||||
@deprecated("0.13.8", "Deprecated in favor of new sbt.compiler.javac package.")
|
||||
def directOrFork(instance: ScalaInstance, cpOptions: ClasspathOptions, javaHome: Option[File]): JavaTool =
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ object IC extends IncrementalCompiler[Analysis, AnalyzingCompiler] {
|
|||
|
||||
private[this] def m2o[S](opt: Maybe[S]): Option[S] = if (opt.isEmpty) None else Some(opt.get)
|
||||
|
||||
@deprecated("0.13.8", "A constructor is no longer needed.")
|
||||
@deprecated("0.13.8", "A logger is no longer needed.")
|
||||
def newScalaCompiler(instance: ScalaInstance, interfaceJar: File, options: ClasspathOptions, log: Logger): AnalyzingCompiler =
|
||||
new AnalyzingCompiler(instance, CompilerInterfaceProvider.constant(interfaceJar), options)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@ import java.io.File
|
|||
object Compiler {
|
||||
val DefaultMaxErrors = 100
|
||||
|
||||
final case class Inputs(compilers: Compilers, config: Options, incSetup: IncSetup, previousAnalysis: PreviousAnalysis)
|
||||
/** Inputs necessary to run the incremental compiler. */
|
||||
final case class Inputs(compilers: Compilers, config: Options, incSetup: IncSetup)
|
||||
/** The inputs for the copiler *and* the previous analysis of source dependecnies. */
|
||||
final case class InputsWithPrevious(inputs: Inputs, previousAnalysis: PreviousAnalysis)
|
||||
final case class Options(classpath: Seq[File], sources: Seq[File], classesDirectory: File, options: Seq[String], javacOptions: Seq[String], maxErrors: Int, sourcePositionMapper: Position => Position, order: CompileOrder)
|
||||
final case class IncSetup(analysisMap: File => Option[Analysis], definesClass: DefinesClass, skip: Boolean, cacheFile: File, cache: GlobalsCache, incOptions: IncOptions)
|
||||
private[sbt] trait JavaToolWithNewInterface extends JavaTool {
|
||||
|
|
@ -35,12 +38,11 @@ object Compiler {
|
|||
|
||||
def inputs(classpath: Seq[File], sources: Seq[File], classesDirectory: File, options: Seq[String],
|
||||
javacOptions: Seq[String], maxErrors: Int, sourcePositionMappers: Seq[Position => Option[Position]],
|
||||
order: CompileOrder, previousAnalysis: PreviousAnalysis)(implicit compilers: Compilers, incSetup: IncSetup, log: Logger): Inputs =
|
||||
order: CompileOrder)(implicit compilers: Compilers, incSetup: IncSetup, log: Logger): Inputs =
|
||||
new Inputs(
|
||||
compilers,
|
||||
new Options(classpath, sources, classesDirectory, options, javacOptions, maxErrors, foldMappers(sourcePositionMappers), order),
|
||||
incSetup,
|
||||
previousAnalysis
|
||||
incSetup
|
||||
)
|
||||
|
||||
def compilers(cpOptions: ClasspathOptions)(implicit app: AppConfiguration, log: Logger): Compilers =
|
||||
|
|
@ -87,32 +89,41 @@ object Compiler {
|
|||
}
|
||||
|
||||
@deprecated("0.13.8", "Use the `compile` method instead.")
|
||||
def apply(in: Inputs, log: Logger): Analysis =
|
||||
{
|
||||
import in.compilers._
|
||||
import in.config._
|
||||
import in.incSetup._
|
||||
apply(in, log, new LoggerReporter(maxErrors, log, sourcePositionMapper))
|
||||
}
|
||||
def apply(in: Inputs, log: Logger): Analysis = {
|
||||
import in.config._
|
||||
apply(in, log, new LoggerReporter(maxErrors, log, sourcePositionMapper))
|
||||
}
|
||||
@deprecated("0.13.8", "Use the `compile` method instead.")
|
||||
def apply(in: Inputs, log: Logger, reporter: xsbti.Reporter): Analysis = compile(in, log, reporter).analysis
|
||||
def compile(in: Inputs, log: Logger): CompileResult =
|
||||
def apply(in: Inputs, log: Logger, reporter: xsbti.Reporter): Analysis = {
|
||||
import in.compilers._
|
||||
import in.config._
|
||||
import in.incSetup._
|
||||
// Here we load the previous analysis since the new paths don't.
|
||||
val (previousAnalysis, previousSetup) = {
|
||||
MixedAnalyzingCompiler.staticCachedStore(cacheFile).get().map {
|
||||
case (a, s) => (a, Some(s))
|
||||
} getOrElse {
|
||||
(Analysis.empty(nameHashing = incOptions.nameHashing), None)
|
||||
}
|
||||
}
|
||||
compile(InputsWithPrevious(in, PreviousAnalysis(previousAnalysis, previousSetup)), log, reporter).analysis
|
||||
}
|
||||
def compile(in: InputsWithPrevious, log: Logger): CompileResult =
|
||||
{
|
||||
import in.compilers._
|
||||
import in.config._
|
||||
import in.incSetup._
|
||||
import in.inputs.config._
|
||||
compile(in, log, new LoggerReporter(maxErrors, log, sourcePositionMapper))
|
||||
}
|
||||
def compile(in: Inputs, log: Logger, reporter: xsbti.Reporter): CompileResult =
|
||||
def compile(in: InputsWithPrevious, log: Logger, reporter: xsbti.Reporter): CompileResult =
|
||||
{
|
||||
import in.compilers._
|
||||
import in.config._
|
||||
import in.incSetup._
|
||||
import in.inputs.compilers._
|
||||
import in.inputs.config._
|
||||
import in.inputs.incSetup._
|
||||
// Here is some trickery to choose the more recent (reporter-using) java compiler rather
|
||||
// than the previously defined versions.
|
||||
// TODO - Remove this hackery in sbt 1.0.
|
||||
val javacChosen: xsbti.compile.JavaCompiler =
|
||||
in.compilers.newJavac.map(_.xsbtiCompiler).getOrElse(in.compilers.javac)
|
||||
in.inputs.compilers.newJavac.map(_.xsbtiCompiler).getOrElse(in.inputs.compilers.javac)
|
||||
// TODO - Why are we not using the IC interface???
|
||||
MixedAnalyzingCompiler.analyzingCompile(scalac, javacChosen, sources, classpath, CompileOutput(classesDirectory), cache, None, options, javacOptions,
|
||||
in.previousAnalysis.analysis, in.previousAnalysis.setup, analysisMap, definesClass, reporter, order, skip, incOptions)(log)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ package sbt
|
|||
|
||||
import Attributed.data
|
||||
import Scope.{ fillTaskAxis, GlobalScope, ThisScope }
|
||||
import sbt.Compiler.InputsWithPrevious
|
||||
import xsbt.api.Discovery
|
||||
import xsbti.compile.CompileOrder
|
||||
import Project.{ inConfig, inScope, inTask, richInitialize, richInitializeTask, richTaskSessionVar }
|
||||
|
|
@ -782,13 +783,13 @@ object Defaults extends BuildCommon {
|
|||
|
||||
def compileTask: Initialize[Task[inc.Analysis]] = Def.task { saveAnalysis.value }
|
||||
def compileIncrementalTask = Def.task {
|
||||
compileIncrementalTaskImpl(streams.value, (compileInputs in compile).value, (compilerReporter in compile).value)
|
||||
compileIncrementalTaskImpl(streams.value, (compileInputs in compile).value, (readAnalysis in compile).value, (compilerReporter in compile).value)
|
||||
}
|
||||
private[this] def compileIncrementalTaskImpl(s: TaskStreams, ci: Compiler.Inputs, reporter: Option[xsbti.Reporter]): Compiler.CompileResult =
|
||||
private[this] def compileIncrementalTaskImpl(s: TaskStreams, ci: Compiler.Inputs, previous: Compiler.PreviousAnalysis, reporter: Option[xsbti.Reporter]): Compiler.CompileResult =
|
||||
{
|
||||
lazy val x = s.text(ExportStream)
|
||||
def onArgs(cs: Compiler.Compilers) = cs.copy(scalac = cs.scalac.onArgs(exported(x, "scalac")), javac = cs.javac.onArgs(exported(x, "javac")))
|
||||
val i = ci.copy(compilers = onArgs(ci.compilers))
|
||||
val i = InputsWithPrevious(ci.copy(compilers = onArgs(ci.compilers)), previous)
|
||||
try reporter match {
|
||||
case Some(reporter) => Compiler.compile(i, s.log, reporter)
|
||||
case None => Compiler.compile(i, s.log)
|
||||
|
|
@ -809,13 +810,13 @@ object Defaults extends BuildCommon {
|
|||
Seq(compileInputs := {
|
||||
val cp = classDirectory.value +: data(dependencyClasspath.value)
|
||||
Compiler.inputs(cp, sources.value, classDirectory.value, scalacOptions.value, javacOptions.value,
|
||||
maxErrors.value, sourcePositionMappers.value, compileOrder.value, readAnalysis.value)(compilers.value, compileIncSetup.value, streams.value.log)
|
||||
maxErrors.value, sourcePositionMappers.value, compileOrder.value)(compilers.value, compileIncSetup.value, streams.value.log)
|
||||
},
|
||||
compilerReporter := None)
|
||||
def compileAnalysisSettings: Seq[Setting[_]] = Seq(
|
||||
readAnalysis := {
|
||||
val setup: Compiler.IncSetup = compileIncSetup.value
|
||||
val store = AggressiveCompile.staticCachedStore(setup.cacheFile)
|
||||
val store = MixedAnalyzingCompiler.staticCachedStore(setup.cacheFile)
|
||||
store.get() match {
|
||||
case Some((an, setup)) => Compiler.PreviousAnalysis(an, Some(setup))
|
||||
case None => Compiler.PreviousAnalysis(Analysis.empty(nameHashing = setup.incOptions.nameHashing), None)
|
||||
|
|
|
|||
Loading…
Reference in New Issue