-
Notifications
You must be signed in to change notification settings - Fork 613
/
Copy pathpackage.mill
49 lines (39 loc) · 1.75 KB
/
package.mill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package build.plugin
import mill._
import mill.scalalib._
import mill.scalalib.scalafmt._
import mill.define.Cross
import build._
import build_.release
object `package` extends RootModule {
// https://github.com/com-lihaoyi/mill/issues/3693
object cross extends Cross[Plugin](v.pluginScalaCrossVersions)
}
trait Plugin extends CrossSbtModule with ScalafmtModule with release.ChiselPublishModule {
override def artifactName = "chisel-plugin"
def millSourcePath = super.millSourcePath / os.up
// The plugin is compiled for every minor Scala version
override def crossFullScalaVersion = true
// This is a bit of a hack, but for some reason, Scala compilation crashes with -release 8 for
// Scala 2.13.0-2.13.2. While -release 8 is what we want, -target:jvm-1.8 at least ensures the
// bytecode is Java 8 compatible, and then the higher Scala versions compiled with -release 8 will
// enforce the other guarantees of -release 8 (that we don't accidentally use Java APIs introduced
// in newer JDKs).
def releaseArg(scalaVersion: String): Seq[String] = {
val badSet = Set("2.13.0", "2.13.1", "2.13.2")
if (badSet.contains(scalaVersion)) Seq("-target:jvm-1.8")
else Seq("-release", "8")
}
// Does not use common options because -Wconf wasn't supported in early 2.13, nor was "-release:"
override def scalacOptions = super.scalacOptions() ++ releaseArg(crossScalaVersion)
def scalaLibraryIvy = v.scalaLibrary(crossScalaVersion)
def scalaReflectIvy = v.scalaReflect(crossScalaVersion)
def scalaCompilerIvy: Dep = v.scalaCompiler(crossScalaVersion)
def ivyDeps = Task {
if (!v.isScala3(crossScalaVersion)) {
super.ivyDeps() ++ Agg(scalaLibraryIvy, scalaReflectIvy, scalaCompilerIvy)
} else {
super.ivyDeps()
}
}
}