Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate compiler classpath and bootclasspath options #1721

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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