Skip to content

Commit

Permalink
Merge pull request #1721 from tgodzik/fix-duplicate
Browse files Browse the repository at this point in the history
Fix duplicate compiler classpath and bootclasspath options
  • Loading branch information
tgodzik authored Apr 14, 2022
2 parents d6f1620 + 9bb53cd commit bfcb709
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ object BloopZincCompiler {
val analysis = invalidateAnalysisFromSetup(config.currentSetup, previousSetup, incrementalOptions.ignoredScalacOptions(), setOfSources, prev, manager, logger)

// Scala needs the explicit type signature to infer the function type arguments
val compile: (Set[VirtualFile], DependencyChanges, AnalysisCallback, ClassFileManager) => Task[Unit] = compiler.compile(_, _, _, _, cancelPromise, classpathOptions)
val compile: (Set[VirtualFile], DependencyChanges, AnalysisCallback, ClassFileManager) => Task[Unit] = compiler.compile(_, _, _, _, cancelPromise)
BloopIncremental
.compile(
setOfSources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package sbt.internal.inc.bloop.internal

import java.nio.file.Files
import java.nio.file.Path
import java.util.Optional

import scala.concurrent.Promise
Expand All @@ -15,7 +14,6 @@ import bloop.tracing.BraveTracer
import monix.eval.Task
import sbt.internal.inc.AnalyzingCompiler
import sbt.internal.inc.CompileConfiguration
import sbt.internal.inc.CompilerArguments
import sbt.internal.inc.JavaInterfaceUtil.EnrichOption
import sbt.internal.inc.MixedAnalyzingCompiler
import sbt.internal.inc.PlainVirtualFileConverter
Expand Down Expand Up @@ -48,7 +46,6 @@ final class BloopHighLevelCompiler(
) {
private[this] final val setup = config.currentSetup
private[this] final val classpath: Seq[VirtualFile] = config.classpath
private[this] final val classpathNio: Seq[Path] = classpath.map(PlainVirtualFileConverter.converter.toPath)

private[this] val JavaCompleted: Promise[Unit] = Promise.successful(())

Expand All @@ -67,8 +64,7 @@ final class BloopHighLevelCompiler(
changes: DependencyChanges,
callback: AnalysisCallback,
classfileManager: ClassFileManager,
cancelPromise: Promise[Unit],
classpathOptions: ClasspathOptions
cancelPromise: Promise[Unit]
): Task[Unit] = {
def timed[T](label: String)(t: => T): T = {
tracer.trace(label) { _ =>
Expand Down Expand Up @@ -111,32 +107,25 @@ final class BloopHighLevelCompiler(
}
}

def compilerArgs: CompilerArguments = {
def compileSources(
sources: Seq[VirtualFile],
scalacOptions: Array[String],
callback: AnalysisCallback
): Unit = {
import sbt.internal.inc.CompileFailed
if (scalac.scalaInstance.compilerJars().isEmpty) {
throw new CompileFailed(new Array(0), s"Expected Scala compiler jar in Scala instance containing ${scalac.scalaInstance.allJars().mkString(", ")}", new Array(0))
}

if (scalac.scalaInstance.libraryJars().isEmpty) {
throw new CompileFailed(new Array(0), s"Expected Scala library jar in Scala instance containing ${scalac.scalaInstance.allJars().mkString(", ")}", new Array(0))
}

new CompilerArguments(scalac.scalaInstance, classpathOptions)
}

def compileSources(
sources: Seq[VirtualFile],
scalacOptions: Array[String],
callback: AnalysisCallback
): Unit = {
try {
val args = compilerArgs.makeArguments(Nil, classpathNio, scalacOptions)
scalac.compile(
sources.toArray,
classpath.toArray,
PlainVirtualFileConverter.converter,
changes,
args.toArray,
scalacOptions,
setup.output,
callback,
config.reporter,
Expand All @@ -158,7 +147,6 @@ final class BloopHighLevelCompiler(

def compileSequentially: Task[Unit] = Task {
val scalacOptions = setup.options.scalacOptions
val args = compilerArgs.makeArguments(Nil, classpathNio, scalacOptions)
timed("scalac") {
compileSources(sources, scalacOptions, callback)
}
Expand Down

0 comments on commit bfcb709

Please sign in to comment.