-
Notifications
You must be signed in to change notification settings - Fork 613
/
Copy pathpackage.mill
88 lines (77 loc) · 2.63 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package build.core
import mill._
import mill.scalalib._
import mill.scalalib.scalafmt._
import mill.define.Cross
import de.tobiasroeser.mill.vcs.version.VcsVersion // pulled in by mill-ci-release
import build._
object `package` extends RootModule {
// https://github.com/com-lihaoyi/mill/issues/3693
object cross extends Cross[Core](v.scalaCrossVersions)
}
trait Core extends CrossSbtModule with HasScala2MacroAnno with ScalafmtModule {
def scalaVersion = crossScalaVersion
def millSourcePath = super.millSourcePath / os.up
override def scalacOptions = Task {
if (v.isScala3(crossScalaVersion)) {
Seq.empty[String]
} else {
v.scala2CommonOptions ++ Seq(
"-Xsource:3"
)
}
}
val crossModuleDeps = Seq(firrtl.cross(crossScalaVersion)) ++ {
if (v.isScala3(crossScalaVersion)) Seq.empty
else Seq(macros.cross(crossScalaVersion))
}
override def moduleDeps = super.moduleDeps ++ crossModuleDeps
val commonDeps = Agg(
v.osLib,
v.upickle
)
override def ivyDeps = if (v.isScala3(crossScalaVersion)) {
super.ivyDeps() ++ commonDeps ++ Agg(v.firtoolResolver.withDottyCompat(scalaVersion()))
} else {
super.ivyDeps() ++ commonDeps ++ Agg(v.firtoolResolver)
}
// Similar to the publish version, but no dirty indicators because otherwise
// this file will change any time any file is changed.
def publishVersion = Task {
VcsVersion
.vcsState()
.format(
countSep = "+",
revHashDigits = 8,
untaggedSuffix = "-SNAPSHOT",
dirtySep = "",
dirtyHashDigits = 0
)
}
def buildInfo = Task {
val outputFile = Task.dest / "chisel3" / "BuildInfo.scala"
val firtoolVersionString = "Some(\"" + v.firtoolVersion + "\")"
val contents =
s"""
|package chisel3
|case object BuildInfo {
| val buildInfoPackage: String = "chisel3"
| val version: String = "${publishVersion()}"
| val scalaVersion: String = "${scalaVersion()}"
| @deprecated("Chisel no longer uses SBT, this field will be removed.", "Chisel 7.0")
| val sbtVersion: String = ""
| val firtoolVersion: scala.Option[String] = $firtoolVersionString
| override val toString: String = {
| "buildInfoPackage: %s, version: %s, scalaVersion: %s, firtoolVersion %s".format(
| buildInfoPackage, version, scalaVersion, firtoolVersion
| )
| }
|}
|""".stripMargin
os.write(outputFile, contents, createFolders = true)
PathRef(Task.dest)
}
override def generatedSources = Task {
super.generatedSources() :+ buildInfo()
}
}