Skip to content

Commit

Permalink
improvement: Use sbt bridge defined by the user
Browse files Browse the repository at this point in the history
This is needed to fully compile Dotty right now.
  • Loading branch information
tgodzik committed Oct 25, 2024
1 parent 57eb430 commit a9d25ff
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ object BloopComponentCompiler {
private def compiledBridge(bridgeSources: ModuleID, scalaInstance: ScalaInstance): File = {
val raw = new RawCompiler(scalaInstance, ClasspathOptionsUtil.auto, logger)
val bridgeJarsOpt = scalaInstance match {
case b: _root_.bloop.ScalaInstance => b.bridgeJarsOpt
case b: _root_.bloop.ScalaInstance =>
b.bridgeJarsOpt.foreach { jars =>
logger.debug(s"Using user defined bridge jars for Scala ${jars.mkString(",")}")(
DebugFilter.Compilation
)
}
b.bridgeJarsOpt
case _ => None
}
val zinc = new BloopComponentCompiler(raw, manager, bridgeSources, bridgeJarsOpt, logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ object BloopDefaults {
val modules = onlyCompilationModules(allModules, classpath).toList
if (modules.isEmpty) None else Some(Config.Resolution(modules))
}
val bridge = Keys.scalaCompilerBridgeBinaryJar.value.map(file => List(file.toPath()))

// Force source generators on this task manually
Keys.managedSources.value
Expand All @@ -1034,7 +1035,7 @@ object BloopDefaults {
val c = Keys.classpathOptions.value
val java = Config.Java(javacOptions)
val compileSetup = Config.CompileSetup(compileOrder, c.bootLibrary, c.compiler, c.extra, c.autoBoot, c.filterLibrary)
val `scala` = Config.Scala(scalaOrg, scalaName, scalaVersion, scalacOptions, allScalaJars, None, Some(compileSetup), None)
val `scala` = Config.Scala(scalaOrg, scalaName, scalaVersion, scalacOptions, allScalaJars, None, Some(compileSetup), bridge)
val resources = Some(bloopResourcesTask.value)

val sbt = None // Written by `postGenerate` instead
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import bloop.integrations.sbt.BloopDefaults

val foo = project
.in(file(".") / "foo")
.settings(
scalaCompilerBridgeBinaryJar := Some(baseDirectory.value / "fake.jar")
)

val checkBloopFiles = taskKey[Unit]("Check bloop file contents")
checkBloopFiles in ThisBuild := {
val bloopDir = Keys.baseDirectory.value./(".bloop")
val fooConfig = bloopDir./("foo.json")
val config = BloopDefaults.unsafeParseConfig(fooConfig.toPath)
val bridgeJars = config.project.scala.get.bridgeJars.map(_.map(_.toString))
val expectedJars = Some(List((Keys.baseDirectory.value / "foo" / "fake.jar").toString))
assert(bridgeJars == expectedJars)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % sys.props.apply("plugin.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> foo/bloopGenerate
> foo/test:bloopGenerate
> checkBloopFiles

0 comments on commit a9d25ff

Please sign in to comment.