Skip to content

Commit

Permalink
Classify Zinc workers by zinc version
Browse files Browse the repository at this point in the history
Each version of zinc comes with its own compiler bridges on every
version of Scala. Given that two different versions of Mill can use
two different versions of Zinc we must classify zinc workers by zinc
version (in addition to scala version).
  • Loading branch information
adpi2 committed Jan 7, 2021
1 parent e1de7ca commit 50a519a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,25 @@ object scalalib extends MillModule {
def testArgs = T{Seq(
"-DMILL_SCALA_WORKER=" + runClasspath().map(_.path).mkString(",")
)}

override def generatedSources = T{
val dest = T.ctx.dest
val artifacts = T.traverse(dev.moduleDeps)(_.publishSelfDependency)()
os.write(dest / "Versions.scala",
s"""package mill.scalalib.worker
|
|/**
| * Dependency versions.
| * Generated from mill in build.sc.
| */
|object Versions {
| /** Version of Zinc. */
| val zinc = "${Deps.zinc.dep.version}"
|}
|
|""".stripMargin)
super.generatedSources() ++ Seq(PathRef(dest))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion scalalib/worker/src/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ZincWorkerImpl(compilerBridge: Either[
compilerBridge match {
case Right(compiled) => compiled(scalaVersion)
case Left((ctx0, bridgeProvider)) =>
val workingDir = ctx0.dest / scalaVersion
val workingDir = ctx0.dest / s"zinc-${Versions.zinc}" / scalaVersion
val lock = synchronized(compilerBridgeLocks.getOrElseUpdate(scalaVersion, new Object()))
val compiledDest = workingDir / 'compiled
lock.synchronized{
Expand Down

0 comments on commit 50a519a

Please sign in to comment.